Esempio n. 1
0
 /**
  * Plugin activation
  *
  * @throws iMSCP_Plugin_Exception
  * @param iMSCP_Plugin_Manager $pluginManager
  * @return void
  */
 public function enable(iMSCP_Plugin_Manager $pluginManager)
 {
     try {
         # Make sure that postgrey smtp restriction is evaluated first. This is based on plugin_priority field.
         if ($pluginManager->pluginIsKnown('Postgrey') && $pluginManager->pluginIsEnabled('Postgrey')) {
             $pluginManager->pluginChange('Postgrey');
         }
         iMSCP_Registry::get('dbConfig')->set('PORT_POLICYD_WEIGHT', $this->getConfigParam('policyd_weight_port', 12525) . ';tcp;POLICYD_WEIGHT;1;127.0.0.1');
     } catch (iMSCP_Exception $e) {
         throw new iMSCP_Plugin_Exception($e->getMessage(), $e->getCode(), $e);
     }
 }
Esempio n. 2
0
/**
 * Generates plugin list
 *
 * @param TemplateEngine $tpl Template engine instance
 * @param PluginManager $pluginManager
 * @return void
 */
function generatePage($tpl, $pluginManager)
{
    $pluginList = $pluginManager->pluginGetList('Action', false);
    if (empty($pluginList)) {
        $tpl->assign('PLUGINS_BLOCK', '');
        set_page_message(tr('Plugin list is empty.'), 'static_info');
    } else {
        natsort($pluginList);
        $cacheFile = PERSISTENT_PATH . '/protected_plugins.php';
        foreach ($pluginList as $pluginName) {
            $pluginInfo = $pluginManager->pluginGetInfo($pluginName);
            $pluginStatus = $pluginManager->pluginGetStatus($pluginName);
            if (is_array($pluginInfo['author'])) {
                if (count($pluginInfo['author']) == 2) {
                    $pluginInfo['author'] = implode(' ' . tr('and') . ' ', $pluginInfo['author']);
                } else {
                    $lastEntry = array_pop($pluginInfo['author']);
                    $pluginInfo['author'] = implode(', ', $pluginInfo['author']);
                    $pluginInfo['author'] .= ' ' . tr('and') . ' ' . $lastEntry;
                }
            }
            $tpl->assign(array('PLUGIN_NAME' => tohtml($pluginName), 'PLUGIN_DESCRIPTION' => tr($pluginInfo['desc']), 'PLUGIN_STATUS' => $pluginManager->pluginHasError($pluginName) ? tr('Unexpected error') : translateStatus($pluginStatus), 'PLUGIN_VERSION' => isset($pluginInfo['__nversion__']) ? tohtml($pluginInfo['__nversion__']) : tr('Unknown'), 'PLUGIN_AUTHOR' => tohtml($pluginInfo['author']), 'PLUGIN_MAILTO' => tohtml($pluginInfo['email']), 'PLUGIN_SITE' => tohtml($pluginInfo['url'])));
            if ($pluginManager->pluginHasError($pluginName)) {
                $tpl->assign('PLUGIN_STATUS_DETAILS', tr('An unexpected error occurred: %s', '<br><br>' . $pluginManager->pluginGetError($pluginName)));
                $tpl->parse('PLUGIN_STATUS_DETAILS_BLOCK', 'plugin_status_details_block');
                $tpl->assign(array('PLUGIN_DEACTIVATE_LINK' => '', 'PLUGIN_ACTIVATE_LINK' => '', 'PLUGIN_PROTECTED_LINK' => ''));
            } else {
                $tpl->assign('PLUGIN_STATUS_DETAILS_BLOCK', '');
                if ($pluginManager->pluginIsProtected($pluginName)) {
                    // Protected plugin
                    $tpl->assign(array('PLUGIN_ACTIVATE_LINK' => '', 'PLUGIN_DEACTIVATE_LINK' => '', 'TR_UNPROTECT_TOOLTIP' => tr('To unprotect this plugin, you must edit the %s file', $cacheFile)));
                    $tpl->parse('PLUGIN_PROTECTED_LINK', 'plugin_protected_link');
                } elseif ($pluginManager->pluginIsUninstalled($pluginName)) {
                    // Uninstalled plugin
                    $tpl->assign(array('PLUGIN_DEACTIVATE_LINK' => '', 'ACTIVATE_ACTION' => 'install', 'TR_ACTIVATE_TOOLTIP' => tr('Install this plugin'), 'UNINSTALL_ACTION' => 'delete', 'TR_UNINSTALL_TOOLTIP' => tr('Delete this plugin'), 'PLUGIN_PROTECTED_LINK' => ''));
                    $tpl->parse('PLUGIN_ACTIVATE_LINK', 'plugin_activate_link');
                } elseif ($pluginManager->pluginIsDisabled($pluginName)) {
                    // Disabled plugin
                    $tpl->assign(array('PLUGIN_DEACTIVATE_LINK' => '', 'ACTIVATE_ACTION' => 'enable', 'TR_ACTIVATE_TOOLTIP' => tr('Activate this plugin'), 'UNINSTALL_ACTION' => $pluginManager->pluginIsUninstallable($pluginName) ? 'uninstall' : 'delete', 'TR_UNINSTALL_TOOLTIP' => $pluginManager->pluginIsUninstallable($pluginName) ? tr('Uninstall this plugin') : tr('Delete this plugin'), 'PLUGIN_PROTECTED_LINK' => ''));
                    $tpl->parse('PLUGIN_ACTIVATE_LINK', 'plugin_activate_link');
                } elseif ($pluginManager->pluginIsEnabled($pluginName)) {
                    // Enabled plugin
                    $tpl->assign(array('PLUGIN_ACTIVATE_LINK' => '', 'PLUGIN_PROTECTED_LINK' => ''));
                    $tpl->parse('PLUGIN_DEACTIVATE_LINK', 'plugin_deactivate_link');
                } else {
                    // Plugin with unknown status
                    $tpl->assign(array('PLUGIN_DEACTIVATE_LINK' => '', 'PLUGIN_ACTIVATE_LINK' => '', 'PLUGIN_PROTECTED_LINK' => ''));
                }
            }
            $tpl->parse('PLUGIN_BLOCK', '.plugin_block');
        }
    }
}