mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-13045: Made groups UI use role name aliases
This commit is contained in:
parent
1c5376af07
commit
3540f2b35c
@ -344,7 +344,7 @@ function groups_get_users_not_in_group_by_role($courseid, $groupid, $searchtext=
|
||||
$orderby = " ORDER BY $sort";
|
||||
|
||||
return groups_calculate_role_people(get_recordset_sql(
|
||||
$select.$from.$where.$orderby));
|
||||
$select.$from.$where.$orderby),$context->id);
|
||||
}
|
||||
|
||||
|
||||
@ -540,7 +540,7 @@ function groups_get_members_by_role($groupid, $courseid, $fields='u.*', $sort='u
|
||||
AND ra.contextid ".get_related_contexts_string($context)."
|
||||
ORDER BY r.sortorder,$sort");
|
||||
|
||||
return groups_calculate_role_people($rs);
|
||||
return groups_calculate_role_people($rs,$context->id);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -549,14 +549,20 @@ function groups_get_members_by_role($groupid, $courseid, $fields='u.*', $sort='u
|
||||
* roles on a course.
|
||||
*
|
||||
* @param object $rs The record set (may be false)
|
||||
* @param int $contextid ID of course context
|
||||
* @return array As described in groups_get_members_by_role
|
||||
*/
|
||||
function groups_calculate_role_people($rs) {
|
||||
function groups_calculate_role_people($rs,$contextid) {
|
||||
global $CFG;
|
||||
if(!$rs) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get role aliases for course in array of roleid => obj->text
|
||||
if(!($aliasnames=get_records('role_names','contextid',$contextid,'','roleid,text'))) {
|
||||
$aliasnames=array();
|
||||
}
|
||||
|
||||
// Array of all involved roles
|
||||
$roles=array();
|
||||
// Array of all retrieved users
|
||||
@ -585,7 +591,11 @@ function groups_calculate_role_people($rs) {
|
||||
$roledata=new StdClass;
|
||||
$roledata->id=$rec->roleid;
|
||||
$roledata->shortname=$rec->roleshortname;
|
||||
if(array_key_exists($rec->roleid,$aliasnames)) {
|
||||
$roledata->name=$aliasnames[$rec->roleid]->text;
|
||||
} else {
|
||||
$roledata->name=$rec->rolename;
|
||||
}
|
||||
$roledata->users=array();
|
||||
$roles[$roledata->id]=$roledata;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user