mirror of
https://github.com/moodle/moodle.git
synced 2025-04-25 10:26:17 +02:00
MDL-48012 core: added pre_*_delete hooks
This commit is contained in:
parent
e8952c5951
commit
ea88fd4e66
@ -1652,6 +1652,15 @@ function course_delete_module($cmid) {
|
||||
"Cannot delete this module as the function {$modulename}_delete_instance is missing in mod/$modulename/lib.php.");
|
||||
}
|
||||
|
||||
// Allow plugins to use this course module before we completely delete it.
|
||||
if ($pluginsfunction = get_plugins_with_function('pre_course_module_delete')) {
|
||||
foreach ($pluginsfunction as $plugintype => $plugins) {
|
||||
foreach ($plugins as $pluginfunction) {
|
||||
$pluginfunction($cm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Delete activity context questions and question categories.
|
||||
question_delete_activity($cm);
|
||||
|
||||
|
@ -2041,6 +2041,15 @@ function blocks_name_allowed_in_format($name, $pageformat) {
|
||||
function blocks_delete_instance($instance, $nolongerused = false, $skipblockstables = false) {
|
||||
global $DB;
|
||||
|
||||
// Allow plugins to use this block before we completely delete it.
|
||||
if ($pluginsfunction = get_plugins_with_function('pre_block_delete')) {
|
||||
foreach ($pluginsfunction as $plugintype => $plugins) {
|
||||
foreach ($plugins as $pluginfunction) {
|
||||
$pluginfunction($instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($block = block_instance($instance->blockname, $instance)) {
|
||||
$block->instance_delete();
|
||||
}
|
||||
|
@ -1670,6 +1670,16 @@ class coursecat implements renderable, cacheable_object, IteratorAggregate {
|
||||
// Make sure we won't timeout when deleting a lot of courses.
|
||||
$settimeout = core_php_time_limit::raise();
|
||||
|
||||
// Allow plugins to use this category before we completely delete it.
|
||||
if ($pluginsfunction = get_plugins_with_function('pre_course_category_delete')) {
|
||||
$category = $this->get_db_record();
|
||||
foreach ($pluginsfunction as $plugintype => $plugins) {
|
||||
foreach ($plugins as $pluginfunction) {
|
||||
$pluginfunction($category);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$deletedcourses = array();
|
||||
|
||||
// Get children. Note, we don't want to use cache here because it would be rebuilt too often.
|
||||
|
@ -3928,6 +3928,15 @@ function delete_user(stdClass $user) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Allow plugins to use this user object before we completely delete it.
|
||||
if ($pluginsfunction = get_plugins_with_function('pre_user_delete')) {
|
||||
foreach ($pluginsfunction as $plugintype => $plugins) {
|
||||
foreach ($plugins as $pluginfunction) {
|
||||
$pluginfunction($user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Keep user record before updating it, as we have to pass this to user_deleted event.
|
||||
$olduser = clone $user;
|
||||
|
||||
@ -4677,6 +4686,15 @@ function delete_course($courseorid, $showfeedback = true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Allow plugins to use this course before we completely delete it.
|
||||
if ($pluginsfunction = get_plugins_with_function('pre_course_delete')) {
|
||||
foreach ($pluginsfunction as $plugintype => $plugins) {
|
||||
foreach ($plugins as $pluginfunction) {
|
||||
$pluginfunction($course);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Make the course completely empty.
|
||||
remove_course_contents($courseid, $showfeedback);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user