MDL-41437 fix and cleanup filter uninstall

This commit is contained in:
Petr Škoda
2013-09-25 08:41:33 +02:00
parent e50df55c91
commit a31e0b40c9
4 changed files with 40 additions and 38 deletions
+28 -2
View File
@@ -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();
}
}