diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2016-01-14 05:07:35 +0300 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2016-01-14 05:07:35 +0300 |
commit | f2634f9ec0385cb0dc889672ec80d0cd25fc2d57 (patch) | |
tree | 72d0fc8b9f282a491aea12c64be7b03959bc20ca /core/Settings | |
parent | 95ca1edf95f0518fd09f5efffbac719b9ce0e4c3 (diff) |
refs https://github.com/piwik/plugin-QueuedTracking/issues/21 allow any plugin setting to be overwritten in the config file
Diffstat (limited to 'core/Settings')
-rw-r--r-- | core/Settings/SystemSetting.php | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/core/Settings/SystemSetting.php b/core/Settings/SystemSetting.php index 94f7416c19..fb0a4d7a2d 100644 --- a/core/Settings/SystemSetting.php +++ b/core/Settings/SystemSetting.php @@ -9,6 +9,7 @@ namespace Piwik\Settings; +use Piwik\Config; use Piwik\Piwik; /** @@ -58,6 +59,10 @@ class SystemSetting extends Setting */ public function isWritableByCurrentUser() { + if ($this->hasConfigValue()) { + return false; + } + return $this->writableByCurrentUser; } @@ -80,4 +85,34 @@ class SystemSetting extends Setting { return 30; } + + public function getValue() + { + $defaultValue = parent::getValue(); // we access value first to make sure permissions are checked + + $configValue = $this->getValueFromConfig(); + + if (isset($configValue)) { + $defaultValue = $configValue; + settype($defaultValue, $this->type); + } + + return $defaultValue; + } + + private function hasConfigValue() + { + $value = $this->getValueFromConfig(); + return isset($value); + } + + private function getValueFromConfig() + { + $config = Config::getInstance()->{$this->pluginName}; + + if (!empty($config) && array_key_exists($this->name, $config)) { + return $config[$this->name]; + } + } + } |