]> git.mjollnir.org Git - moodle.git/commitdiff
accesslib: Move check_enrolment_plugins() to complete_user_login()
authormartinlanghoff <martinlanghoff>
Wed, 14 Nov 2007 22:04:05 +0000 (22:04 +0000)
committermartinlanghoff <martinlanghoff>
Wed, 14 Nov 2007 22:04:05 +0000 (22:04 +0000)
... where it belongs ;-)

load_all_capabiloties() gets called at several points where we don't
want to be re-querying the enrolment backends. It needs to  be called
before load_all_capabilities() and only by callers that are setting up
a logon session.

Those callers need to be calling complete_user_login() anyway, as they
need to set the Moodle cookie, log the logon action, etc. In fact,
those callers duplicate a lot of that code already.

The callers that don't duplicate code for the login are actually the
cases where the backend enrolment plugins should not be queried.

To be followed by callers cleanup...

lib/accesslib.php
lib/moodlelib.php

index 16c712c4694622d589374504688e3a06ec94b651..b819cdb1c584dab22e77bb5c9f3e7f781bbc4bc3 100755 (executable)
@@ -1570,7 +1570,10 @@ function compact_rdefs(&$rdefs) {
 
 /**
  *  A convenience function to completely load all the capabilities 
- *  for the current user.   This is what gets called from login, for example.
+ *  for the current user.   This is what gets called from complete_user_login()
+ *  for example. Call it only _after_ you've setup $USER and called
+ *  check_enrolment_plugins();
+ *
  */
 function load_all_capabilities() {
     global $USER, $CFG, $DIRTYCONTEXTS;
@@ -1588,8 +1591,6 @@ function load_all_capabilities() {
 
     } else if (isloggedin()) {
 
-        check_enrolment_plugins($USER);
-
         $accessdata = get_user_access_sitewide($USER->id);
 
         //
index a218bac7d586c4f26c9f7c3c85d1f76a15ae6973..2d00b35cf93146b914f734e97cde079ec36774a2 100644 (file)
@@ -3039,6 +3039,9 @@ function complete_user_login($user) {
     }
     set_login_session_preferences();
 
+    // Call enrolment plugins
+    check_enrolment_plugins($user);
+
     /// This is what lets the user do anything on the site :-)
     load_all_capabilities();