]> git.mjollnir.org Git - moodle.git/commitdiff
get_role_users() can now get all the people who have any role in that context,
authormoodler <moodler>
Sun, 1 Oct 2006 08:34:36 +0000 (08:34 +0000)
committermoodler <moodler>
Sun, 1 Oct 2006 08:34:36 +0000 (08:34 +0000)
which is useful

lib/accesslib.php

index 29bec9549d7cc13ce9911548a44a110fe990ab2a..8a55d7766ee605b5ba89b9d2513ec4bf79fe122b 100755 (executable)
@@ -2795,12 +2795,17 @@ function get_role_users($roleid, $context, $parent=false, $fields='u.*', $sort='
         $parentcontexts = '';
     }
 
+    if ($roleid) {
+        $roleselect = "AND r.roleid = $roleid";
+    } else {
+        $roleselect = '';
+    }
+
     $SQL = "SELECT $fields
             FROM {$CFG->prefix}role_assignments r,
                  {$CFG->prefix}user u
             WHERE (r.contextid = $context->id $parentcontexts)
-            AND r.roleid = $roleid
-            AND u.id = r.userid
+            AND u.id = r.userid $roleselect
             ORDER BY $sort
             ";                  // join now so that we can just use fullname() later