diff --git a/backup/restorelib.php b/backup/restorelib.php index f41434de2f8..abe69fdae5c 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -2205,6 +2205,10 @@ // relink the descriptions $user->description = stripslashes(backup_todb($user->description)); + if (!empty($CFG->disableuserimages)) { + $user->picture = 0; + } + //We need to analyse the AUTH field to recode it: // - if the field isn't set, we are in a pre 1.4 backup and we'll // use manual @@ -3208,27 +3212,24 @@ foreach ($list as $dir) { // If there are directories in this folder, we are in the new user hierarchy if ($newlist = list_directories("$rootdir/$dir")) { - foreach ($newlist as $userid) { - $userlist[$userid] = "$rootdir/$dir/$userid"; + foreach ($newlist as $olduserid) { + $userlist[$olduserid] = "$rootdir/$dir/$olduserid"; } } else { - $userlist[$userid] = "$rootdir/$dir"; + $userlist[$dir] = "$rootdir/$dir"; } } - foreach ($userlist as $userid => $backup_location) { + foreach ($userlist as $olduserid => $backup_location) { //Look for dir like username in backup_ids - $data = get_record ("backup_ids","backup_code",$restore->backup_unique_code, "table_name","user", "old_id",$userid); - //If that user exists in backup_ids - if ($data) { + if ($user = backup_getid($restore->backup_unique_code,"user",$olduserid)) { //Only if user has been created now or if it existed previously, but he hasn't got an image (see bug 1123) - $newuserdir = make_user_directory($userid, true); // Doesn't create the folder, just returns the location + $newuserdir = make_user_directory($user->new_id, true); // Doesn't create the folder, just returns the location - if ((strpos($data->info,"new") !== false) or (!check_dir_exists($newuserdir))) { - //Copy the old_dir to its new location (and name) !! Only if destination doesn't exists - if (!file_exists($newuserdir)) { - make_user_directory($userid); // Creates the folder + // restore images if new user or image does not exist yet + if (!empty($user->new) or !check_dir_exists($newuserdir)) { + if (make_user_directory($user->new_id)) { // Creates the folder $status = backup_copy_file($backup_location, $newuserdir, true); $counter ++; }