/**
  * Install a plugin, if necessary
  *
  * @param Piwik_Plugin  $plugin
  */
 private function installPluginIfNecessary(Piwik_Plugin $plugin)
 {
     $pluginName = $plugin->getPluginName();
     $saveConfig = false;
     // is the plugin already installed or is it the first time we activate it?
     $pluginsInstalled = $this->getInstalledPluginsName();
     if (!in_array($pluginName, $pluginsInstalled)) {
         $this->installPlugin($plugin);
         $pluginsInstalled[] = $pluginName;
         $this->updatePluginsInstalledConfig($pluginsInstalled);
         $saveConfig = true;
     }
     $information = $plugin->getInformation();
     // if the plugin is to be loaded during the statistics logging
     if (isset($information['TrackerPlugin']) && $information['TrackerPlugin'] === true) {
         $pluginsTracker = Piwik_Config::getInstance()->Plugins_Tracker['Plugins_Tracker'];
         if (is_null($pluginsTracker)) {
             $pluginsTracker = array();
         }
         if (!in_array($pluginName, $pluginsTracker)) {
             $pluginsTracker[] = $pluginName;
             $this->updatePluginsTrackerConfig($pluginsTracker);
             $saveConfig = true;
         }
     }
     if ($saveConfig) {
         Piwik_Config::getInstance()->forceSave();
     }
 }
 private function installPluginIfNecessary(Piwik_Plugin $plugin)
 {
     $pluginName = $plugin->getClassName();
     // is the plugin already installed or is it the first time we activate it?
     $pluginsInstalled = $this->getInstalledPluginsName();
     if (!in_array($pluginName, $pluginsInstalled)) {
         $this->installPlugin($plugin);
         $pluginsInstalled[] = $pluginName;
         Zend_Registry::get('config')->PluginsInstalled = array('PluginsInstalled' => $pluginsInstalled);
     }
     $information = $plugin->getInformation();
     // if the plugin is to be loaded during the statistics logging
     if (isset($information['TrackerPlugin']) && $information['TrackerPlugin'] === true) {
         $pluginsTracker = Zend_Registry::get('config')->Plugins_Tracker->Plugins_Tracker;
         if (is_null($pluginsTracker)) {
             $pluginsTracker = array();
         } else {
             $pluginsTracker = $pluginsTracker->toArray();
         }
         if (!in_array($pluginName, $pluginsTracker)) {
             $pluginsTracker[] = $pluginName;
             Zend_Registry::get('config')->Plugins_Tracker = array('Plugins_Tracker' => $pluginsTracker);
         }
     }
 }
Exemple #3
0
 /**
  * For the given plugin, add all the observers of this plugin.
  */
 private function addPluginObservers(Piwik_Plugin $plugin)
 {
     $hooks = $plugin->getListHooksRegistered();
     foreach ($hooks as $hookName => $methodToCall) {
         $this->dispatcher->addObserver(array($plugin, $methodToCall), $hookName);
     }
 }