]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-17009 restore of mnet users - prevent any user using local host to end with mnet...
authorstronk7 <stronk7>
Sun, 10 May 2009 01:16:10 +0000 (01:16 +0000)
committerstronk7 <stronk7>
Sun, 10 May 2009 01:16:10 +0000 (01:16 +0000)
backup/restorelib.php

index 504db381e45d6f11fd0f787a43b1f66667f1eb47..ae5f8b4b2dbb24b25bd59b01cdd6d889280f7f7b 100644 (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