]> git.mjollnir.org Git - moodle.git/commitdiff
lib/deprecatedlib: enrol/manual: Fix calls to get_users_by_capability() to avoid ra
authormartinlanghoff <martinlanghoff>
Sun, 6 Jan 2008 23:25:26 +0000 (23:25 +0000)
committermartinlanghoff <martinlanghoff>
Sun, 6 Jan 2008 23:25:26 +0000 (23:25 +0000)
get_users_by_capability() can no longer refer to properties of role
assignments or roles, as the capability aggregate is indirect.

Fixes:
 get_teacher() - though the results will be poor, as we cannot provide
                 role.sortorder reliably
 (used mainly by mod/workshop)
 get_course_teachers() - which seems broken for a lot of situations as
                 its default parameters still refer to old tables.

MDL-12452

lib/deprecatedlib.php

index 6b1652f73664e71ec993e9f0e7d237e0884ae427..75cd1e50e66527298388f0a7695e1284c2a5f98b 100644 (file)
@@ -515,13 +515,10 @@ function get_teacher($courseid) {
 
     $context = get_context_instance(CONTEXT_COURSE, $courseid);
 
-    if ($users = get_users_by_capability($context, 'moodle/course:update', 'u.*,ra.hidden', 'r.sortorder ASC',
-                                         '', '', '', '', false)) {
-        foreach ($users as $user) {
-            if (!$user->hidden || has_capability('moodle/role:viewhiddenassigns', $context)) {
-                return $user;
-            }
-        }
+    // Pass $view=true to filter hidden caps if the user cannot see them
+    if ($users = get_users_by_capability($context, 'moodle/course:update', 'u.*', 'u.id ASC',
+                                         '', '', '', '', false, true)) {
+        return array_shift($users);
     }
 
     return false;
@@ -746,7 +743,7 @@ function get_course_teachers($courseid, $sort='t.authority ASC', $exceptions='')
         }
     }
 
-    return get_users_by_capability($context, 'moodle/course:update', 'u.*, ul.timeaccess as lastaccess, ra.hidden', $sort, '','','',$exceptions, false);
+    return get_users_by_capability($context, 'moodle/course:update', 'u.*, ul.timeaccess as lastaccess', $sort, '','','',$exceptions, false);
     /// some fields will be missing, like authority, editall
     /*
     return get_records_sql("SELECT u.id, u.username, u.firstname, u.lastname, u.maildisplay, u.mailformat, u.maildigest,