Fixes the not changed "addr" entry when an account is imported

This commit is contained in:
Michael 2017-10-07 05:20:46 +00:00
parent 072bf7d13d
commit ceb0dda486
1 changed files with 7 additions and 3 deletions

View File

@ -125,6 +125,10 @@ function import_account(App $a, $file) {
$oldbaseurl = $account['baseurl'];
$newbaseurl = System::baseUrl();
$oldaddr = str_replace('http://', '@', normalise_link($oldbaseurl));
$newaddr = str_replace('http://', '@', normalise_link($newbaseurl));
$olduid = $account['user']['uid'];
unset($account['user']['uid']);
@ -133,7 +137,7 @@ function import_account(App $a, $file) {
unset($account['user']['expire_notification_sent']);
foreach ($account['user'] as $k => &$v) {
$v = str_replace($oldbaseurl, $newbaseurl, $v);
$v = str_replace(array($oldbaseurl, $oldaddr), array($newbaseurl, $newaddr), $v);
}
// import user
@ -153,7 +157,7 @@ function import_account(App $a, $file) {
foreach ($account['profile'] as &$profile) {
foreach ($profile as $k => &$v) {
$v = str_replace($oldbaseurl, $newbaseurl, $v);
$v = str_replace(array($oldbaseurl, $oldaddr), array($newbaseurl, $newaddr), $v);
foreach (array("profile", "avatar") as $k) {
$v = str_replace($oldbaseurl . "/photo/" . $k . "/" . $olduid . ".jpg", $newbaseurl . "/photo/" . $k . "/" . $newuid . ".jpg", $v);
}
@ -172,7 +176,7 @@ function import_account(App $a, $file) {
foreach ($account['contact'] as &$contact) {
if ($contact['uid'] == $olduid && $contact['self'] == '1') {
foreach ($contact as $k => &$v) {
$v = str_replace($oldbaseurl, $newbaseurl, $v);
$v = str_replace(array($oldbaseurl, $oldaddr), array($newbaseurl, $newaddr), $v);
foreach (array("profile", "avatar", "micro") as $k) {
$v = str_replace($oldbaseurl . "/photo/" . $k . "/" . $olduid . ".jpg", $newbaseurl . "/photo/" . $k . "/" . $newuid . ".jpg", $v);
}