123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <?php
- defined('STATUSNET') || die();
- require_once INSTALLDIR . '/lib/util/deletetree.php';
- class PlugindeleteAction extends Action
- {
- var $user;
- var $plugin;
-
- function prepare(array $args = [])
- {
- parent::prepare($args);
-
-
- if ($_SERVER['REQUEST_METHOD'] != 'POST') {
-
-
- $this->clientError(_m('This action only accepts POST requests.'));
- }
-
- $token = $this->trimmed('token');
- if (!$token || $token != common_session_token()) {
-
- $this->clientError(_m('There was a problem with your session token.'.
- ' Try again, please.'));
- }
-
- $this->user = common_current_user();
- if (empty($this->user)) {
-
- $this->clientError(_m('Not logged in.'));
- }
- if (!AdminPanelAction::canAdmin('plugins')) {
-
- $this->clientError(_m('You cannot administer plugins.'));
- }
- $this->plugin = $this->arg('plugin');
- if (!array_key_exists($this->plugin, array_flip(PluginList::grabAllPluginNames()))) {
-
- $this->clientError(_m('No such plugin.'));
- }
- return true;
- }
-
- function handle()
- {
- if (PluginList::isPluginLoaded($this->plugin)) {
- $this->clientError(_m('You can\'t delete a plugin without first removing its loader from your config.php.'));
- }
- if (!is_writable(INSTALLDIR . '/local/plugins/'.$this->plugin)) {
- $this->clientError(_m('We can only delete third party plugins.'));
- }
- deleteTree(INSTALLDIR . '/local/plugins/'.$this->plugin);
- deleteTree(PUBLICDIR . '/local/plugins/'.$this->plugin);
- $url = common_local_url('pluginsadminpanel');
- common_redirect($url, 303);
- }
- }
|