allowedNames)) { throw new Exception(sprintf('Name "%s" is not allowed to be used with a MeasurableProperty, use a MeasurableSetting instead.', $name)); } parent::__construct($name, $defaultValue, $type, $pluginName); $this->idSite = $idSite; $storageFactory = StaticContainer::get('Piwik\Settings\Storage\Factory'); $this->storage = $storageFactory->getSitesTable($idSite); } /** * Returns `true` if this setting can be displayed for the current user, `false` if otherwise. * * @return bool */ public function isWritableByCurrentUser() { if (isset($this->hasWritePermission)) { return $this->hasWritePermission; } // performance improvement, do not detect this in __construct otherwise likely rather "big" query to DB. if ($this->hasSiteBeenCreated()) { $this->hasWritePermission = Piwik::isUserHasAdminAccess($this->idSite); } else { $this->hasWritePermission = Piwik::hasUserSuperUserAccess(); } return $this->hasWritePermission; } private function hasSiteBeenCreated() { return !empty($this->idSite); } }