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.
/// 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));
}
$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';
*/
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);
$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
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 '/'
*
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();
}
}