MDL-41437 fix non-functional message processor uninstall

This commit is contained in:
Petr Škoda 2013-09-25 09:39:36 +02:00
parent a31e0b40c9
commit a707a0b461
4 changed files with 16 additions and 45 deletions

View File

@ -35,8 +35,6 @@ require_capability('moodle/site:config', context_system::instance());
// 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 @@ if (!empty($enable) && confirm_sesskey()) {
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 @@ $messageoutputs = $renderer->manage_messageoutputs($processors);
echo $OUTPUT->header();
echo $OUTPUT->heading($headingtitle);
echo $messageoutputs;
echo $OUTPUT->footer();
echo $OUTPUT->footer();

View File

@ -107,8 +107,6 @@ $string['permitted'] = 'Permitted';
$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';

View File

@ -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);

View File

@ -3710,20 +3710,24 @@ class plugininfo_message extends plugininfo_base {
}
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();
}
}