]> git.mxchange.org Git - friendica.git/blobdiff - include/uimport.php
Add defuse/php-encryption 2.0 to Composer dependencies
[friendica.git] / include / uimport.php
index 359fc90673d083a5e317bfda4a415a4b905900ca..af4f434d4bb0d65da2477695e7764e740bd577e8 100644 (file)
@@ -2,6 +2,9 @@
 
 use Friendica\App;
 use Friendica\Core\System;
+use Friendica\Core\PConfig;
+use Friendica\Core\Worker;
+use Friendica\Database\DBM;
 
 require_once("include/Photo.php");
 define("IMPORT_DEBUG", False);
@@ -102,7 +105,7 @@ function import_account(App $a, $file) {
                notice(t('Error! Cannot check nickname'));
                return;
        }
-       if (dbm::is_result($r) > 0) {
+       if (DBM::is_result($r) > 0) {
                notice(sprintf(t("User '%s' already exists on this server!"), $account['user']['nickname']));
                return;
        }
@@ -113,7 +116,7 @@ function import_account(App $a, $file) {
                notice(t('Error! Cannot check nickname'));
                return;
        }
-       if (dbm::is_result($r) > 0) {
+       if (DBM::is_result($r) > 0) {
                notice(sprintf(t("User '%s' already exists on this server!"), $account['user']['nickname']));
                return;
        }
@@ -124,6 +127,12 @@ function import_account(App $a, $file) {
        $oldaddr = str_replace('http://', '@', normalise_link($oldbaseurl));
        $newaddr = str_replace('http://', '@', normalise_link($newbaseurl));
 
+       if (!empty($account['profile']['addr'])) {
+               $old_handle = $account['profile']['addr'];
+       } else {
+               $old_handle = $account['user']['nickname'].$oldaddr;
+       }
+
        $olduid = $account['user']['uid'];
 
        unset($account['user']['uid']);
@@ -146,6 +155,8 @@ function import_account(App $a, $file) {
        $newuid = last_insert_id();
        //~ $newuid = 1;
 
+       PConfig::set($newuid, 'system', 'previous_addr', $old_handle);
+
        // 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));
@@ -183,6 +194,7 @@ function import_account(App $a, $file) {
 
                        switch ($contact['network']) {
                                case NETWORK_DFRN:
+                               case NETWORK_DIASPORA:
                                        //  send relocate message (below)
                                        break;
                                case NETWORK_ZOT:
@@ -274,7 +286,7 @@ function import_account(App $a, $file) {
        }
 
        // send relocate messages
-       proc_run(PRIORITY_HIGH, 'include/notifier.php', 'relocate', $newuid);
+       Worker::add(PRIORITY_HIGH, 'notifier', 'relocate', $newuid);
 
        info(t("Done. You can now login with your username and password"));
        goaway(System::baseUrl() . "/login");