$groupmembersoptions .= '<option> </option>'; } //TODO: If no 'showall' button, then set true. $showall = true; $potentialmembers = array(); $potentialmembersoptions = ''; $potentialmemberscount = 0; if (!$showall && $groupingid != GROUP_NOT_IN_GROUPING) { $potentialmembers = groups_get_users_not_in_any_group_in_grouping($courseid, $groupingid, $groupid); } else { $potentialmembers = groups_get_users_not_in_group($courseid, $groupid); } if ($potentialmembers != false) { // Put the groupings into a hash and sorts them foreach ($potentialmembers as $userid) { $nonmembers[$userid] = groups_get_user_displayname($userid, $courseid); $potentialmemberscount++; } natcasesort($nonmembers); // Print out the HTML foreach ($nonmembers as $id => $name) { $potentialmembersoptions .= "<option value=\"{$id}\">{$name}</option>\n"; } } else { $potentialmembersoptions .= '<option> </option>'; } // Print the page and form $strgroups = get_string('groups'); $strparticipants = get_string('participants'); $groupname = groups_get_group_displayname($groupid); print_header("{$course->shortname}: {$strgroups}", $course->fullname, "<a href=\"{$CFG->wwwroot}/course/view.php?id={$courseid}\">{$course->shortname}</a> " . "-> <a href=\"{$CFG->wwwroot}/user/index.php?id={$courseid}\">{$strparticipants}</a> " . '-> <a href="' . format_string(groups_home_url($courseid, $groupid, $groupingid, false)) . "\">{$strgroups}</a>" . '-> ' . get_string('adduserstogroup', 'group'), '', '', true, '', user_login_string($course, $USER));
/** * Get an sorted array of user-id/display-name objects. */ function groups_userids_to_user_names($userids, $courseid) { if (!$userids) { return array(); } $member_names = array(); foreach ($userids as $id) { $user = new object(); $user->id = $id; $user->name = groups_get_user_displayname($id, $courseid); $member_names[] = $user; } if (!usort($member_names, 'groups_compare_name')) { debug('Error usort [groups_compare_name].'); } return $member_names; }