private function createUsersOptOutSetting()
 {
     $this->userTrackingEnabled = new UserSetting('userTrackingEnabled', 'Piwik usage tracking enabled');
     $this->userTrackingEnabled->type = static::TYPE_BOOL;
     $this->userTrackingEnabled->uiControlType = static::CONTROL_CHECKBOX;
     $this->userTrackingEnabled->defaultValue = true;
     $this->userTrackingEnabled->description = 'If enabled, anonymous usage data will be tracked. For example which pages are viewed and which reports are used most often. For more information contact your system administrator.';
     if ($this->canUserOptOut->getValue()) {
         // we show this setting only when a user can actually opt out
         $this->addSetting($this->userTrackingEnabled);
     }
 }
Пример #2
0
 private function createGenerateKeysSetting()
 {
     $this->generateKeys = new SystemSetting('generateKeys', Piwik::translate('LoginEncrypted_SettingsGenerateKeysTitle'));
     $this->generateKeys->readableByCurrentUser = true;
     $this->generateKeys->type = static::TYPE_BOOL;
     $this->generateKeys->uiControlType = static::CONTROL_CHECKBOX;
     $this->generateKeys->description = Piwik::translate('LoginEncrypted_SettingsGenerateKeysDescription');
     $this->generateKeys->defaultValue = false;
     $this->generateKeys->transform = function ($value, $setting) {
         // check if check box got activated, and generate keys if so
         if ($value != $setting->defaultValue) {
             $publickey = Crypto::generateKeys($this->keyLength->getValue());
             $this->publicKey->setValue($publickey['e'] . ', ' . $publickey['n']);
         }
         return $setting->defaultValue;
         // reset checkbox
     };
     $this->addSetting($this->generateKeys);
 }
 private function createStartTrackingSetting()
 {
     $goals = \Piwik\API\Request::processRequest('Goals.getGoals', array('idSite' => $this->matching_site->getValue()));
     $options = array();
     foreach ($goals as $goal) {
         $options[$goal['idgoal']] = $goal['name'];
     }
     $this->matching_goals = new SystemSetting('matching_goals', 'Goals to start scoring');
     //$this->matching_goals->readableByCurrentUser = true;
     $this->matching_goals->type = static::TYPE_ARRAY;
     $this->matching_goals->uiControlType = static::CONTROL_MULTI_SELECT;
     $this->matching_goals->description = 'Goals that match our visitor.';
     $this->matching_goals->availableValues = array('0' => 'None') + $options;
     $this->addSetting($this->matching_goals);
 }
 public function setValue($value)
 {
     $newNumWorkers = $value;
     $oldNumWorkers = $this->getValue();
     parent::setValue($value);
     if ($newNumWorkers && $oldNumWorkers) {
         try {
             $manager = Factory::makeQueueManager(Factory::makeBackend());
             $manager->setNumberOfAvailableQueues($newNumWorkers);
             $manager->moveSomeQueuesIfNeeded($newNumWorkers, $oldNumWorkers);
         } catch (\Exception $e) {
             // it is ok if this fails. then it is most likely not enabled etc.
         }
     }
 }
Пример #5
0
 private function createRedisTimeoutSetting()
 {
     $this->redisTimeout = new SystemSetting('redisTimeout', 'Redis timeout');
     $this->redisTimeout->readableByCurrentUser = true;
     $this->redisTimeout->type = static::TYPE_FLOAT;
     $this->redisTimeout->uiControlType = static::CONTROL_TEXT;
     $this->redisTimeout->uiControlAttributes = array('size' => 5);
     $this->redisTimeout->inlineHelp = 'Redis connection timeout in seconds. "0.0" meaning unlimited. Can be a float eg "2.5" for a connection timeout of 2.5 seconds.';
     $this->redisTimeout->defaultValue = 0.0;
     $this->redisTimeout->validate = function ($value) {
         if (!is_numeric($value)) {
             throw new \Exception('Timeout should be numeric, eg "0.1"');
         }
         if (strlen($value) > 5) {
             throw new \Exception('Max 5 characters allowed');
         }
     };
     // we do not expose this one to the UI currently. That's on purpose
     $this->redisTimeout->setStorage($this->staticStorage);
 }