From bf9f255523e5f8feb7cb39067475389ba260ff4e Mon Sep 17 00:00:00 2001 From: Brendan Heywood Date: Wed, 18 Oct 2017 16:20:33 +1100 Subject: [PATCH] MDL-60470 core: New hook 'after_require_login' This adds a hook towards the end of the require_login function. --- lib/moodlelib.php | 14 ++++++++++++++ lib/upgrade.txt | 1 + 2 files changed, 15 insertions(+) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 1cc6caa2b37..f3b227f6b4c 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -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) { diff --git a/lib/upgrade.txt b/lib/upgrade.txt index f1bbeceee21..d0baed6779b 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -30,6 +30,7 @@ attribute on forms to avoid collisions in forms loaded in AJAX requests. in this category. To work with list of courses use API methods in core_course_category and also 'course' form element. * It is possible to pass additional conditions to get_courses_search(); core_course_category::search_courses() now allows to search only among courses with completion enabled. +* Add support for a new xxx_after_require_login callback === 3.6 ===