]> git.mjollnir.org Git - moodle.git/commitdiff
merged fix for MDL-6928, LDAP course creation error
authortoyomoyo <toyomoyo>
Wed, 1 Nov 2006 03:51:04 +0000 (03:51 +0000)
committertoyomoyo <toyomoyo>
Wed, 1 Nov 2006 03:51:04 +0000 (03:51 +0000)
lib/moodlelib.php

index be0e264ddbc15bdc0552f9037a644dd9a43ab0d5..f62226d2333d87c9be21395c947b75528f0db90c 100644 (file)
@@ -2382,6 +2382,7 @@ function authenticate_user_login($username, $password) {
             $user = create_user_record($username, $password, $auth);
         }
 
+/*
         if (function_exists('auth_iscreator')) {    // Check if the user is a creator
             $useriscreator = auth_iscreator($username);
             if (!is_null($useriscreator)) {
@@ -2401,6 +2402,23 @@ function authenticate_user_login($username, $password) {
                 }
             }
         }
+*/
+        // fix for MDL-6928
+        
+        if (function_exists('auth_iscreator')) {                    
+            $sitecontext = get_context_instance(CONTEXT_SYSTEM);
+            if ($creatorroles = get_roles_with_capability('moodle/legacy:coursecreator', CAP_ALLOW)) {
+                $creatorrole = array_shift($creatorroles); // We can only use one, let's use the first one
+                // Check if the user is a creator
+                if (auth_iscreator($username)) { // Following calls will not create duplicates
+                    if ($useriscreator) {
+                       role_assign($creatorrole->id, $user->id, 0, $sitecontext->id, 0, 0, 0, 'ldap');
+                    } else {
+                       role_unassign($creatorrole->id, $user->id, 0, $sitecontext->id);
+                    }
+                }
+            }
+        }
 
     /// Log in to a second system if necessary
         if (!empty($CFG->sso)) {