MDL-28126 webservice : resolved integration conflicts
[moodle.git] / admin / webservice / forms.php
index b95935c..ce16f99 100644 (file)
@@ -179,7 +179,7 @@ class external_service_functions_form extends moodleform {
 class web_service_token_form extends moodleform {
 
     function definition() {
-        global $USER, $DB;
+        global $USER, $DB, $CFG;
 
         $mform = $this->_form;
         $data = $this->_customdata;
@@ -194,9 +194,13 @@ class web_service_token_form extends moodleform {
 
             if ($usertotal < 500) {
                 //user searchable selector - get all users (admin and guest included)
-                $users = $DB->get_records('user',
-                        array('deleted' => 0, 'suspended' => 0, 'confirmed' => 1), 'lastname',
-                        'id, firstname, lastname');
+                //user must be confirmed, not deleted, not suspended, not guest
+                $sql = "SELECT u.id, u.firstname, u.lastname
+                FROM {user} u
+                WHERE u.deleted = 0 AND u.confirmed = 1 AND u.suspended = 0 AND u.id != ?
+                ORDER BY u.lastname";
+                $users = $DB->get_records_sql($sql, array($CFG->siteguest));
+
                 $options = array();
                 foreach ($users as $userid => $user) {
                     $options[$userid] = $user->firstname . " " . $user->lastname;