From: stronk7 Date: Thu, 18 Dec 2008 00:20:51 +0000 (+0000) Subject: MDL-17009 restore of mnet users - Automatic switching of remote users (unknown host... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=9eaefcf1ee914d3594873ee1b9d1431d6f182fd6;p=moodle.git MDL-17009 restore of mnet users - Automatic switching of remote users (unknown host) to local ones. Merged from 19_STABLE --- diff --git a/backup/restorelib.php b/backup/restorelib.php index 40cfed76ce..6fe8974275 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -2507,6 +2507,9 @@ define('RESTORE_GROUPS_GROUPINGS', 3); /// Iterate over all users loaded from xml $counter = 0; + + /// Init trailing messages + $messages = array(); foreach ($info->users as $userid) { $rec = backup_getid($restore->backup_unique_code,"user",$userid); $user = $rec->info; @@ -2565,9 +2568,15 @@ define('RESTORE_GROUPS_GROUPINGS', 3); if (isset($mnethosts[$user->mnethosturl])) { $user->mnethostid = $mnethosts[$user->mnethosturl]->id; } else { - // should not happen, as we check in restore_chech.php - // but handle the error if it does - print_error('backupcontainexternal', 'error'); + // 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); } } unset($user->mnethosturl); @@ -2834,6 +2843,17 @@ define('RESTORE_GROUPS_GROUPINGS', 3); backup_flush(300); } } /// End of loop over all the users loaded from xml + + /// Inform about all the messages geerated while restoring users + if (!defined('RESTORE_SILENTLY')) { + if ($messages) { + echo ''; + } + } } return $status;