MDL-77248 core: Move pre_enable_plugin_actions callback to enable_plugin
Note: The original callback was incorrectly using the $PAGE output, which cannot be relied upon in this callback. The best we can do here is to add a notification to explain the situation.
This commit is contained in:
@@ -51,6 +51,14 @@ class mod extends base {
|
||||
|
||||
// Only set visibility if it's different from the current value.
|
||||
if ($module->visible != $enabled) {
|
||||
if ($enabled && component_callback_exists("mod_{$pluginname}", 'pre_enable_plugin_actions')) {
|
||||
// Invoking a callback function that enables plugins to force additional actions (e.g. displaying notifications,
|
||||
// modals, etc.) and also specify through its returned value (bool) whether the process of enabling the plugin
|
||||
// should continue after these actions or not.
|
||||
if (!component_callback("mod_{$pluginname}", 'pre_enable_plugin_actions')) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Set module visibility.
|
||||
$DB->set_field('modules', 'visible', $enabled, ['id' => $module->id]);
|
||||
$haschanged = true;
|
||||
|
||||
Reference in New Issue
Block a user