diff options
author | mattab <matthieu.aubry@gmail.com> | 2014-12-16 03:01:19 +0300 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2014-12-16 03:01:19 +0300 |
commit | 85fb283d7db457ad9bec03bb89802266da969946 (patch) | |
tree | 609f6093e6502e9cd56700203fc756532ac99f06 /plugins | |
parent | 000b4cbd593ff311ad606e8caaecaec067ecd6f0 (diff) |
Pull variable up as method parameter for reuse
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/UsersManager/UserPreferences.php | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/plugins/UsersManager/UserPreferences.php b/plugins/UsersManager/UserPreferences.php index 430d2b8b65..b1d70f4fcc 100644 --- a/plugins/UsersManager/UserPreferences.php +++ b/plugins/UsersManager/UserPreferences.php @@ -39,6 +39,7 @@ class UserPreferences return false; } + /** * Returns default site ID that Piwik should load. * @@ -91,27 +92,32 @@ class UserPreferences /** * Returns default period type for Piwik reports. * + * @param $defaultDate string the default date string from which the default period will be guessed * @return string `'day'`, `'week'`, `'month'`, `'year'` or `'range'` * @api */ - public function getDefaultPeriod() + public function getDefaultPeriod($defaultDate) { - $userSettingsDate = APIUsersManager::getInstance()->getUserPreference(Piwik::getCurrentUserLogin(), APIUsersManager::PREFERENCE_DEFAULT_REPORT_DATE); - - if ($userSettingsDate === false) { - return Config::getInstance()->General['default_period']; + $defaultPeriod = Config::getInstance()->General['default_period']; + if ($defaultDate === false) { + return $defaultPeriod; } - if (in_array($userSettingsDate, array('today', 'yesterday'))) { + if (in_array($defaultDate, array('today', 'yesterday'))) { return 'day'; } - if (strpos($userSettingsDate, 'last') === 0 - || strpos($userSettingsDate, 'previous') === 0 + if (strpos($defaultDate, 'last') === 0 + || strpos($defaultDate, 'previous') === 0 ) { return 'range'; } - return $userSettingsDate; + return $defaultPeriod; + } + + public function getAllUsersPreferences() + { + } }
\ No newline at end of file |