From b9fc4c24b44ba8a83448f3ea8e0698c689d74d19 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 17 Mar 2010 08:55:16 -0700 Subject: Pulling the stub plugin panel back out; we'll flesh it out more for 1.0.x and see if we can make it easier to disable through the config file for now. Revert "Stub plugins administration panel, allows for disabling/re-enabling plugins from the default plugins list." This reverts commit d9a9fd3779c592e3f4e0a8aea8e385ee2183c0b3. --- actions/plugindisable.php | 78 -------------------- actions/pluginenable.php | 166 ------------------------------------------ actions/pluginsadminpanel.php | 110 ---------------------------- 3 files changed, 354 deletions(-) delete mode 100644 actions/plugindisable.php delete mode 100644 actions/pluginenable.php delete mode 100644 actions/pluginsadminpanel.php (limited to 'actions') diff --git a/actions/plugindisable.php b/actions/plugindisable.php deleted file mode 100644 index 7f107b333..000000000 --- a/actions/plugindisable.php +++ /dev/null @@ -1,78 +0,0 @@ -. - * - * PHP version 5 - * - * @category Action - * @package StatusNet - * @author Brion Vibber - * @copyright 2010 StatusNet, Inc. - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3 - * @link http://status.net/ - */ - -if (!defined('STATUSNET')) { - exit(1); -} - -/** - * Plugin enable action. - * - * (Re)-enables a plugin from the default plugins list. - * - * Takes parameters: - * - * - plugin: plugin name - * - token: session token to prevent CSRF attacks - * - ajax: boolean; whether to return Ajax or full-browser results - * - * Only works if the current user is logged in. - * - * @category Action - * @package StatusNet - * @author Brion Vibber - * @copyright 2010 StatusNet, Inc. - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3 - * @link http://status.net/ - */ - -class PluginDisableAction extends PluginEnableAction -{ - /** - * Value to save into $config['plugins']['disable-'] - */ - protected function overrideValue() - { - return 1; - } - - protected function successShortTitle() - { - // TRANS: Page title for AJAX form return when a disabling a plugin. - return _m('plugin', 'Disabled'); - } - - protected function successNextForm() - { - return new EnablePluginForm($this, $this->plugin); - } -} - - diff --git a/actions/pluginenable.php b/actions/pluginenable.php deleted file mode 100644 index 2dbb3e395..000000000 --- a/actions/pluginenable.php +++ /dev/null @@ -1,166 +0,0 @@ -. - * - * PHP version 5 - * - * @category Action - * @package StatusNet - * @author Brion Vibber - * @copyright 2010 StatusNet, Inc. - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3 - * @link http://status.net/ - */ - -if (!defined('STATUSNET')) { - exit(1); -} - -/** - * Plugin enable action. - * - * (Re)-enables a plugin from the default plugins list. - * - * Takes parameters: - * - * - plugin: plugin name - * - token: session token to prevent CSRF attacks - * - ajax: boolean; whether to return Ajax or full-browser results - * - * Only works if the current user is logged in. - * - * @category Action - * @package StatusNet - * @author Brion Vibber - * @copyright 2010 StatusNet, Inc. - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3 - * @link http://status.net/ - */ - -class PluginEnableAction extends Action -{ - var $user; - var $plugin; - - /** - * Check pre-requisites and instantiate attributes - * - * @param Array $args array of arguments (URL, GET, POST) - * - * @return boolean success flag - */ - - function prepare($args) - { - parent::prepare($args); - - // @fixme these are pretty common, should a parent class factor these out? - - // Only allow POST requests - - if ($_SERVER['REQUEST_METHOD'] != 'POST') { - $this->clientError(_('This action only accepts POST requests.')); - return false; - } - - // CSRF protection - - $token = $this->trimmed('token'); - - if (!$token || $token != common_session_token()) { - $this->clientError(_('There was a problem with your session token.'. - ' Try again, please.')); - return false; - } - - // Only for logged-in users - - $this->user = common_current_user(); - - if (empty($this->user)) { - $this->clientError(_('Not logged in.')); - return false; - } - - if (!AdminPanelAction::canAdmin('plugins')) { - $this->clientError(_('You cannot administer plugins.')); - return false; - } - - $this->plugin = $this->arg('plugin'); - $defaultPlugins = common_config('plugins', 'default'); - if (!array_key_exists($this->plugin, $defaultPlugins)) { - $this->clientError(_('No such plugin.')); - return false; - } - - return true; - } - - /** - * Handle request - * - * Does the subscription and returns results. - * - * @param Array $args unused. - * - * @return void - */ - - function handle($args) - { - $key = 'disable-' . $this->plugin; - Config::save('plugins', $key, $this->overrideValue()); - - // @fixme this is a pretty common pattern and should be refactored down - if ($this->boolean('ajax')) { - $this->startHTML('text/xml;charset=utf-8'); - $this->elementStart('head'); - $this->element('title', null, $this->successShortTitle()); - $this->elementEnd('head'); - $this->elementStart('body'); - $form = $this->successNextForm(); - $form->show(); - $this->elementEnd('body'); - $this->elementEnd('html'); - } else { - $url = common_local_url('pluginsadminpanel'); - common_redirect($url, 303); - } - } - - /** - * Value to save into $config['plugins']['disable-'] - */ - protected function overrideValue() - { - return 0; - } - - protected function successShortTitle() - { - // TRANS: Page title for AJAX form return when enabling a plugin. - return _m('plugin', 'Enabled'); - } - - protected function successNextForm() - { - return new DisablePluginForm($this, $this->plugin); - } -} diff --git a/actions/pluginsadminpanel.php b/actions/pluginsadminpanel.php deleted file mode 100644 index bc400bd51..000000000 --- a/actions/pluginsadminpanel.php +++ /dev/null @@ -1,110 +0,0 @@ -. - * - * @category Settings - * @package StatusNet - * @author Brion Vibber - * @copyright 2010 StatusNet, Inc. - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://status.net/ - */ - -if (!defined('STATUSNET')) { - exit(1); -} - -/** - * Plugins settings - * - * @category Admin - * @package StatusNet - * @author Brion Vibber - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://status.net/ - */ - -class PluginsadminpanelAction extends AdminPanelAction -{ - - /** - * Returns the page title - * - * @return string page title - */ - - function title() - { - // TRANS: Tab and title for plugins admin panel. - return _('Plugins'); - } - - /** - * Instructions for using this form. - * - * @return string instructions - */ - - function getInstructions() - { - // TRANS: Instructions at top of plugin admin page. - return _('Additional plugins can be enabled and configured manually. ' . - 'See the online plugin ' . - 'documentation for more details.'); - } - - /** - * Show the plugins admin panel form - * - * @return void - */ - - function showForm() - { - $this->elementStart('fieldset', array('id' => 'settings_plugins_default')); - - // TRANS: Admin form section header - $this->element('legend', null, _('Default plugins'), 'default'); - - $this->showDefaultPlugins(); - - $this->elementEnd('fieldset'); - } - - /** - * Until we have a general plugin metadata infrastructure, for now - * we'll just list up the ones we know from the global default - * plugins list. - */ - protected function showDefaultPlugins() - { - $plugins = array_keys(common_config('plugins', 'default')); - natsort($plugins); - - if ($plugins) { - $list = new PluginList($plugins, $this); - $list->show(); - } else { - $this->element('p', null, - _('All default plugins have been disabled from the ' . - 'site\'s configuration file.')); - } - } -} -- cgit v1.2.3-54-g00ecf