]> git.mjollnir.org Git - moodle.git/commitdiff
Function to get roles used in a context
authormoodler <moodler>
Mon, 14 Aug 2006 08:14:02 +0000 (08:14 +0000)
committermoodler <moodler>
Mon, 14 Aug 2006 08:14:02 +0000 (08:14 +0000)
lib/accesslib.php

index 8fc7c59f6e8ffe8d58af2c0c72f369c469d29ed0..16e246eb9a9cc14397da96dc5b461bc65339f590 100755 (executable)
@@ -1577,4 +1577,17 @@ function get_component_string($component, $contextlevel) {
 }
 
 
-?>
\ No newline at end of file
+function get_roles_used_in_context($context) {
+
+    global $CFG;
+
+    return get_records_sql('SELECT distinct r.id, r.name 
+                              FROM '.$CFG->prefix.'role_assignments ra,
+                                   '.$CFG->prefix.'role r 
+                             WHERE r.id = ra.roleid 
+                               AND ra.contextid = '.$context->id.' 
+                             ORDER BY r.sortorder ASC');
+}
+
+
+?>