diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2013-10-24 05:43:51 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2013-10-24 05:43:51 +0400 |
commit | 52e8a0d868069c090997aaa134ecc51ef275b4c2 (patch) | |
tree | ef24bf3a645e4140875c7aa5261687e5d9d6ca4a /core/Settings | |
parent | 0f2af694d5ae42215a3afb3ea642d163fefa56ec (diff) |
refs #4126 added more example, handle type array and field multi select correct, code cleanup
Diffstat (limited to 'core/Settings')
-rw-r--r-- | core/Settings/Setting.php | 17 | ||||
-rw-r--r-- | core/Settings/UserSetting.php | 4 |
2 files changed, 7 insertions, 14 deletions
diff --git a/core/Settings/Setting.php b/core/Settings/Setting.php index 43bbd49149..00efc9d876 100644 --- a/core/Settings/Setting.php +++ b/core/Settings/Setting.php @@ -128,26 +128,14 @@ abstract class Setting protected $name; protected $displayedForCurrentUser = false; - public function canBeDisplayedForCurrentUser() - { - return $this->displayedForCurrentUser; - } - /** * Creates a new setting. * * @param string $name The name of the setting, only alnum characters are allowed. For instance `refreshInterval` * @param string $title The title of the setting which will be visible to the user. For instance `Refresh Interval` - * - * @throws \Exception In case the name contains invalid characters. */ public function __construct($name, $title) { - if (!ctype_alnum($name)) { - $msg = sprintf('The setting name %s is not valid. Only alpha and numerical characters are allowed', $name); - throw new \Exception($msg); - } - $this->key = $name; $this->name = $name; $this->title = $title; @@ -158,6 +146,11 @@ abstract class Setting return $this->name; } + public function canBeDisplayedForCurrentUser() + { + return $this->displayedForCurrentUser; + } + /** * Returns the key under which property name the setting will be stored. * diff --git a/core/Settings/UserSetting.php b/core/Settings/UserSetting.php index c207e2e805..c7eb7eeb26 100644 --- a/core/Settings/UserSetting.php +++ b/core/Settings/UserSetting.php @@ -37,7 +37,7 @@ class UserSetting extends Setting $this->setUserLogin($userLogin); - $this->displayedForCurrentUser = !Piwik::isUserIsAnonymous(); + $this->displayedForCurrentUser = !Piwik::isUserIsAnonymous() && Piwik::isUserHasSomeViewAccess(); } private function buildUserSettingName($name, $userLogin = null) @@ -94,7 +94,7 @@ class UserSetting extends Setting if ($setting instanceof UserSetting) { $setting->setUserLogin($userLogin); - $pluginSettings->removeValue($setting); + $pluginSettings->removeSettingValue($setting); } } |