MDL-17009 restore of mnet users - prevent any user using local host to end with mnet auth ; merged from 19_STABLE

This commit is contained in:
stronk7 2009-05-10 01:16:10 +00:00
parent bc68144cf8
commit adf8cf19bc

View File

@ -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