| <?php |
|
|
| |
| |
| |
| |
| |
| |
|
|
| namespace Piwik\Settings\Plugin; |
|
|
| use Piwik\Config; |
| use Piwik\Container\StaticContainer; |
| use Piwik\Piwik; |
| use Piwik\Settings\Setting; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| class SystemSetting extends Setting |
| { |
| |
| |
| |
| |
| |
| |
| public function __construct($name, $defaultValue, $type, $pluginName) |
| { |
| parent::__construct($name, $defaultValue, $type, $pluginName); |
|
|
| $factory = StaticContainer::get('Piwik\Settings\Storage\Factory'); |
| $this->storage = $factory->getPluginStorage($this->pluginName, $userLogin = ''); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| public function isWritableByCurrentUser() |
| { |
| if ($this->hasConfigValue()) { |
| return false; |
| } |
|
|
| if (isset($this->hasWritePermission)) { |
| return $this->hasWritePermission; |
| } |
|
|
| |
| $this->hasWritePermission = Piwik::hasUserSuperUserAccess(); |
|
|
| return $this->hasWritePermission; |
| } |
|
|
| |
| |
| |
| public function getValue() |
| { |
| $defaultValue = parent::getValue(); |
|
|
| $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]; |
| } |
| } |
| } |
|
|