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.

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
This commit is contained in:
martinlanghoff 2008-01-06 23:25:26 +00:00
parent 0d8466509d
commit 1113f8002a

View 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,