Follow-up fix for Bug MDL-8617 "Implement groupings & course modules..." internal (sam's patch, thank you!)

This commit is contained in:
nfreear 2007-03-01 11:33:35 +00:00
parent 504af96b2e
commit 20ed8a7215

View file

@ -188,8 +188,13 @@ function groups_groupids_to_groups($groupids, $courseid=false, $alldata=false) {
/** /**
* Get a sorted array of group-id/display-name objects. * Get a sorted array of group-id/display-name objects.
* @param array $groupids Array of group IDs
* @param bool $justnames Return names only as values, not objects. Needed
* for print_group_menu in weblib
* @return array If $justnames is set, returns an array of id=>name. Otherwise
* returns an array without specific keys of objects containing id, name
*/ */
function groups_groupids_to_group_names($groupids) { function groups_groupids_to_group_names($groupids, $justnames=false) {
if (! $groupids) { if (! $groupids) {
return array(); return array();
} }
@ -216,6 +221,15 @@ function groups_groupids_to_group_names($groupids) {
$gname->name = $name; $gname->name = $name;
$group_names[] = $gname; $group_names[] = $gname;
}*/ }*/
if ($justnames) {
$namesonly = array();
foreach ($group_names as $id => $object) {
$namesonly[$object->id] = $object->name;
}
return $namesonly;
}
return $group_names; return $group_names;
} }