]> git.mxchange.org Git - friendica.git/blobdiff - include/dfrn.php
addon stuff
[friendica.git] / include / dfrn.php
index e9cfb228f65f7b8781bdc23cbe283fdf88e04e36..e048e66085c6acfb1a49d0d8e5b740381ccb8a1e 100644 (file)
@@ -112,7 +112,6 @@ class dfrn {
                $owner_nick = $owner['nickname'];
 
                $sql_post_table = "";
-               $visibility = "";
 
                if(! $public_feed) {
 
@@ -171,9 +170,6 @@ class dfrn {
                else
                        $sort = 'ASC';
 
-               $date_field = "`changed`";
-               $sql_order = "`item`.`parent` ".$sort.", `item`.`created` ASC";
-
                if(! strlen($last_update))
                        $last_update = 'now -30 days';
 
@@ -190,22 +186,19 @@ class dfrn {
 
                $check_date = datetime_convert('UTC','UTC',$last_update,'Y-m-d H:i:s');
 
-               //      AND ( `item`.`edited` > '%s' OR `item`.`changed` > '%s' )
-               //      dbesc($check_date),
-
-               $r = q("SELECT STRAIGHT_JOIN `item`.*, `item`.`id` AS `item_id`,
+               $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
                        `contact`.`name`, `contact`.`network`, `contact`.`photo`, `contact`.`url`,
                        `contact`.`name-date`, `contact`.`uri-date`, `contact`.`avatar-date`,
                        `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
                        `sign`.`signed_text`, `sign`.`signature`, `sign`.`signer`
-                       FROM `item` $sql_post_table
-                       INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
-                       AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+                       FROM `item` USE INDEX (`uid_wall_changed`, `uid_type_changed`) $sql_post_table
+                       STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
+                       AND NOT `contact`.`blocked`
                        LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id`
-                       WHERE `item`.`uid` = %d AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`parent` != 0
-                       AND ((`item`.`wall` = 1) $visibility) AND `item`.$date_field > '%s'
+                       WHERE `item`.`uid` = %d AND `item`.`visible` AND NOT `item`.`moderated` AND `item`.`parent` != 0
+                       AND `item`.`wall` AND `item`.`changed` > '%s'
                        $sql_extra
-                       ORDER BY $sql_order LIMIT 0, 300",
+                       ORDER BY `item`.`parent` ".$sort.", `item`.`created` ASC LIMIT 0, 300",
                        intval($owner_id),
                        dbesc($check_date),
                        dbesc($sort)
@@ -1147,7 +1140,7 @@ class dfrn {
                $author["link"] = $xpath->evaluate($element."/atom:uri/text()", $context)->item(0)->nodeValue;
 
                $r = q("SELECT `id`, `uid`, `url`, `network`, `avatar-date`, `name-date`, `uri-date`, `addr`,
-                               `name`, `nick`, `about`, `location`, `keywords`, `xmpp`, `bdyear`, `bd`, `hidden`
+                               `name`, `nick`, `about`, `location`, `keywords`, `xmpp`, `bdyear`, `bd`, `hidden`, `contact-type`
                                FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `network` != '%s'",
                        intval($importer["uid"]), dbesc(normalise_link($author["link"])), dbesc(NETWORK_STATUSNET));
                if ($r) {
@@ -1336,6 +1329,7 @@ class dfrn {
                        $poco["generation"] = 2;
                        $poco["photo"] = $author["avatar"];
                        $poco["hide"] = $hide;
+                       $poco["contact-type"] = $contact["contact-type"];
                        update_gcontact($poco);
                }
 
@@ -2492,7 +2486,19 @@ class dfrn {
 
                logger("Import DFRN message for user ".$importer["uid"]." from contact ".$importer["id"], LOGGER_DEBUG);
 
-               // is it a public forum? Private forums aren't supported by now with this method
+               // The account type is new since 3.5.1
+               if ($xpath->query("/atom:feed/dfrn:account_type")->length > 0) {
+                       $accounttype = intval($xpath->evaluate("/atom:feed/dfrn:account_type/text()", $context)->item(0)->nodeValue);
+
+                       if ($accounttype != $importer["contact-type"])
+                               q("UPDATE `contact` SET `contact-type` = %d WHERE `id` = %d",
+                                       intval($accounttype),
+                                       intval($importer["id"])
+                               );
+               }
+
+               // is it a public forum? Private forums aren't supported with this method
+               // This is deprecated since 3.5.1
                $forum = intval($xpath->evaluate("/atom:feed/dfrn:community/text()", $context)->item(0)->nodeValue);
 
                if ($forum != $importer["forum"])