MDL-60470 core: New hook 'after_require_login'

This adds a hook towards the end of the require_login function.
This commit is contained in:
Brendan Heywood
2019-04-16 03:39:20 +10:00
parent bef0fe2000
commit bf9f255523
2 changed files with 15 additions and 0 deletions
+14
View File
@@ -2764,6 +2764,8 @@ function require_login($courseorid = null, $autologinguest = true, $cm = null, $
$CFG->forceclean = true;
}
$afterlogins = get_plugins_with_function('after_require_login', 'lib.php');
// Do not bother admins with any formalities, except for activities pending deletion.
if (is_siteadmin() && !($cm && $cm->deletioninprogress)) {
// Set the global $COURSE.
@@ -2778,6 +2780,12 @@ function require_login($courseorid = null, $autologinguest = true, $cm = null, $
if (!WS_SERVER && !AJAX_SCRIPT) {
user_accesstime_log($course->id);
}
foreach ($afterlogins as $plugintype => $plugins) {
foreach ($plugins as $pluginfunction) {
$pluginfunction($courseorid, $autologinguest, $cm, $setwantsurltome, $preventredirect);
}
}
return;
}
@@ -2995,6 +3003,12 @@ function require_login($courseorid = null, $autologinguest = true, $cm = null, $
$PAGE->set_course($course);
}
foreach ($afterlogins as $plugintype => $plugins) {
foreach ($plugins as $pluginfunction) {
$pluginfunction($courseorid, $autologinguest, $cm, $setwantsurltome, $preventredirect);
}
}
// Finally access granted, update lastaccess times.
// Do not update access time for webservice or ajax requests.
if (!WS_SERVER && !AJAX_SCRIPT) {