Skip to content
Browse files

MDL-12523 lib/deprecatedlib: enrol/manual: Fix calls to get_users_by_…

…capability() to avoid ra

get_users_by_capability() can no longer refer to properties of role
assignments or roles, as the capability aggregate is indirect.

 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.

  • Loading branch information...
martinlanghoff committed Jan 6, 2008
1 parent f5687e3 commit 3e117fb6af15287aad2e7adb318e3e8e66c625c0
Showing with 5 additions and 8 deletions.
  1. +5 −8 lib/deprecatedlib.php
@@ -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.*', ' 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.username, u.firstname, u.lastname, u.maildisplay, u.mailformat, u.maildigest,

0 comments on commit 3e117fb

Please sign in to comment.
You can’t perform that action at this time.