Commit 4a55d6eb authored by Mihail Geshoski's avatar Mihail Geshoski
Browse files

MDL-74584 admin: Add callback executed prior to enabling a module

Adds a callback xxx_pre_enable_plugin_actions in admin/modules.php
which plugins can use to force additional actions before enabling the
plugin. The return value (bool) from the plugin callback method
specifies whether the process of enabling the plugin should continue
after the added actions or not.
parent 1a744030
......@@ -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;
// 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');
}
admin_get_root(true, false); // settings not required - only pages
redirect(new moodle_url('/admin/modules.php'));
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();
......
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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment