]> git.mjollnir.org Git - moodle.git/commitdiff
function should be looking up parent contexts too
authortoyomoyo <toyomoyo>
Tue, 19 Sep 2006 02:47:55 +0000 (02:47 +0000)
committertoyomoyo <toyomoyo>
Tue, 19 Sep 2006 02:47:55 +0000 (02:47 +0000)
lib/accesslib.php

index 09148ff1461a33b229650d5a09673e182484615b..fc5c9e921ed45139f185788bf39a248e1b0ccb01 100755 (executable)
@@ -2214,19 +2214,21 @@ function get_component_string($component, $contextlevel) {
 }
 
 /** gets the list of roles assigned to this context
+ * and up (parents)
  * @param object $context
  * @return array
  */
 function get_roles_used_in_context($context) {
 
     global $CFG;
-
-    return get_records_sql('SELECT distinct r.id, r.name, r.shortname
-                              FROM '.$CFG->prefix.'role_assignments ra,
-                                   '.$CFG->prefix.'role r 
+    
+    $contextlist = get_related_contexts_string($context);
+    return get_records_sql("SELECT distinct r.id, r.name, r.shortname
+                              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');
+                               AND ra.contextid $contextlist
+                             ORDER BY r.sortorder ASC");
 }
 
 /** this function is used to print roles column in user profile page.