diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2017-09-26 04:32:54 +0300 |
---|---|---|
committer | Matthieu Aubry <mattab@users.noreply.github.com> | 2017-09-26 04:32:54 +0300 |
commit | 948e1f04b48b7f6a8ef7d0f0421bf075feb9003a (patch) | |
tree | f21ba915daca8ce86eb2cb57fe7bec76688bfb19 /core | |
parent | 2459f222b6f96db3698e1f6b380c59a0bd8b5938 (diff) |
Better fetching of saved report parameters by report ID (#11983)
* Better report parameter fetching
* prefer a unique report id
* add method to get id
* removed code that is supposed to be in different PR
Diffstat (limited to 'core')
-rw-r--r-- | core/Plugin/Report.php | 20 | ||||
-rw-r--r-- | core/ViewDataTable/Factory.php | 9 |
2 files changed, 27 insertions, 2 deletions
diff --git a/core/Plugin/Report.php b/core/Plugin/Report.php index df28f450c9..24887fb4c0 100644 --- a/core/Plugin/Report.php +++ b/core/Plugin/Report.php @@ -318,6 +318,26 @@ class Report } /** + * + * Processing a uniqueId for each report, can be used by UIs as a key to match a given report + * @return string + */ + public function getId() + { + $params = $this->getParameters(); + + $paramsKey = $this->getModule() . '.' . $this->getAction(); + + if (!empty($params)) { + foreach ($params as $key => $value) { + $paramsKey .= '_' . $key . '--' . $value; + } + } + + return $paramsKey; + } + + /** * lets you add any amount of widgets for this report. If a report defines a {@link $categoryId} and a * {@link $subcategoryId} a widget will be generated automatically. * diff --git a/core/ViewDataTable/Factory.php b/core/ViewDataTable/Factory.php index 90a44281e4..b9b166b963 100644 --- a/core/ViewDataTable/Factory.php +++ b/core/ViewDataTable/Factory.php @@ -106,12 +106,17 @@ class Factory $params = array(); - if(is_null($loadViewDataTableParametersForUser)) { + if (!isset($loadViewDataTableParametersForUser)) { $loadViewDataTableParametersForUser = ('0' == Common::getRequestVar('widget', '0', 'string')); } + if ($loadViewDataTableParametersForUser) { $login = Piwik::getCurrentUserLogin(); - $params = Manager::getViewDataTableParameters($login, $controllerAction); + $paramsKey = $controllerAction; + if (!empty($report) && $controllerAction === $apiAction) { + $paramsKey = $report->getId(); + } + $params = Manager::getViewDataTableParameters($login, $paramsKey); } if (!self::isDefaultViewTypeForReportFixed($report)) { |