MDL-24505 limit max number of admin candidates
authorPetr Skoda <skodak@moodle.org>
Mon, 4 Oct 2010 07:50:12 +0000 (07:50 +0000)
committerPetr Skoda <skodak@moodle.org>
Mon, 4 Oct 2010 07:50:12 +0000 (07:50 +0000)
admin/roles/lib.php

index d77694d..d8a492d 100644 (file)
@@ -1519,6 +1519,14 @@ class admins_potential_selector extends user_selector_base {
         $order = ' ORDER BY lastname ASC, firstname ASC';
         $params['localmnet'] = $CFG->mnet_localhost_id; // it could be dangerous to make remote users admins and also this could lead to other problems
 
+        // Check to see if there are too many to show sensibly.
+        if (!$this->is_validating()) {
+            $potentialcount = $DB->count_records_sql($countfields . $sql, $params);
+            if ($potentialcount > 100) {
+                return $this->too_many_results($search, $potentialcount);
+            }
+        }
+
         $availableusers = $DB->get_records_sql($fields . $sql . $order, $params);
 
         if (empty($availableusers)) {