Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/UsersManager/API.php')
-rw-r--r--plugins/UsersManager/API.php29
1 files changed, 28 insertions, 1 deletions
diff --git a/plugins/UsersManager/API.php b/plugins/UsersManager/API.php
index 1e651eef13..75d9190cd1 100644
--- a/plugins/UsersManager/API.php
+++ b/plugins/UsersManager/API.php
@@ -32,6 +32,8 @@ use Piwik\Tracker\Cache;
*/
class API extends \Piwik\Plugin\API
{
+ const OPTION_NAME_PREFERENCE_SEPARATOR = '_';
+
/**
* @var Model
*/
@@ -107,9 +109,34 @@ class API extends \Piwik\Plugin\API
return $this->getDefaultUserPreference($preferenceName, $userLogin);
}
+ /**
+ * Returns an array of Preferences
+ * @param $preferenceNames array of preference names
+ * @return array
+ * @ignore
+ */
+ public function getAllUsersPreferences(array $preferenceNames)
+ {
+ Piwik::checkUserHasSuperUserAccess();
+
+ $userPreferences = array();
+ foreach($preferenceNames as $preferenceName) {
+ $optionNameMatchAllUsers = $this->getPreferenceId('%', $preferenceName);
+ $preferences = Option::getLike($optionNameMatchAllUsers);
+
+ foreach($preferences as $optionName => $optionValue) {
+ $optionName = explode(self::OPTION_NAME_PREFERENCE_SEPARATOR, $optionName);
+ $userName = $optionName[0];
+ $preference = $optionName[1];
+ $userPreferences[$userName][$preference] = $optionValue;
+ }
+ }
+ return $userPreferences;
+ }
+
private function getPreferenceId($login, $preference)
{
- return $login . '_' . $preference;
+ return $login . self::OPTION_NAME_PREFERENCE_SEPARATOR . $preference;
}
private function getDefaultUserPreference($preferenceName, $login)