From a707a0b461b8feabb0d9ff6ebfb384437dbd5254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20S=CC=8Ckoda?= Date: Wed, 25 Sep 2013 09:39:36 +0200 Subject: [PATCH] MDL-41437 fix non-functional message processor uninstall --- admin/message.php | 30 ++---------------------------- lang/en/message.php | 2 -- lib/adminlib.php | 5 ----- lib/pluginlib.php | 24 ++++++++++++++---------- 4 files changed, 16 insertions(+), 45 deletions(-) diff --git a/admin/message.php b/admin/message.php index 67a60b08b8812..f9fee27c2f623 100644 --- a/admin/message.php +++ b/admin/message.php @@ -35,8 +35,6 @@ // Get the submitted params $disable = optional_param('disable', 0, PARAM_INT); $enable = optional_param('enable', 0, PARAM_INT); -$uninstall = optional_param('uninstall', 0, PARAM_INT); -$confirm = optional_param('confirm', false, PARAM_BOOL); $headingtitle = get_string('managemessageoutputs', 'message'); @@ -56,31 +54,7 @@ plugin_manager::reset_caches(); } -if (!empty($uninstall) && confirm_sesskey()) { - echo $OUTPUT->header(); - echo $OUTPUT->heading($headingtitle); - - if (!$processor = $DB->get_record('message_processors', array('id'=>$uninstall))) { - print_error('outputdoesnotexist', 'message'); - } - - $processorname = get_string('pluginname', 'message_'.$processor->name); - - if (!$confirm) { - echo $OUTPUT->confirm(get_string('processordeleteconfirm', 'message', $processorname), 'message.php?uninstall='.$processor->id.'&confirm=1', 'message.php'); - echo $OUTPUT->footer(); - exit; - - } else { - message_processor_uninstall($processor->name); - $a = new stdClass(); - $a->processor = $processorname; - $a->directory = $CFG->dirroot.'/message/output/'.$processor->name; - notice(get_string('processordeletefiles', 'message', $a), 'message.php'); - } -} - -if ($disable || $enable || $uninstall) { +if ($disable || $enable) { $url = new moodle_url('message.php'); redirect($url); } @@ -98,4 +72,4 @@ echo $OUTPUT->header(); echo $OUTPUT->heading($headingtitle); echo $messageoutputs; -echo $OUTPUT->footer(); \ No newline at end of file +echo $OUTPUT->footer(); diff --git a/lang/en/message.php b/lang/en/message.php index ef38ada1fba03..a8167539248e0 100644 --- a/lang/en/message.php +++ b/lang/en/message.php @@ -107,8 +107,6 @@ $string['page-message-x'] = 'Any message pages'; $string['private_config'] = 'Popup message window'; $string['processortag'] = 'Destination'; -$string['processordeleteconfirm'] = 'You are about to completely delete message output \'{$a}\'. This will completely delete everything in the database associated with this output. Are you SURE you want to continue?'; -$string['processordeletefiles'] = 'All data associated with the output \'{$a->processor}\' has been deleted from the database. To complete the deletion (and prevent the output re-installing itself), you should now delete this directory from your server: {$a->directory}'; $string['providers_config'] = 'Configure notification methods for incoming messages'; $string['providerstag'] = 'Source'; $string['recent'] = 'Recent'; diff --git a/lib/adminlib.php b/lib/adminlib.php index 621083e2548b5..861a9ef6eed8e 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -315,11 +315,6 @@ function uninstall_plugin($type, $name) { // delete message provider message_provider_uninstall($component); - // delete message processor - if ($type === 'message') { - message_processor_uninstall($name); - } - // delete the plugin tables $xmldbfilepath = $plugindirectory . '/db/install.xml'; drop_plugin_tables($component, $xmldbfilepath, false); diff --git a/lib/pluginlib.php b/lib/pluginlib.php index b7c99e502aee2..1ae306bedb630 100644 --- a/lib/pluginlib.php +++ b/lib/pluginlib.php @@ -3710,20 +3710,24 @@ public function load_settings(part_of_admin_tree $adminroot, $parentnodename, $h } public function is_uninstall_allowed() { - $processors = get_message_processors(); - if (isset($processors[$this->name])) { - return true; - } else { - return false; - } + return true; } /** - * @see plugintype_interface::get_uninstall_url() + * Pre-uninstall hook. + * + * This is intended for disabling of plugin, some DB table purging, etc. + * + * NOTE: to be called from uninstall_plugin() only. + * @private */ - public function get_uninstall_url() { - $processors = get_message_processors(); - return new moodle_url('/admin/message.php', array('uninstall' => $processors[$this->name]->id, 'sesskey' => sesskey())); + public function uninstall_cleanup() { + global $CFG; + + require_once($CFG->libdir.'/messagelib.php'); + message_processor_uninstall($this->name); + + parent::uninstall_cleanup(); } }