mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 04:52:36 +02:00
MDL-41437 fix and cleanup filter uninstall
This commit is contained in:
parent
e50df55c91
commit
a31e0b40c9
@ -95,38 +95,6 @@
|
||||
filter_set_global_state($filterpath, $filters[$filterpath]->active, -1);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
// If not yet confirmed, display a confirmation message.
|
||||
if (!optional_param('confirm', '', PARAM_BOOL)) {
|
||||
$filtername = filter_get_name($filterpath);
|
||||
|
||||
$title = get_string('deletefilterareyousure', 'admin', $filtername);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($title);
|
||||
|
||||
$linkcontinue = new moodle_url($returnurl, array('action' => 'delete', 'filterpath' => $filterpath, 'confirm' => 1));
|
||||
$formcancel = new single_button(new moodle_url($returnurl), get_string('no'), 'get');
|
||||
echo $OUTPUT->confirm(get_string('deletefilterareyousuremessage', 'admin', $filtername), $linkcontinue, $formcancel);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
// Do the deletion.
|
||||
$title = get_string('deletingfilter', 'admin', $filterpath);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($title);
|
||||
|
||||
// Delete all data for this plugin.
|
||||
filter_delete_all_for_filter($filterpath);
|
||||
|
||||
$a = new stdClass;
|
||||
$a->filter = $filterpath;
|
||||
$a->directory = "$CFG->dirroot/filter/$filterpath";
|
||||
echo $OUTPUT->box(get_string('deletefilterfiles', 'admin', $a), 'generalbox', 'notice');
|
||||
echo $OUTPUT->continue_button($returnurl);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
// Add any missing filters to the DB table.
|
||||
@ -211,6 +179,9 @@
|
||||
/// Display helper functions ===================================================
|
||||
|
||||
function filters_action_url($filterpath, $action) {
|
||||
if ($action === 'delete') {
|
||||
return new moodle_url('/admin/plugins.php', array('sesskey'=>sesskey(), 'uninstall'=>'filter_'.$filterpath));
|
||||
}
|
||||
return new moodle_url('/admin/filters.php', array('sesskey'=>sesskey(), 'filterpath'=>$filterpath, 'action'=>$action));
|
||||
}
|
||||
|
||||
|
@ -424,13 +424,9 @@ $string['defaulthomepage'] = 'Default home page for users';
|
||||
$string['defaultrequestcategory'] = 'Default category for course requests';
|
||||
$string['defaultsettinginfo'] = 'Default: {$a}';
|
||||
$string['defaultuserroleid'] = 'Default role for all users';
|
||||
$string['deletefilterareyousure'] = 'Are you sure you want to delete the filter \'{$a}\'';
|
||||
$string['deletefilterareyousuremessage'] = 'You are about to completely delete the filter \'{$a}\'. Are you sure you want to uninstall it?';
|
||||
$string['deletefilterfiles'] = 'All data associated with the filter \'{$a->filter}\' has been deleted from the database. To complete the deletion (and to prevent the filter from re-installing itself), you should now delete this directory from your server: {$a->directory}';
|
||||
$string['deleteincompleteusers'] = 'Delete incomplete users after';
|
||||
$string['deleteunconfirmed'] = 'Delete not fully setup users after';
|
||||
$string['deleteuser'] = 'Delete user';
|
||||
$string['deletingfilter'] = 'Deleting filter \'{$a}\'';
|
||||
$string['density'] = 'Density';
|
||||
$string['denyemailaddresses'] = 'Denied email domains';
|
||||
$string['development'] = 'Development';
|
||||
|
@ -124,6 +124,7 @@ define('INSECURE_DATAROOT_ERROR', 2);
|
||||
*/
|
||||
function uninstall_plugin($type, $name) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
require_once($CFG->libdir.'/pluginlib.php');
|
||||
|
||||
// This may take a long time.
|
||||
@set_time_limit(0);
|
||||
@ -282,6 +283,14 @@ function uninstall_plugin($type, $name) {
|
||||
$DB->delete_records('course_format_options', array('format' => $name));
|
||||
}
|
||||
|
||||
// Specific plugin type cleanup.
|
||||
$plugininfo = plugin_manager::instance()->get_plugin_info($component);
|
||||
if ($plugininfo) {
|
||||
$plugininfo->uninstall_cleanup();
|
||||
plugin_manager::reset_caches();
|
||||
}
|
||||
$plugininfo = null;
|
||||
|
||||
// perform clean-up task common for all the plugin/subplugin types
|
||||
|
||||
//delete the web service functions and pre-built services
|
||||
|
@ -3100,6 +3100,19 @@ abstract class plugininfo_base {
|
||||
return $this->get_default_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 uninstall_cleanup() {
|
||||
// Override when extending class,
|
||||
// do not forget to call parent::pre_uninstall_cleanup() at the end.
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns relative directory of the plugin with heading '/'
|
||||
*
|
||||
@ -3317,8 +3330,21 @@ class plugininfo_filter extends plugininfo_base {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function get_uninstall_url() {
|
||||
return new moodle_url('/admin/filters.php', array('sesskey' => sesskey(), 'filterpath' => $this->name, 'action' => 'delete'));
|
||||
/**
|
||||
* 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 uninstall_cleanup() {
|
||||
global $DB;
|
||||
|
||||
$DB->delete_records('filter_active', array('filter' => $this->name));
|
||||
$DB->delete_records('filter_config', array('filter' => $this->name));
|
||||
|
||||
parent::uninstall_cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user