storage = $factory->getPluginStorage($this->pluginName, $userLogin = ''); } /** * Returns `true` if this setting is writable for the current user, `false` if otherwise. In case it returns * writable for the current user it will be visible in the Plugin settings UI. * * @return bool */ public function isWritableByCurrentUser() { if ($this->hasConfigValue()) { return false; } if (isset($this->hasWritePermission)) { return $this->hasWritePermission; } // performance improvement, do not detect this in __construct otherwise likely rather "big" query to DB. $this->hasWritePermission = Piwik::hasUserSuperUserAccess(); return $this->hasWritePermission; } /** * @inheritdoc */ 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]; } } }