Inheritance: extends Piwik\Plugin
Esempio n. 1
0
 public function configureAdminMenu(MenuAdmin $menu)
 {
     $hasSuperUserAcess = Piwik::hasUserSuperUserAccess();
     $isAnonymous = Piwik::isUserIsAnonymous();
     $isMarketplaceEnabled = CorePluginsAdmin::isMarketplaceEnabled();
     $pluginsUpdateMessage = '';
     $themesUpdateMessage = '';
     if ($hasSuperUserAcess && $isMarketplaceEnabled) {
         $marketplace = new Marketplace();
         $pluginsHavingUpdate = $marketplace->getPluginsHavingUpdate($themesOnly = false);
         $themesHavingUpdate = $marketplace->getPluginsHavingUpdate($themesOnly = true);
         if (!empty($pluginsHavingUpdate)) {
             $pluginsUpdateMessage = sprintf(' (%d)', count($pluginsHavingUpdate));
         }
         if (!empty($themesHavingUpdate)) {
             $themesUpdateMessage = sprintf(' (%d)', count($themesHavingUpdate));
         }
     }
     $menu->add('CorePluginsAdmin_MenuPlatform', null, "", !$isAnonymous, $order = 7);
     $menu->add('CorePluginsAdmin_MenuPlatform', Piwik::translate('General_Plugins') . $pluginsUpdateMessage, array('module' => 'CorePluginsAdmin', 'action' => 'plugins', 'activated' => ''), $hasSuperUserAcess, $order = 1);
     $menu->add('CorePluginsAdmin_MenuPlatform', Piwik::translate('CorePluginsAdmin_Themes') . $themesUpdateMessage, array('module' => 'CorePluginsAdmin', 'action' => 'themes', 'activated' => ''), $hasSuperUserAcess, $order = 3);
     if ($isMarketplaceEnabled) {
         $menu->add('CorePluginsAdmin_MenuPlatform', 'CorePluginsAdmin_Marketplace', array('module' => 'CorePluginsAdmin', 'action' => 'extend', 'activated' => ''), !$isAnonymous, $order = 5);
     }
 }
Esempio n. 2
0
 protected function configureView($template)
 {
     Piwik::checkUserIsNotAnonymous();
     $view = new View($template);
     $this->setBasicVariablesView($view);
     // If user can manage plugins+themes, display a warning if config not writable
     if (CorePluginsAdmin::isPluginsAdminEnabled()) {
         $this->displayWarningIfConfigFileNotWritable();
     }
     $view->errorMessage = '';
     return $view;
 }
Esempio n. 3
0
 /**
  * Checks whether a plugin update notification can be enabled or not. It cannot be enabled if for instance the
  * Marketplace is disabled or if update notifications are disabled in general.
  *
  * @return bool
  */
 public function canBeEnabled()
 {
     $isEnabled = Config::getInstance()->General['enable_update_communication'];
     return CorePluginsAdmin::isMarketplaceEnabled() && !empty($isEnabled);
 }
Esempio n. 4
0
 private function createPluginsOrThemesView($template, $themesOnly)
 {
     Piwik::checkUserIsSuperUser();
     $view = $this->configureView('@CorePluginsAdmin/' . $template);
     $view->updateNonce = Nonce::getNonce(static::UPDATE_NONCE);
     $view->activateNonce = Nonce::getNonce(static::ACTIVATE_NONCE);
     $view->uninstallNonce = Nonce::getNonce(static::UNINSTALL_NONCE);
     $view->deactivateNonce = Nonce::getNonce(static::DEACTIVATE_NONCE);
     $view->pluginsInfo = $this->getPluginsInfo($themesOnly);
     $users = \Piwik\Plugins\UsersManager\API::getInstance()->getUsers();
     $view->otherUsersCount = count($users) - 1;
     $view->themeEnabled = \Piwik\Plugin\Manager::getInstance()->getThemeEnabled()->getPluginName();
     $view->pluginNamesHavingSettings = $this->getPluginNamesHavingSettingsForCurrentUser();
     $view->isMarketplaceEnabled = CorePluginsAdmin::isMarketplaceEnabled();
     $view->isPluginsAdminEnabled = CorePluginsAdmin::isPluginsAdminEnabled();
     $view->pluginsHavingUpdate = array();
     $view->marketplacePluginNames = array();
     if (CorePluginsAdmin::isMarketplaceEnabled()) {
         try {
             $marketplace = new Marketplace();
             $view->marketplacePluginNames = $marketplace->getAvailablePluginNames($themesOnly);
             $view->pluginsHavingUpdate = $marketplace->getPluginsHavingUpdate($themesOnly);
         } catch (Exception $e) {
             // curl exec connection error (ie. server not connected to internet)
         }
     }
     return $view;
 }
Esempio n. 5
0
 private function isAllowedToSeeMarketPlace()
 {
     $isAnonymous = Piwik::isUserIsAnonymous();
     $isMarketplaceEnabled = CorePluginsAdmin::isMarketplaceEnabled();
     return $isMarketplaceEnabled && !$isAnonymous;
 }
Esempio n. 6
0
 private function dieIfPluginsAdminIsDisabled()
 {
     if (!CorePluginsAdmin::isPluginsAdminEnabled()) {
         throw new \Exception('Enabling, disabling and uninstalling plugins has been disabled by Piwik admins.
         Please contact your Piwik admins with your request so they can assist you.');
     }
 }