]> git.mjollnir.org Git - moodle.git/commitdiff
On enrol students to a course page, force searching if too many users to display...
authormjollnir_ <mjollnir_>
Mon, 22 Nov 2004 01:40:18 +0000 (01:40 +0000)
committermjollnir_ <mjollnir_>
Mon, 22 Nov 2004 01:40:18 +0000 (01:40 +0000)
course/student.html
course/student.php
lang/en/moodle.php

index fc5176a7994a40605a23761ee4f6928b8692c457..d47068da90595e11263e27212df55659d8916481 100644 (file)
@@ -40,6 +40,7 @@
                            document.studentform.remove.disabled=true;
                            document.studentform.removeselect.selectedIndex=-1;">
           <?php
+           
               if (!empty($searchusers)) {
                   echo "<optgroup label=\"$strsearchresults (" . count($searchusers) . ")\">\n";
                   foreach ($searchusers as $user) {
                   echo "</optgroup>\n";
               }
               if (!empty($users)) {
-                  foreach ($users as $user) {
-                      $fullname = fullname($user, true);
-                      echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
+                  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 {
+                      foreach ($users as $user) {
+                          $fullname = fullname($user, true);
+                          echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
+                      }
                   }
               }
           ?>
index c24c7c648fafe54bbec3729ffdb7b82278f95211..4a42bb628733e5f20d5f754616faeb848cea4c6a 100644 (file)
@@ -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, "");
     
 /// 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);
+
     }
 
 
index d9921b710d3d3d17246110a656b6b313dc0a5a03..f5d81d62237cfc0251c284e0fe4b29cd54564f81 100644 (file)
@@ -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';