From 809e0a75994f8973a1f99dc178e05da972e04b5a Mon Sep 17 00:00:00 2001 From: peterbulmer Date: Thu, 14 Aug 2008 23:36:37 +0000 Subject: [PATCH] MDL-16021 dont force mnethost restriction forloading user data based on id --- lib/moodlelib.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 4402944d00..3d81952eea 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -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 -- 2.39.5