diff options
author | Thomas Steur <thomas.steur@googlemail.com> | 2014-05-29 04:45:06 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@googlemail.com> | 2014-05-29 04:45:06 +0400 |
commit | 82da315ea28b6ac1b94f3bc683bc0c8f29756fce (patch) | |
tree | 7830306d3c2c52ef8ce89af922e3d78090784fd6 /plugins | |
parent | 62acfde14e6c514b6a5008c9f6aaa284b01db44b (diff) |
refs #5212 added possibility to make a system setting readable for non super users
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/ExampleSettingsPlugin/Settings.php | 1 | ||||
-rw-r--r-- | plugins/LeftMenu/API.php | 17 | ||||
-rw-r--r-- | plugins/LeftMenu/Settings.php | 1 |
3 files changed, 12 insertions, 7 deletions
diff --git a/plugins/ExampleSettingsPlugin/Settings.php b/plugins/ExampleSettingsPlugin/Settings.php index 2eb78b465a..40a06aebd8 100644 --- a/plugins/ExampleSettingsPlugin/Settings.php +++ b/plugins/ExampleSettingsPlugin/Settings.php @@ -117,6 +117,7 @@ class Settings extends \Piwik\Plugin\Settings $this->metric->introduction = 'Only Super Users can change the following settings:'; $this->metric->description = 'Choose the metric that should be displayed in the browser tab'; $this->metric->defaultValue = 'nb_visits'; + $this->metric->readableByCurrentUser = true; $this->addSetting($this->metric); } diff --git a/plugins/LeftMenu/API.php b/plugins/LeftMenu/API.php index 3cf190b5dd..c7313a37c7 100644 --- a/plugins/LeftMenu/API.php +++ b/plugins/LeftMenu/API.php @@ -7,6 +7,7 @@ * */ namespace Piwik\Plugins\LeftMenu; +use Piwik\Piwik; /** * API for plugin LeftMenu @@ -22,18 +23,20 @@ class API extends \Piwik\Plugin\API */ public function isEnabled() { - return true; - $settings = new Settings('LeftMenu'); + $default = $settings->globalEnabled->getValue(); - $global = $settings->globalEnabled->getValue(); - $user = $settings->userEnabled->getValue(); + if (!$settings->userEnabled->isReadableByCurrentUser()) { + return $default; + } - if (empty($user) || 'no' === $user) { - return false; + $user = $settings->userEnabled->getValue(); + + if (empty($user) || $user === 'default') { + return $default; } - if ($user === 'default' && !$global) { + if ($user === 'no') { return false; } diff --git a/plugins/LeftMenu/Settings.php b/plugins/LeftMenu/Settings.php index f0ee1f6f3c..6d33611b92 100644 --- a/plugins/LeftMenu/Settings.php +++ b/plugins/LeftMenu/Settings.php @@ -38,6 +38,7 @@ class Settings extends \Piwik\Plugin\Settings $this->globalEnabled->description = 'Defines the system default for all of your users.'; $this->globalEnabled->inlineHelp = 'Users are able to disable/enable the left menu independent of the system default'; $this->globalEnabled->defaultValue = true; + $this->globalEnabled->readableByCurrentUser = true; $this->addSetting($this->globalEnabled); } |