Descendants of this class should implement the {@link init()} method and call the {@link addSetting()} method for each of the plugin's settings. For an example, see the {@link Piwik\Plugins\ExampleSettingsPlugin\ExampleSettingsPlugin} plugin.
Beispiel #1
0
 public function configfile()
 {
     Piwik::checkUserHasSuperUserAccess();
     $settings = new SettingsProvider(\Piwik\Plugin\Manager::getInstance());
     $allSettings = $settings->getAllSystemSettings();
     $configValues = $this->configReader->getConfigValuesFromFiles();
     $configValues = $this->configReader->addConfigValuesFromSystemSettings($configValues, $allSettings);
     $configValues = $this->sortConfigValues($configValues);
     return $this->renderTemplate('configfile', array('allConfigValues' => $configValues));
 }
Beispiel #2
0
 public function activate($redirectAfter = true)
 {
     $pluginName = $this->initPluginModification(static::ACTIVATE_NONCE);
     $this->dieIfPluginsAdminIsDisabled();
     $this->pluginManager->activatePlugin($pluginName);
     if ($redirectAfter) {
         $message = $this->translator->translate('CorePluginsAdmin_SuccessfullyActicated', array($pluginName));
         if ($this->settingsProvider->getSystemSettings($pluginName)) {
             $target = sprintf('<a href="index.php%s#%s">', Url::getCurrentQueryStringWithParametersModified(array('module' => 'CoreAdminHome', 'action' => 'generalSettings')), $pluginName);
             $message .= ' ' . $this->translator->translate('CorePluginsAdmin_ChangeSettingsPossible', array($target, '</a>'));
         }
         $notification = new Notification($message);
         $notification->raw = true;
         $notification->title = $this->translator->translate('General_WellDone');
         $notification->context = Notification::CONTEXT_SUCCESS;
         Notification\Manager::notify('CorePluginsAdmin_PluginActivated', $notification);
         $redirectTo = Common::getRequestVar('redirectTo', '', 'string');
         if (!empty($redirectTo) && $redirectTo === 'marketplace') {
             $this->redirectToIndex('Marketplace', 'overview');
         } elseif (!empty($redirectTo) && $redirectTo === 'referrer') {
             $this->redirectAfterModification($redirectAfter);
         } else {
             $plugin = $this->pluginManager->loadPlugin($pluginName);
             $actionToRedirect = 'plugins';
             if ($plugin->isTheme()) {
                 $actionToRedirect = 'themes';
             }
             $this->redirectToIndex('CorePluginsAdmin', $actionToRedirect);
         }
     }
 }
Beispiel #3
0
 /**
  * Returns all available measurable types.
  * Marked as deprecated so it won't appear in API page. It won't be a public API for now.
  * @deprecated
  * @return array
  */
 public function getAvailableMeasurableTypes()
 {
     Piwik::checkUserHasSomeViewAccess();
     $typeManager = new TypeManager();
     $types = $typeManager->getAllTypes();
     $available = array();
     foreach ($types as $type) {
         $measurableSettings = $this->settingsProvider->getAllMeasurableSettings($idSite = 0, $type->getId());
         $settingsMetadata = new SettingsMetadata();
         $available[] = array('id' => $type->getId(), 'name' => Piwik::translate($type->getName()), 'description' => Piwik::translate($type->getDescription()), 'howToSetupUrl' => $type->getHowToSetupUrl(), 'settings' => $settingsMetadata->formatSettings($measurableSettings));
     }
     return $available;
 }
Beispiel #4
0
 /**
  * @internal
  * @return array
  * @throws \Piwik\NoAccessException
  */
 public function getUserSettings()
 {
     Piwik::checkUserIsNotAnonymous();
     $userSettings = $this->settingsProvider->getAllUserSettings();
     return $this->settingsMetadata->formatSettings($userSettings);
 }
Beispiel #5
0
 private function setAndValidateMeasurableSettings($idSite, $idType, $settingValues)
 {
     $measurableSettings = $this->settingsProvider->getAllMeasurableSettings($idSite, $idType);
     $this->settingsMetadata->setPluginSettings($measurableSettings, $settingValues);
     return $measurableSettings;
 }