]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-16021 dont force mnethost restriction forloading user data based on id
authorpeterbulmer <peterbulmer>
Thu, 14 Aug 2008 23:36:37 +0000 (23:36 +0000)
committerpeterbulmer <peterbulmer>
Thu, 14 Aug 2008 23:36:37 +0000 (23:36 +0000)
lib/moodlelib.php

index 4402944d00c82ec5c4197e5904309a7442e66621..3d81952eea366fe467860443316dacccf926592e 100644 (file)
@@ -3228,17 +3228,18 @@ function get_complete_user_data($field, $value, $mnethostid=null) {
     $params = array('fieldval'=>$value);
     $constraints = "$field = :fieldval AND deleted <> 1";
 
-    if (is_null($mnethostid)) {
-        // if null, we restrict to local users
-        // ** testing for local user can be done with
-        //    mnethostid = $CFG->mnet_localhost_id
-        //    or with
-        //    auth != 'mnet'
-        //    but the first one is FAST with our indexes
-        $mnethostid = $CFG->mnet_localhost_id;
-    }
-    $params['mnethostid'] = $mnethostid;
-    $constraints .= " AND mnethostid = :mnethostid";
+    // If we are loading user data based on anything other than id,
+    // we must also restrict our search based on mnet host.
+    if ($field != 'id') {
+        if (empty($mnethostid)) {
+            // if empty, we restrict to local users
+            $mnethostid = $CFG->mnet_localhost_id;
+        }
+    }
+    if (!empty($mnethostid)) {
+        $params['mnethostid'] = $mnethostid;
+        $constraints .= " AND mnethostid = :mnethostid";
+    }
 
 /// Get all the basic user data