From: mjollnir_ Date: Mon, 22 Nov 2004 01:40:18 +0000 (+0000) Subject: On enrol students to a course page, force searching if too many users to display... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=4f3fecf4a6c1ff13b02c80af038d6b7fff330f38;p=moodle.git On enrol students to a course page, force searching if too many users to display (controlled by MAX_USERS_PER_PAGE - not previously used and bumped up to 1000 as a more reasonable limit) - trying to put 30,000 users in a drop down menu crashes some browsers --- diff --git a/course/student.html b/course/student.html index fc5176a799..d47068da90 100644 --- a/course/student.html +++ b/course/student.html @@ -40,6 +40,7 @@ document.studentform.remove.disabled=true; document.studentform.removeselect.selectedIndex=-1;"> \n"; foreach ($searchusers as $user) { @@ -49,9 +50,15 @@ echo "\n"; } if (!empty($users)) { - foreach ($users as $user) { - $fullname = fullname($user, true); - echo "\n"; + if ($usercount > MAX_USERS_PER_PAGE) { + echo ''."\n" + .''."\n"; + } + else { + foreach ($users as $user) { + $fullname = fullname($user, true); + echo "\n"; + } } } ?> diff --git a/course/student.php b/course/student.php index c24c7c648f..4a42bb6287 100644 --- a/course/student.php +++ b/course/student.php @@ -3,7 +3,7 @@ require_once("../config.php"); - define("MAX_USERS_PER_PAGE", 50); + define("MAX_USERS_PER_PAGE", 1000); require_variable($id); // course id optional_variable($add, ""); @@ -122,11 +122,16 @@ /// If no search results then get potential students for this course excluding users already in course if (empty($searchusers)) { - if (!$users = get_users(true, '', true, $existinguserlist, 'firstname ASC, lastname ASC', '', '', - 0, 99999, 'id, firstname, lastname, email') ) { - $users = array(); + + $usercount = get_users(false, '', true, $existinguserlist, 'firstname ASC, lastname ASC', '', '', + 0, 99999, 'id, firstname, lastname, email') ; + $users = array(); + + if ($usercount <= MAX_USERS_PER_PAGE) { + $users = get_users(true, '', true, $existinguserlist, 'firstname ASC, lastname ASC', '', '', + 0, 99999, 'id, firstname, lastname, email'); } - $usercount = count($users); + } diff --git a/lang/en/moodle.php b/lang/en/moodle.php index d9921b710d..f5d81d6223 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -994,13 +994,14 @@ $string['timezone'] = 'Timezone'; $string['to'] = 'To'; $string['today'] = 'Today'; $string['todaylogs'] = 'Today\'s logs'; -$string['toomanytoshow'] = 'There are too many users to show'; +$string['toomanytoshow'] = 'There are too many users to show.'; $string['top'] = 'Top'; $string['topic'] = 'Topic'; $string['topichide'] = 'Hide this topic from $a'; $string['topicoutline'] = 'Topic outline'; $string['topicshow'] = 'Show this topic to $a'; $string['total'] = 'Total'; +$string['trysearching'] = 'Try searching instead.'; $string['turneditingoff'] = 'Turn editing off'; $string['turneditingon'] = 'Turn editing on'; $string['undecided'] = 'Undecided';