コード例 #1
0
 function updatePriorities()
 {
     $request =& HTTPRequest::instance();
     if ($request->exist('priorities')) {
         $plugin_manager =& PluginManager::instance();
         $plugin_hook_priority_manager = new PluginHookPriorityManager();
         $updated = false;
         foreach ($request->get('priorities') as $hook => $plugins) {
             if (is_array($plugins)) {
                 foreach ($plugins as $id => $priority) {
                     $plugin =& $plugin_manager->getPluginById((int) $id);
                     $updated = $updated || $plugin_hook_priority_manager->setPriorityForPluginHook($plugin, $hook, (int) $priority);
                 }
             }
         }
         if ($updated) {
             $GLOBALS['feedback'] .= 'Priorities updated';
         }
     }
 }
コード例 #2
0
 function _searchPlugins()
 {
     if (!$this->_plugins) {
         $this->_plugins = array();
         $this->_priorities = array();
         $plugin_hook_priority_manager = new PluginHookPriorityManager();
         $plugin_manager = $this->plugin_manager;
         try {
             $forgeUpgradeConfig = new ForgeUpgradeConfig();
             $forgeUpgradeConfig->loadDefaults();
             $noFUConfig = array();
         } catch (Exception $e) {
             $GLOBALS['Response']->addFeedback('warning', $e->getMessage());
         }
         $plugins = $plugin_manager->getAllPlugins();
         foreach ($plugins as $plugin) {
             $plug_info =& $plugin->getPluginInfo();
             $descriptor =& $plug_info->getPluginDescriptor();
             $available = $plugin_manager->isPluginAvailable($plugin);
             $name = $descriptor->getFullName();
             if (strlen(trim($name)) === 0) {
                 $name = get_class($plugin);
             }
             $dont_touch = strcasecmp(get_class($plugin), 'PluginsAdministrationPlugin') === 0;
             $dont_restrict = $plugin->getScope() !== Plugin::SCOPE_PROJECT;
             $this->_plugins[] = array('plugin_id' => $plugin->getId(), 'name' => $name, 'description' => $descriptor->getDescription(), 'version' => $descriptor->getVersion(), 'available' => $available, 'scope' => $plugin->getScope(), 'dont_touch' => $dont_touch, 'dont_restrict' => $dont_restrict);
             if (isset($noFUConfig) && !$forgeUpgradeConfig->existsInPath($plugin->getFilesystemPath())) {
                 $noFUConfig[] = array('name' => $name, 'plugin' => $plugin);
             }
             $col_hooks =& $plugin->getHooks();
             $hooks =& $col_hooks->iterator();
             while ($hooks->valid()) {
                 $hook =& $hooks->current();
                 $priority = $plugin_hook_priority_manager->getPriorityForPluginHook($plugin, $hook);
                 if (!isset($this->_priorities[$hook])) {
                     $this->_priorities[$hook] = array();
                 }
                 if (!isset($this->_priorities[$hook][$priority])) {
                     $this->_priorities[$hook][$priority] = array();
                 }
                 $this->_priorities[$hook][$priority][$plugin->getId()] = array('name' => $name, 'available' => $available);
                 $hooks->next();
             }
         }
         // ForgeUpgrade configuration warning
         if (isset($noFUConfig) && count($noFUConfig) && isset($GLOBALS['forgeupgrade_file'])) {
             $txt = 'Some plugins are not referenced in ForgeUpgrade configuration, please add the following in <code>' . $GLOBALS['forgeupgrade_file'] . '.</code><br/>';
             foreach ($noFUConfig as $plugInfo) {
                 $txt .= '<code>path[]="' . $plugInfo['plugin']->getFilesystemPath() . '"</code><br/>';
             }
             $GLOBALS['Response']->addFeedback('warning', $txt, CODENDI_PURIFIER_DISABLED);
         }
     }
 }