Skip to content

Commit

Permalink
MDL-41437 fix non-functional message processor uninstall
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Sep 25, 2013
1 parent a31e0b4 commit a707a0b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 45 deletions.
30 changes: 2 additions & 28 deletions admin/message.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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);
}
Expand All @@ -98,4 +72,4 @@
echo $OUTPUT->header();
echo $OUTPUT->heading($headingtitle);
echo $messageoutputs;
echo $OUTPUT->footer();
echo $OUTPUT->footer();
2 changes: 0 additions & 2 deletions lang/en/message.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
5 changes: 0 additions & 5 deletions lib/adminlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
24 changes: 14 additions & 10 deletions lib/pluginlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down

0 comments on commit a707a0b

Please sign in to comment.