mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
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
This commit is contained in:
parent
eb46f6a322
commit
4f3fecf4a6
3 changed files with 22 additions and 9 deletions
|
@ -40,6 +40,7 @@
|
||||||
document.studentform.remove.disabled=true;
|
document.studentform.remove.disabled=true;
|
||||||
document.studentform.removeselect.selectedIndex=-1;">
|
document.studentform.removeselect.selectedIndex=-1;">
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (!empty($searchusers)) {
|
if (!empty($searchusers)) {
|
||||||
echo "<optgroup label=\"$strsearchresults (" . count($searchusers) . ")\">\n";
|
echo "<optgroup label=\"$strsearchresults (" . count($searchusers) . ")\">\n";
|
||||||
foreach ($searchusers as $user) {
|
foreach ($searchusers as $user) {
|
||||||
|
@ -49,9 +50,15 @@
|
||||||
echo "</optgroup>\n";
|
echo "</optgroup>\n";
|
||||||
}
|
}
|
||||||
if (!empty($users)) {
|
if (!empty($users)) {
|
||||||
foreach ($users as $user) {
|
if ($usercount > MAX_USERS_PER_PAGE) {
|
||||||
$fullname = fullname($user, true);
|
echo '<optgroup label="'.get_string('toomanytoshow').'"><option></option></optgroup>'."\n"
|
||||||
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
|
.'<optgroup label="'.get_string('trysearching').'"><option></option></optgroup>'."\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
foreach ($users as $user) {
|
||||||
|
$fullname = fullname($user, true);
|
||||||
|
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
require_once("../config.php");
|
require_once("../config.php");
|
||||||
|
|
||||||
define("MAX_USERS_PER_PAGE", 50);
|
define("MAX_USERS_PER_PAGE", 1000);
|
||||||
|
|
||||||
require_variable($id); // course id
|
require_variable($id); // course id
|
||||||
optional_variable($add, "");
|
optional_variable($add, "");
|
||||||
|
@ -122,11 +122,16 @@
|
||||||
|
|
||||||
/// If no search results then get potential students for this course excluding users already in course
|
/// If no search results then get potential students for this course excluding users already in course
|
||||||
if (empty($searchusers)) {
|
if (empty($searchusers)) {
|
||||||
if (!$users = get_users(true, '', true, $existinguserlist, 'firstname ASC, lastname ASC', '', '',
|
|
||||||
0, 99999, 'id, firstname, lastname, email') ) {
|
$usercount = get_users(false, '', true, $existinguserlist, 'firstname ASC, lastname ASC', '', '',
|
||||||
$users = array();
|
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -994,13 +994,14 @@ $string['timezone'] = 'Timezone';
|
||||||
$string['to'] = 'To';
|
$string['to'] = 'To';
|
||||||
$string['today'] = 'Today';
|
$string['today'] = 'Today';
|
||||||
$string['todaylogs'] = 'Today\'s logs';
|
$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['top'] = 'Top';
|
||||||
$string['topic'] = 'Topic';
|
$string['topic'] = 'Topic';
|
||||||
$string['topichide'] = 'Hide this topic from $a';
|
$string['topichide'] = 'Hide this topic from $a';
|
||||||
$string['topicoutline'] = 'Topic outline';
|
$string['topicoutline'] = 'Topic outline';
|
||||||
$string['topicshow'] = 'Show this topic to $a';
|
$string['topicshow'] = 'Show this topic to $a';
|
||||||
$string['total'] = 'Total';
|
$string['total'] = 'Total';
|
||||||
|
$string['trysearching'] = 'Try searching instead.';
|
||||||
$string['turneditingoff'] = 'Turn editing off';
|
$string['turneditingoff'] = 'Turn editing off';
|
||||||
$string['turneditingon'] = 'Turn editing on';
|
$string['turneditingon'] = 'Turn editing on';
|
||||||
$string['undecided'] = 'Undecided';
|
$string['undecided'] = 'Undecided';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue