echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
}
echo "</optgroup>\n";
- }
- if (!empty($users)) {
- foreach ($users as $user) {
- $fullname = fullname($user, true);
- echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
+ } else {
+ if ($usercount > MAX_USERS_PER_PAGE) {
+ echo '<optgroup label="'.get_string('toomanytoshow').'"><option></option></optgroup>'."\n"
+ .'<optgroup label="'.get_string('trysearching').'"><option></option></optgroup>'."\n";
+ } else {
+ if (!empty($users)) {
+ foreach ($users as $user) {
+ $fullname = fullname($user, true);
+ echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
+ }
+ }
}
}
?>
/// If no search results then get potential users excluding current admins
if (empty($searchusers)) {
- if (!$users = get_users(true, '', true, $adminlist, 'firstname ASC, lastname ASC', '', '',
- 0, 99999, 'id, firstname, lastname, email') ) {
- $users = array();
+
+ $usercount = get_users(false, '', true, $adminlist, 'firstname ASC, lastname ASC', '', '',
+ 0, 99999, 'id, firstname, lastname, email');
+
+ $users = array();
+
+ if ($usercount <= MAX_USERS_PER_PAGE) {
+ if (!$users = get_users(true, '', true, $adminlist, 'firstname ASC, lastname ASC', '', '',
+ 0, 99999, 'id, firstname, lastname, email') ) {
+ $users = array();
+ }
}
- $usercount = count($users);
}
$searchtext = (isset($frm->searchtext)) ? $frm->searchtext : "";