123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- class PluginEnableAction extends Action
- {
- var $user;
- var $plugin;
-
- function prepare($args)
- {
- parent::prepare($args);
-
-
- if ($_SERVER['REQUEST_METHOD'] != 'POST') {
-
-
- $this->clientError(_('This action only accepts POST requests.'));
- }
-
- $token = $this->trimmed('token');
- if (!$token || $token != common_session_token()) {
-
- $this->clientError(_('There was a problem with your session token.'.
- ' Try again, please.'));
- }
-
- $this->user = common_current_user();
- if (empty($this->user)) {
-
- $this->clientError(_('Not logged in.'));
- }
- if (!AdminPanelAction::canAdmin('plugins')) {
-
- $this->clientError(_('You cannot administer plugins.'));
- }
- $this->plugin = $this->arg('plugin');
- $defaultPlugins = common_config('plugins', 'default');
- if (!array_key_exists($this->plugin, $defaultPlugins)) {
-
- $this->clientError(_('No such plugin.'));
- }
- return true;
- }
-
- function handle($args)
- {
- $key = 'disable-' . $this->plugin;
- Config::save('plugins', $key, $this->overrideValue());
-
- 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->endHTML();
- } else {
- $url = common_local_url('pluginsadminpanel');
- common_redirect($url, 303);
- }
- }
-
- protected function overrideValue()
- {
- return 0;
- }
- protected function successShortTitle()
- {
-
- return _m('plugin', 'Enabled');
- }
- protected function successNextForm()
- {
- return new DisablePluginForm($this, $this->plugin);
- }
- }
|