mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-8605 fixed user image restore code
This commit is contained in:
parent
ffb2a56ff1
commit
e3516b2da1
@ -2205,6 +2205,10 @@
|
|||||||
// relink the descriptions
|
// relink the descriptions
|
||||||
$user->description = stripslashes(backup_todb($user->description));
|
$user->description = stripslashes(backup_todb($user->description));
|
||||||
|
|
||||||
|
if (!empty($CFG->disableuserimages)) {
|
||||||
|
$user->picture = 0;
|
||||||
|
}
|
||||||
|
|
||||||
//We need to analyse the AUTH field to recode it:
|
//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
|
// - if the field isn't set, we are in a pre 1.4 backup and we'll
|
||||||
// use manual
|
// use manual
|
||||||
@ -3208,27 +3212,24 @@
|
|||||||
foreach ($list as $dir) {
|
foreach ($list as $dir) {
|
||||||
// If there are directories in this folder, we are in the new user hierarchy
|
// If there are directories in this folder, we are in the new user hierarchy
|
||||||
if ($newlist = list_directories("$rootdir/$dir")) {
|
if ($newlist = list_directories("$rootdir/$dir")) {
|
||||||
foreach ($newlist as $userid) {
|
foreach ($newlist as $olduserid) {
|
||||||
$userlist[$userid] = "$rootdir/$dir/$userid";
|
$userlist[$olduserid] = "$rootdir/$dir/$olduserid";
|
||||||
}
|
}
|
||||||
} else {
|
} 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
|
//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 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)
|
//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))) {
|
// restore images if new user or image does not exist yet
|
||||||
//Copy the old_dir to its new location (and name) !! Only if destination doesn't exists
|
if (!empty($user->new) or !check_dir_exists($newuserdir)) {
|
||||||
if (!file_exists($newuserdir)) {
|
if (make_user_directory($user->new_id)) { // Creates the folder
|
||||||
make_user_directory($userid); // Creates the folder
|
|
||||||
$status = backup_copy_file($backup_location, $newuserdir, true);
|
$status = backup_copy_file($backup_location, $newuserdir, true);
|
||||||
$counter ++;
|
$counter ++;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user