Merge branch 'w36_MDL-29306_m22_dbenrolroles' of git://github.com/skodak/moodle
authorSam Hemelryk <sam@moodle.com>
Mon, 12 Sep 2011 03:30:15 +0000 (15:30 +1200)
committerSam Hemelryk <sam@moodle.com>
Mon, 12 Sep 2011 03:30:15 +0000 (15:30 +1200)
enrol/database/lib.php

index 814e723..f7606b6 100644 (file)
@@ -464,6 +464,17 @@ class enrol_database_plugin extends enrol_plugin {
                     }
                 }
 
+                // assign extra roles
+                foreach ($userroles as $roleid) {
+                    if (empty($current_roles[$userid][$roleid])) {
+                        role_assign($roleid, $userid, $context->id, 'enrol_database', $instance->id);
+                        $current_roles[$userid][$roleid] = $roleid;
+                        if ($verbose) {
+                            mtrace("  assigning roles: $userid ==> $course->shortname as ".$allroles[$roleid]->shortname);
+                        }
+                    }
+                }
+
                 // unassign removed roles
                 foreach($current_roles[$userid] as $cr) {
                     if (empty($userroles[$cr])) {