From: stronk7 Date: Sun, 10 May 2009 01:16:10 +0000 (+0000) Subject: MDL-17009 restore of mnet users - prevent any user using local host to end with mnet... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=adf8cf19bc2bfe770d35e5a672ca31118d845052;p=moodle.git MDL-17009 restore of mnet users - prevent any user using local host to end with mnet auth ; merged from 19_STABLE --- diff --git a/backup/restorelib.php b/backup/restorelib.php index 504db381e4..ae5f8b4b2d 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -2609,17 +2609,24 @@ define('RESTORE_GROUPS_GROUPINGS', 3); if (isset($mnethosts[$user->mnethosturl])) { $user->mnethostid = $mnethosts[$user->mnethosturl]->id; } else { - // lookup failed, switch user auth to manual and host to local. MDL-17009 - if ($CFG->registerauth == 'email') { - $user->auth = 'email'; - } else { - $user->auth = 'manual'; - } $user->mnethostid = $CFG->mnet_localhost_id; - // inform about the automatic switch of authentication/host - $messages[] = get_string('mnetrestore_extusers_switchuserauth', 'admin', $user); } } + //Arriving here, any user with mnet auth and using $CFG->mnet_localhost_id is wrong + //as own server cannot be accesed over mnet. Change auth to manual and inform about the switch + if ($user->auth == 'mnet' && $user->mnethostid == $CFG->mnet_localhost_id) { + // Respect registerauth + if ($CFG->registerauth == 'email') { + $user->auth = 'email'; + } else { + $user->auth = 'manual'; + } + // inform about the automatic switch of authentication/host + if(empty($user->mnethosturl)) { + $user->mnethosturl = '----'; + } + $messages[] = get_string('mnetrestore_extusers_switchuserauth', 'admin', $user); + } unset($user->mnethosturl); //To store user->id along all the iteration