X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fuimport.php;h=0d9ffc35fca2f001fcf6df23db1f03a1e8fd8da5;hb=c2213760412f6d178d77451d69ae467534042457;hp=fcc7e75a6120d99790062a7ee15b8f89876a3f0c;hpb=4487515d0c8dc295e5f8b7a137accfa741b5cf52;p=friendica.git diff --git a/include/uimport.php b/include/uimport.php index fcc7e75a61..0d9ffc35fc 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 */ @@ -116,7 +116,7 @@ function import_account(&$a, $file) { notice(t('Error! Cannot check nickname')); return; } - if (count($r) > 0) { + if (dbm::is_result($r) > 0) { notice(sprintf(t("User '%s' already exists on this server!"), $account['user']['nickname'])); return; } @@ -127,13 +127,13 @@ function import_account(&$a, $file) { notice(t('Error! Cannot check nickname')); return; } - if (count($r) > 0) { + if (dbm::is_result($r) > 0) { notice(sprintf(t("User '%s' already exists on this server!"), $account['user']['nickname'])); return; } $oldbaseurl = $account['baseurl']; - $newbaseurl = $a->get_baseurl(); + $newbaseurl = App::get_baseurl(); $olduid = $account['user']['uid']; unset($account['user']['uid']); @@ -156,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); @@ -180,23 +182,23 @@ 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) break; case NETWORK_ZOT: - // TODO handle zot network + /// @TODO handle zot network break; case NETWORK_MAIL2: - // TODO ? + /// @TODO ? break; case NETWORK_FEED: case NETWORK_MAIL: @@ -285,8 +287,8 @@ function import_account(&$a, $file) { } // send relocate messages - proc_run('php', 'include/notifier.php', 'relocate', $newuid); + proc_run(PRIORITY_HIGH, 'include/notifier.php', 'relocate', $newuid); info(t("Done. You can now login with your username and password")); - goaway($a->get_baseurl() . "/login"); + goaway(App::get_baseurl() . "/login"); }