X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Fdfrn.php;h=67cef59d956ccbe037a060e272ba9f83a1439c97;hb=d55d500e3534579ffbd7d992d5b103d3e9ab1709;hp=9d91cbce7b585118f12b191089f069a4e01a39a3;hpb=cd92a0dc34a8b5400311df0630d9933876f4d4db;p=friendica.git diff --git a/include/dfrn.php b/include/dfrn.php index 9d91cbce7b..67cef59d95 100644 --- a/include/dfrn.php +++ b/include/dfrn.php @@ -98,9 +98,9 @@ class dfrn { $sql_extra = " AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' "; - $r = q("SELECT `contact`.*, `user`.`nickname`, `user`.`timezone`, `user`.`page-flags` + $r = q("SELECT `contact`.*, `user`.`nickname`, `user`.`timezone`, `user`.`page-flags`, `user`.`account-type` FROM `contact` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid` - WHERE `contact`.`self` = 1 AND `user`.`nickname` = '%s' LIMIT 1", + WHERE `contact`.`self` AND `user`.`nickname` = '%s' LIMIT 1", dbesc($owner_nick) ); @@ -112,7 +112,6 @@ class dfrn { $owner_nick = $owner['nickname']; $sql_post_table = ""; - $visibility = ""; if(! $public_feed) { @@ -135,7 +134,7 @@ class dfrn { break; // NOTREACHED } - $r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `contact`.`uid` = %d $sql_extra LIMIT 1", + $r = q("SELECT * FROM `contact` WHERE NOT `blocked` AND `contact`.`uid` = %d $sql_extra LIMIT 1", intval($owner_id) ); @@ -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) @@ -440,9 +433,13 @@ class dfrn { xml::add_element($doc, $root, "link", "", $attributes); } + // For backward compatibility we keep this element if ($owner['page-flags'] == PAGE_COMMUNITY) xml::add_element($doc, $root, "dfrn:community", 1); + // The former element is replaced by this one + xml::add_element($doc, $root, "dfrn:account_type", $owner["account-type"]); + /// @todo We need a way to transmit the different page flags like "PAGE_PRVGROUP" xml::add_element($doc, $root, "updated", datetime_convert("UTC", "UTC", "now", ATOM_TIME)); @@ -512,14 +509,16 @@ class dfrn { xml::add_element($doc, $author, "dfrn:birthday", $birthday); // Only show contact details when we are allowed to - $r = q("SELECT `profile`.`about`, `profile`.`name`, `profile`.`homepage`, `user`.`nickname`, `user`.`timezone`, - `profile`.`locality`, `profile`.`region`, `profile`.`country-name`, `profile`.`pub_keywords`, `profile`.`dob` + $r = q("SELECT `profile`.`about`, `profile`.`name`, `profile`.`homepage`, `user`.`nickname`, + `user`.`timezone`, `profile`.`locality`, `profile`.`region`, `profile`.`country-name`, + `profile`.`pub_keywords`, `profile`.`xmpp`, `profile`.`dob` FROM `profile` INNER JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `profile`.`is-default` AND NOT `user`.`hidewall` AND `user`.`uid` = %d", intval($owner['uid'])); if ($r) { $profile = $r[0]; + xml::add_element($doc, $author, "poco:displayName", $profile["name"]); xml::add_element($doc, $author, "poco:updated", $namdate); @@ -550,12 +549,10 @@ class dfrn { } - /// @todo When we are having the XMPP address in the profile we should propagate it here - $xmpp = ""; - if (trim($xmpp) != "") { + if (trim($profile["xmpp"]) != "") { $ims = $doc->createElement("poco:ims"); xml::add_element($doc, $ims, "poco:type", "xmpp"); - xml::add_element($doc, $ims, "poco:value", $xmpp); + xml::add_element($doc, $ims, "poco:value", $profile["xmpp"]); xml::add_element($doc, $ims, "poco:primary", "true"); $author->appendChild($ims); } @@ -1143,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`, `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) { @@ -1219,9 +1216,13 @@ class dfrn { if ($value != "") $poco["location"] = $value; + /// @todo Only search for elements with "poco:type" = "xmpp" + $value = $xpath->evaluate($element."/poco:ims/poco:value/text()", $context)->item(0)->nodeValue; + if ($value != "") + $poco["xmpp"] = $value; + /// @todo Add support for the following fields that we don't support by now in the contact table: /// - poco:utcOffset - /// - poco:ims /// - poco:urls /// - poco:locality /// - poco:region @@ -1308,12 +1309,13 @@ class dfrn { q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `about` = '%s', `location` = '%s', `addr` = '%s', `keywords` = '%s', `bdyear` = '%s', `bd` = '%s', `hidden` = %d, - `name-date` = '%s', `uri-date` = '%s' + `xmpp` = '%s', `name-date` = '%s', `uri-date` = '%s' WHERE `id` = %d AND `network` = '%s'", dbesc($contact["name"]), dbesc($contact["nick"]), dbesc($contact["about"]), dbesc($contact["location"]), dbesc($contact["addr"]), dbesc($contact["keywords"]), dbesc($contact["bdyear"]), - dbesc($contact["bd"]), intval($contact["hidden"]), dbesc($contact["name-date"]), - dbesc($contact["uri-date"]), intval($contact["id"]), dbesc($contact["network"])); + dbesc($contact["bd"]), intval($contact["hidden"]), dbesc($contact["xmpp"]), + dbesc($contact["name-date"]), dbesc($contact["uri-date"]), + intval($contact["id"]), dbesc($contact["network"])); } update_contact_avatar($author["avatar"], $importer["uid"], $contact["id"], @@ -1327,6 +1329,7 @@ class dfrn { $poco["generation"] = 2; $poco["photo"] = $author["avatar"]; $poco["hide"] = $hide; + $poco["contact-type"] = $contact["contact-type"]; update_gcontact($poco); } @@ -1692,7 +1695,7 @@ class dfrn { $changed = true; if ($entrytype == DFRN_REPLY_RC) - proc_run("php", "include/notifier.php","comment-import", $current["id"]); + proc_run(PRIORITY_HIGH, "include/notifier.php","comment-import", $current["id"]); } // update last-child if it changes @@ -2252,7 +2255,7 @@ class dfrn { if($posted_id AND $parent AND ($entrytype == DFRN_REPLY_RC)) { logger("Notifying followers about comment ".$posted_id, LOGGER_DEBUG); - proc_run("php", "include/notifier.php", "comment-import", $posted_id); + proc_run(PRIORITY_HIGH, "include/notifier.php", "comment-import", $posted_id); } return true; @@ -2423,7 +2426,7 @@ class dfrn { if($entrytype == DFRN_REPLY_RC) { logger("Notifying followers about deletion of post ".$item["id"], LOGGER_DEBUG); - proc_run("php", "include/notifier.php","drop", $item["id"]); + proc_run(PRIORITY_HIGH, "include/notifier.php","drop", $item["id"]); } } } @@ -2483,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"])