| <?php |
|
|
| |
| |
| |
| |
| |
| |
|
|
| namespace Piwik\Settings\Measurable; |
|
|
| use Piwik\Container\StaticContainer; |
| use Piwik\Piwik; |
| use Exception; |
| use Piwik\Settings\Storage\Factory; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| class MeasurableProperty extends \Piwik\Settings\Setting |
| { |
| |
| |
| |
| private $idSite = 0; |
|
|
| private $allowedNames = array( |
| 'ecommerce', 'sitesearch', 'sitesearch_keyword_parameters', |
| 'sitesearch_category_parameters', 'excluded_referrers', |
| 'exclude_unknown_urls', 'excluded_ips', 'excluded_parameters', |
| 'excluded_user_agents', 'keep_url_fragment', 'urls', 'group', |
| ); |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| public function __construct($name, $defaultValue, $type, $pluginName, $idSite) |
| { |
| if (!in_array($name, $this->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); |
| } |
|
|
| |
| |
| |
| |
| |
| public function isWritableByCurrentUser() |
| { |
| if (isset($this->hasWritePermission)) { |
| return $this->hasWritePermission; |
| } |
|
|
| |
| if ($this->hasSiteBeenCreated()) { |
| $this->hasWritePermission = Piwik::isUserHasAdminAccess($this->idSite); |
| } else { |
| $this->hasWritePermission = Piwik::hasUserSuperUserAccess(); |
| } |
|
|
| return $this->hasWritePermission; |
| } |
|
|
| private function hasSiteBeenCreated() |
| { |
| return !empty($this->idSite); |
| } |
| } |
|
|