]> git.mxchange.org Git - friendica.git/blobdiff - include/uimport.php
Code standards in api_get_user
[friendica.git] / include / uimport.php
index 442df94460777cb5ef555982929d4c80786ed9bc..d9b040597fdc6c8affe2af20354a437821dba064 100644 (file)
@@ -1,10 +1,15 @@
 <?php
-
+/**
+ * @file include/uimport.php
+ */
 use Friendica\App;
 use Friendica\Core\System;
 use Friendica\Core\PConfig;
+use Friendica\Core\Worker;
+use Friendica\Database\DBM;
+use Friendica\Model\Photo;
+use Friendica\Object\Image;
 
-require_once("include/Photo.php");
 define("IMPORT_DEBUG", False);
 
 function last_insert_id() {
@@ -103,7 +108,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;
        }
@@ -114,7 +119,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;
        }
@@ -145,7 +150,6 @@ function import_account(App $a, $file) {
        // import user
        $r = db_import_assoc('user', $account['user']);
        if ($r === false) {
-               //echo "<pre>"; var_dump($r, $query, mysql_error()); killme();
                logger("uimport:insert user : ERROR : " . dba::errorMessage(), LOGGER_NORMAL);
                notice(t("User creation error"));
                return;
@@ -187,7 +191,7 @@ function import_account(App $a, $file) {
                        }
                }
                if ($contact['uid'] == $olduid && $contact['self'] == '0') {
-                       // set contacts 'avatar-date' to NULL_DATE to let poller to update urls
+                       // set contacts 'avatar-date' to NULL_DATE to let worker to update urls
                        $contact["avatar-date"] = NULL_DATE;
 
                        switch ($contact['network']) {
@@ -195,12 +199,6 @@ function import_account(App $a, $file) {
                                case NETWORK_DIASPORA:
                                        //  send relocate message (below)
                                        break;
-                               case NETWORK_ZOT:
-                                       /// @TODO handle zot network
-                                       break;
-                               case NETWORK_MAIL2:
-                                       /// @TODO ?
-                                       break;
                                case NETWORK_FEED:
                                case NETWORK_MAIL:
                                        // Nothing to do
@@ -234,8 +232,6 @@ function import_account(App $a, $file) {
        }
 
        foreach ($account['group_member'] as &$group_member) {
-               $group_member['uid'] = $newuid;
-
                $import = 0;
                foreach ($account['group'] as $group) {
                        if ($group['id'] == $group_member['gid'] && isset($group['newid'])) {
@@ -263,8 +259,9 @@ function import_account(App $a, $file) {
                $photo['uid'] = $newuid;
                $photo['data'] = hex2bin($photo['data']);
 
-               $p = new Photo($photo['data'], $photo['type']);
-               $r = $p->store(
+               $Image = new Image($photo['data'], $photo['type']);
+               $r = Photo::store(
+                               $Image,
                                $photo['uid'], $photo['contact-id'], //0
                                $photo['resource-id'], $photo['filename'], $photo['album'], $photo['scale'], $photo['profile'], //1
                                $photo['allow_cid'], $photo['allow_gid'], $photo['deny_cid'], $photo['deny_gid']
@@ -284,7 +281,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");