Skip to content

Commit

Permalink
MDL-13045: Made groups UI use role name aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
sam_marshall committed Jan 18, 2008
1 parent 1c5376a commit 3540f2b
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions group/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -549,13 +549,19 @@ 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();
Expand Down Expand Up @@ -585,7 +591,11 @@ function groups_calculate_role_people($rs) {
$roledata=new StdClass;
$roledata->id=$rec->roleid;
$roledata->shortname=$rec->roleshortname;
$roledata->name=$rec->rolename;
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;
}
Expand Down

0 comments on commit 3540f2b

Please sign in to comment.