X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fuimport.php;h=78471af1514461d33cdef9a13f7b1e5bd31503e8;hb=3665ab3de03d6a190211b7a5f3b2d881705b0f18;hp=1bfd3334c8a3a74d96efd960603722963cb0c491;hpb=efce5ae1b9c142092ae878dded34e83b336d42f8;p=friendica.git diff --git a/include/uimport.php b/include/uimport.php index 1bfd3334c8..78471af151 100644 --- a/include/uimport.php +++ b/include/uimport.php @@ -28,7 +28,7 @@ function last_error() { /** * Remove columns from array $arr that aren't in table $table - * + * * @param string $table Table name * @param array &$arr Column=>Value array from json (by ref) */ @@ -51,7 +51,7 @@ function check_cols($table, &$arr) { /** * Import data into table $table - * + * * @param string $table Table name * @param array $arr Column=>Value array from json */ @@ -120,12 +120,26 @@ function import_account(&$a, $file) { notice(sprintf(t("User '%s' already exists on this server!"), $account['user']['nickname'])); return; } + // check if username matches deleted account + $r = q("SELECT id FROM userd WHERE username='%s'", $account['user']['nickname']); + if ($r === false) { + logger("uimport:check nickname : ERROR : " . last_error(), LOGGER_NORMAL); + notice(t('Error! Cannot check nickname')); + return; + } + if (count($r) > 0) { + notice(sprintf(t("User '%s' already exists on this server!"), $account['user']['nickname'])); + return; + } $oldbaseurl = $account['baseurl']; $newbaseurl = $a->get_baseurl(); $olduid = $account['user']['uid']; - unset($account['user']['uid']); + unset($account['user']['uid']); + unset($account['user']['account_expired']); + unset($account['user']['account_expires_on']); + unset($account['user']['expire_notification_sent']); foreach ($account['user'] as $k => &$v) { $v = str_replace($oldbaseurl, $newbaseurl, $v); } @@ -142,13 +156,15 @@ function import_account(&$a, $file) { $newuid = last_insert_id(); //~ $newuid = 1; - + // Generate a new guid for the account. Otherwise there will be problems with diaspora + q("UPDATE `user` SET `guid` = '%s' WHERE `uid` = %d", + dbesc(generate_user_guid()), intval($newuid)); foreach ($account['profile'] as &$profile) { foreach ($profile as $k => &$v) { $v = str_replace($oldbaseurl, $newbaseurl, $v); foreach (array("profile", "avatar") as $k) - $v = str_replace($newbaseurl . "/photo/" . $k . "/" . $olduid . ".jpg", $newbaseurl . "/photo/" . $k . "/" . $newuid . ".jpg", $v); + $v = str_replace($oldbaseurl . "/photo/" . $k . "/" . $olduid . ".jpg", $newbaseurl . "/photo/" . $k . "/" . $newuid . ".jpg", $v); } $profile['uid'] = $newuid; $r = db_import_assoc('profile', $profile); @@ -166,14 +182,14 @@ function import_account(&$a, $file) { foreach ($contact as $k => &$v) { $v = str_replace($oldbaseurl, $newbaseurl, $v); foreach (array("profile", "avatar", "micro") as $k) - $v = str_replace($newbaseurl . "/photo/" . $k . "/" . $olduid . ".jpg", $newbaseurl . "/photo/" . $k . "/" . $newuid . ".jpg", $v); + $v = str_replace($oldbaseurl . "/photo/" . $k . "/" . $olduid . ".jpg", $newbaseurl . "/photo/" . $k . "/" . $newuid . ".jpg", $v); } } if ($contact['uid'] == $olduid && $contact['self'] == '0') { // set contacts 'avatar-date' to "0000-00-00 00:00:00" to let poller to update urls $contact["avatar-date"] = "0000-00-00 00:00:00" ; - - + + switch ($contact['network']) { case NETWORK_DFRN: // send relocate message (below)