function toggleactivateplugin() { global $configFile; if (!isset($_REQUEST["plugin"]) || !isset($_REQUEST["value"])) { setError('Internal Error in togleactivateplugin'); } $strPluginName = urljsdecode($_REQUEST["plugin"]); $strValue = urljsdecode($_REQUEST["value"]); $oPluginDir = new PPluginDir(PLUGINS_DIR . SLASH . $strPluginName); if (!$oPluginDir->isDir()) { return setError(sprintf(_('Can not find the plugin %s'), $strPluginName)); } if (!$oPluginDir->toggleActivate(true)) { return false; } if ($strValue == "true") { echo sprintf(_('Plugin %s is activated'), $oPluginDir->getPluginName()); } else { echo sprintf(_('Plugin %s is unactivated'), $oPluginDir->getPluginName(), true); } return true; }
{LIST} </table> '; $strListActivated = ''; $strListAvailable = ''; if (is_dir(PLUGINS_DIR)) { $oPdir = getFileObject(PLUGINS_DIR); //parse each plugin directory $listDir = $oPdir->listDir($oPdir->ONLY_DIR); foreach ($listDir as $strPluginPath) { $oDirPlugin = new PPluginDir($strPluginPath); $bActivated = false; $configFile->getParam($oDirPlugin->getIdName(), $bActivated, 'PLUGINS'); $strAction = $bActivated === "true" ? _('UnActivate') : _('Activate'); $strLine = '<tr> <td>' . $oDirPlugin->getPluginName() . '</td> <td>' . $oDirPlugin->getAuthor() . '</td> <td>' . $oDirPlugin->getVersion() . '</td> <td><a href="#" onClick="return toggleactivatePlugin(\'' . urljsencode($oDirPlugin->getName()) . '\',\'false\');">[ ' . $strAction . ' ]</a></td> </tr>'; if ($bActivated === "true") { $strListActivated .= $strLine; } else { $strListAvailable .= $strLine; } } } $strContent = '<div id="listPlugins"> ' . str_replace('{LIST}', $strListActivated, $strTableActivated) . ' ' . str_replace('{LIST}', $strListAvailable, $strTableAvailable) . ' </div>';