X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fdfrn.php;h=bc62de6ed9e60333262a48917b4b5a4cb550ac87;hb=0cd9db9cb7f4c96f597e37590a536eaae123238d;hp=1b97f39a2d939b404c273eb6759f07ac4f84e552;hpb=9c0d2c31e87a73f157b360c518eb059e9a2507de;p=friendica.git diff --git a/include/dfrn.php b/include/dfrn.php index 1b97f39a2d..bc62de6ed9 100644 --- a/include/dfrn.php +++ b/include/dfrn.php @@ -284,6 +284,62 @@ class dfrn { return $atom; } + /** + * @brief Generate an atom entry for a given item id + * + * @param int $item_id The item id + * + * @return string DFRN feed entry + */ + public static function itemFeed($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` + STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` + AND (NOT `contact`.`blocked` OR `contact`.`pending`) + LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id` + WHERE `item`.`id` = %d AND `item`.`visible` AND NOT `item`.`moderated` AND `item`.`parent` != 0 + AND `item`.`wall` AND NOT `item`.`private`", + intval($item_id) + ); + + if (!dbm::is_result($r)) { + killme(); + } + + $item = $r[0]; + + $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` AND `user`.`uid` = %d LIMIT 1", + intval($item['uid']) + ); + + if (!dbm::is_result($r)) { + killme(); + } + + $owner = $r[0]; + + $doc = new DOMDocument('1.0', 'utf-8'); + $doc->formatOutput = true; + + $alternatelink = $owner['url']; + + $root = self::add_header($doc, $owner, 'dfrn:owner', $alternatelink, true); + + $type = 'html'; + + $entry = self::entry($doc, $type, $item, $owner, true); + $root->appendChild($entry); + + $atom = trim($doc->saveXML()); + return $atom; + } + /** * @brief Create XML text for DFRN mails *