diff --git a/admin/modules.php b/admin/modules.php index 1ec117e82e5..3a17cf5b780 100644 --- a/admin/modules.php +++ b/admin/modules.php @@ -38,11 +38,22 @@ } if (!empty($show) and confirm_sesskey()) { - $class = \core_plugin_manager::resolve_plugininfo_class('mod'); - $class::enable_plugin($show, true); + $canenablemodule = true; + $modulename = $show; - admin_get_root(true, false); // settings not required - only pages - redirect(new moodle_url('/admin/modules.php')); + // 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_exists("mod_{$modulename}", 'pre_enable_plugin_actions')) { + $canenablemodule = component_callback("mod_{$modulename}", 'pre_enable_plugin_actions'); + } + + if ($canenablemodule) { + $class = \core_plugin_manager::resolve_plugininfo_class('mod'); + $class::enable_plugin($show, true); + admin_get_root(true, false); // Settings not required - only pages. + redirect(new moodle_url('/admin/modules.php')); + } } echo $OUTPUT->header(); diff --git a/admin/upgrade.txt b/admin/upgrade.txt index 6beeb3a0f42..df789ff29b9 100644 --- a/admin/upgrade.txt +++ b/admin/upgrade.txt @@ -1,5 +1,12 @@ This files describes API changes in /admin/*. +=== 4.0.1 === + +* A new callback xxx_pre_enable_plugin_actions has been added in admin/modules.php. Plugins can use this callback to + force additional actions (e.g. displaying notifications, modals, etc.) before enabling the plugin. The expected + return value (bool) from the plugin callback method specifies whether the process of enabling the plugin should + continue after the added actions or not. + === 3.11 === * New admin setting admin_setting_encryptedpassword allows passwords in admin settings to be