123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?php
- defined('STATUSNET') || die();
- class PlugindisableAction extends PluginenableAction
- {
-
- function handle()
- {
- if (PluginList::isPluginLoaded($this->plugin)) {
- $config_file = INSTALLDIR . DIRECTORY_SEPARATOR . 'config.php';
- $config_lines = file($config_file, FILE_IGNORE_NEW_LINES);
- foreach($config_lines as $key => $line) {
-
- $line = str_replace('addPlugin(\''.$this->plugin.'\');', '', $line);
- $config_lines[$key] = $line;
- if($line === ' // Added by sysadmin\'s Plugin UI.') {
- unset($config_lines[$key]);
- }
- }
- $new_config_data = implode(PHP_EOL, $config_lines);
- if (!file_put_contents($config_file, $new_config_data)) {
- $this->clientError(_m('No permissions for writing to config.php'));
- }
- }
- $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 1;
- }
- protected function successShortTitle()
- {
-
- return _m('plugin', 'Disabled');
- }
- protected function successNextForm()
- {
- return new PluginEnableForm($this, $this->plugin);
- }
- }
|