2 require_once('include/items.php');
3 require_once('include/ostatus.php');
6 * @brief Generates the atom entries for delivery.php
8 * This function is used whenever content is transmitted via DFRN.
10 * @param array $items Item elements
11 * @param array $owner Owner record
13 * @return string DFRN entries
15 function dfrn_entries($items,$owner) {
17 $doc = new DOMDocument('1.0', 'utf-8');
18 $doc->formatOutput = true;
20 $root = dfrn_add_header($doc, $owner, "dfrn:owner", "", false);
23 return trim($doc->saveXML());
25 foreach($items as $item) {
26 $entry = dfrn_entry($doc, "text", $item, $owner, $item["entry:comment-allow"], $item["entry:cid"]);
27 $root->appendChild($entry);
30 return(trim($doc->saveXML()));
34 * @brief Generate an atom feed for the given user
36 * This function is called when another server is pulling data from the user feed.
39 * @param string $dfrn_id
40 * @param string $owner_nick Owner nick name
41 * @param string $last_update Date of the last update
42 * @param int $direction
44 * @return string DFRN feed entries
46 function dfrn_feed(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) {
48 $sitefeed = ((strlen($owner_nick)) ? false : true); // not yet implemented, need to rewrite huge chunks of following logic
49 $public_feed = (($dfrn_id) ? false : true);
50 $starred = false; // not yet implemented, possible security issues
53 if($public_feed && $a->argc > 2) {
54 for($x = 2; $x < $a->argc; $x++) {
55 if($a->argv[$x] == 'converse')
57 if($a->argv[$x] == 'starred')
59 if($a->argv[$x] === 'category' && $a->argc > ($x + 1) && strlen($a->argv[$x+1]))
60 $category = $a->argv[$x+1];
66 // default permissions - anonymous user
68 $sql_extra = " AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' ";
70 $r = q("SELECT `contact`.*, `user`.`uid` AS `user_uid`, `user`.`nickname`, `user`.`timezone`, `user`.`page-flags`
71 FROM `contact` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid`
72 WHERE `contact`.`self` = 1 AND `user`.`nickname` = '%s' LIMIT 1",
80 $owner_id = $owner['user_uid'];
81 $owner_nick = $owner['nickname'];
91 $sql_extra = sprintf(" AND `issued-id` = '%s' ", dbesc($dfrn_id));
95 $sql_extra = sprintf(" AND `issued-id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id));
96 $my_id = '1:' . $dfrn_id;
99 $sql_extra = sprintf(" AND `dfrn-id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id));
100 $my_id = '0:' . $dfrn_id;
107 $r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `contact`.`uid` = %d $sql_extra LIMIT 1",
115 require_once('include/security.php');
116 $groups = init_groups_visitor($contact['id']);
119 for($x = 0; $x < count($groups); $x ++)
120 $groups[$x] = '<' . intval($groups[$x]) . '>' ;
121 $gs = implode('|', $groups);
124 $gs = '<<>>' ; // Impossible to match
126 $sql_extra = sprintf("
127 AND ( `allow_cid` = '' OR `allow_cid` REGEXP '<%d>' )
128 AND ( `deny_cid` = '' OR NOT `deny_cid` REGEXP '<%d>' )
129 AND ( `allow_gid` = '' OR `allow_gid` REGEXP '%s' )
130 AND ( `deny_gid` = '' OR NOT `deny_gid` REGEXP '%s')
132 intval($contact['id']),
133 intval($contact['id']),
144 $date_field = "`changed`";
145 $sql_order = "`item`.`parent` ".$sort.", `item`.`created` ASC";
147 if(! strlen($last_update))
148 $last_update = 'now -30 days';
150 if(isset($category)) {
151 $sql_post_table = sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
152 dbesc(protect_sprintf($category)), intval(TERM_OBJ_POST), intval(TERM_CATEGORY), intval($owner_id));
153 //$sql_extra .= file_tag_file_query('item',$category,'category');
158 $sql_extra .= " AND `contact`.`self` = 1 ";
161 $check_date = datetime_convert('UTC','UTC',$last_update,'Y-m-d H:i:s');
163 // AND ( `item`.`edited` > '%s' OR `item`.`changed` > '%s' )
164 // dbesc($check_date),
166 $r = q("SELECT STRAIGHT_JOIN `item`.*, `item`.`id` AS `item_id`,
167 `contact`.`name`, `contact`.`network`, `contact`.`photo`, `contact`.`url`,
168 `contact`.`name-date`, `contact`.`uri-date`, `contact`.`avatar-date`,
169 `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
170 `contact`.`id` AS `contact-id`, `contact`.`uid` AS `contact-uid`,
171 `sign`.`signed_text`, `sign`.`signature`, `sign`.`signer`
172 FROM `item` $sql_post_table
173 INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
174 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
175 LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id`
176 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`parent` != 0
177 AND ((`item`.`wall` = 1) $visibility) AND `item`.$date_field > '%s'
179 ORDER BY $sql_order LIMIT 0, 300",
185 // Will check further below if this actually returned results.
186 // We will provide an empty feed if that is the case.
190 $doc = new DOMDocument('1.0', 'utf-8');
191 $doc->formatOutput = true;
193 $alternatelink = $owner['url'];
196 $alternatelink .= "/category/".$category;
199 $author = "dfrn:owner";
203 $root = dfrn_add_header($doc, $owner, $author, $alternatelink, true);
205 // This hook can't work anymore
206 // call_hooks('atom_feed', $atom);
208 if(! count($items)) {
209 $atom = trim($doc->saveXML());
211 call_hooks('atom_feed_end', $atom);
216 foreach($items as $item) {
218 // prevent private email from leaking.
219 if($item['network'] === NETWORK_MAIL)
222 // public feeds get html, our own nodes use bbcode
226 // catch any email that's in a public conversation and make sure it doesn't leak
234 $entry = dfrn_entry($doc, $type, $item, $owner, true);
235 $root->appendChild($entry);
239 $atom = trim($doc->saveXML());
241 call_hooks('atom_feed_end', $atom);
247 * @brief Create XML text for DFRN mails
249 * @param array $item message elements
250 * @param array $owner Owner record
252 * @return string DFRN mail
254 function dfrn_mail($item, $owner) {
255 $doc = new DOMDocument('1.0', 'utf-8');
256 $doc->formatOutput = true;
258 $root = dfrn_add_header($doc, $owner, "dfrn:owner", "", false);
260 $mail = $doc->createElement("dfrn:mail");
261 $sender = $doc->createElement("dfrn:sender");
263 xml_add_element($doc, $sender, "dfrn:name", $owner['name']);
264 xml_add_element($doc, $sender, "dfrn:uri", $owner['url']);
265 xml_add_element($doc, $sender, "dfrn:avatar", $owner['thumb']);
267 $mail->appendChild($sender);
269 xml_add_element($doc, $mail, "dfrn:id", $item['uri']);
270 xml_add_element($doc, $mail, "dfrn:in-reply-to", $item['parent-uri']);
271 xml_add_element($doc, $mail, "dfrn:sentdate", datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , ATOM_TIME));
272 xml_add_element($doc, $mail, "dfrn:subject", $item['title']);
273 xml_add_element($doc, $mail, "dfrn:content", $item['body']);
275 $root->appendChild($mail);
277 return(trim($doc->saveXML()));
281 * @brief Create XML text for DFRN friend suggestions
283 * @param array $item suggestion elements
284 * @param array $owner Owner record
286 * @return string DFRN suggestions
288 function dfrn_fsuggest($item, $owner) {
289 $doc = new DOMDocument('1.0', 'utf-8');
290 $doc->formatOutput = true;
292 $root = dfrn_add_header($doc, $owner, "dfrn:owner", "", false);
294 $suggest = $doc->createElement("dfrn:suggest");
296 xml_add_element($doc, $suggest, "dfrn:url", $item['url']);
297 xml_add_element($doc, $suggest, "dfrn:name", $item['name']);
298 xml_add_element($doc, $suggest, "dfrn:photo", $item['photo']);
299 xml_add_element($doc, $suggest, "dfrn:request", $item['request']);
300 xml_add_element($doc, $suggest, "dfrn:note", $item['note']);
302 $root->appendChild($suggest);
304 return(trim($doc->saveXML()));
308 * @brief Create XML text for DFRN relocations
310 * @param array $owner Owner record
311 * @param int $uid User ID
313 * @return string DFRN relocations
315 function dfrn_relocate($owner, $uid) {
319 /* get site pubkey. this could be a new installation with no site keys*/
320 $pubkey = get_config('system','site_pubkey');
322 $res = new_keypair(1024);
323 set_config('system','site_prvkey', $res['prvkey']);
324 set_config('system','site_pubkey', $res['pubkey']);
327 $rp = q("SELECT `resource-id` , `scale`, type FROM `photo`
328 WHERE `profile` = 1 AND `uid` = %d ORDER BY scale;", $uid);
330 $ext = Photo::supportedTypes();
332 $photos[$p['scale']] = $a->get_baseurl().'/photo/'.$p['resource-id'].'-'.$p['scale'].'.'.$ext[$p['type']];
336 $doc = new DOMDocument('1.0', 'utf-8');
337 $doc->formatOutput = true;
339 $root = dfrn_add_header($doc, $owner, "dfrn:owner", "", false);
341 $relocate = $doc->createElement("dfrn:relocate");
343 xml_add_element($doc, $relocate, "dfrn:url", $owner['url']);
344 xml_add_element($doc, $relocate, "dfrn:name", $owner['name']);
345 xml_add_element($doc, $relocate, "dfrn:photo", $photos[4]);
346 xml_add_element($doc, $relocate, "dfrn:thumb", $photos[5]);
347 xml_add_element($doc, $relocate, "dfrn:micro", $photos[6]);
348 xml_add_element($doc, $relocate, "dfrn:request", $owner['request']);
349 xml_add_element($doc, $relocate, "dfrn:confirm", $owner['confirm']);
350 xml_add_element($doc, $relocate, "dfrn:notify", $owner['notify']);
351 xml_add_element($doc, $relocate, "dfrn:poll", $owner['poll']);
352 xml_add_element($doc, $relocate, "dfrn:sitepubkey", get_config('system','site_pubkey'));
354 $root->appendChild($relocate);
356 return(trim($doc->saveXML()));
360 * @brief Adds the header elements for the DFRN protocol
362 * @param object $doc XML document
363 * @param array $owner Owner record
364 * @param string $authorelement Element name for the author
365 * @param string $alternatelink link to profile or category
366 * @param bool $public Is it a header for public posts?
368 * @return object XML root object
370 function dfrn_add_header($doc, $owner, $authorelement, $alternatelink = "", $public = false) {
373 if ($alternatelink == "")
374 $alternatelink = $owner['url'];
376 $root = $doc->createElementNS(NS_ATOM, 'feed');
377 $doc->appendChild($root);
379 $root->setAttribute("xmlns:thr", NS_THR);
380 $root->setAttribute("xmlns:at", "http://purl.org/atompub/tombstones/1.0");
381 $root->setAttribute("xmlns:media", NS_MEDIA);
382 $root->setAttribute("xmlns:dfrn", "http://purl.org/macgirvin/dfrn/1.0");
383 $root->setAttribute("xmlns:activity", NS_ACTIVITY);
384 $root->setAttribute("xmlns:georss", NS_GEORSS);
385 $root->setAttribute("xmlns:poco", NS_POCO);
386 $root->setAttribute("xmlns:ostatus", NS_OSTATUS);
387 $root->setAttribute("xmlns:statusnet", NS_STATUSNET);
389 xml_add_element($doc, $root, "id", $a->get_baseurl()."/profile/".$owner["nick"]);
390 xml_add_element($doc, $root, "title", $owner["name"]);
392 $attributes = array("uri" => "https://friendi.ca", "version" => FRIENDICA_VERSION."-".DB_UPDATE_VERSION);
393 xml_add_element($doc, $root, "generator", FRIENDICA_PLATFORM, $attributes);
395 $attributes = array("rel" => "license", "href" => "http://creativecommons.org/licenses/by/3.0/");
396 xml_add_element($doc, $root, "link", "", $attributes);
398 $attributes = array("rel" => "alternate", "type" => "text/html", "href" => $alternatelink);
399 xml_add_element($doc, $root, "link", "", $attributes);
401 ostatus_hublinks($doc, $root);
404 $attributes = array("rel" => "salmon", "href" => $a->get_baseurl()."/salmon/".$owner["nick"]);
405 xml_add_element($doc, $root, "link", "", $attributes);
407 $attributes = array("rel" => "http://salmon-protocol.org/ns/salmon-replies", "href" => $a->get_baseurl()."/salmon/".$owner["nick"]);
408 xml_add_element($doc, $root, "link", "", $attributes);
410 $attributes = array("rel" => "http://salmon-protocol.org/ns/salmon-mention", "href" => $a->get_baseurl()."/salmon/".$owner["nick"]);
411 xml_add_element($doc, $root, "link", "", $attributes);
414 if ($owner['page-flags'] == PAGE_COMMUNITY)
415 xml_add_element($doc, $root, "dfrn:community", 1);
417 xml_add_element($doc, $root, "updated", datetime_convert("UTC", "UTC", "now", ATOM_TIME));
419 $author = dfrn_add_author($doc, $owner, $authorelement);
420 $root->appendChild($author);
426 * @brief Adds the author element in the header for the DFRN protocol
428 * @param object $doc XML document
429 * @param array $owner Owner record
430 * @param string $authorelement Element name for the author
432 * @return object XML author object
434 function dfrn_add_author($doc, $owner, $authorelement) {
437 $author = $doc->createElement($authorelement);
439 $namdate = datetime_convert('UTC', 'UTC', $owner['name-date'].'+00:00' , ATOM_TIME);
440 $uridate = datetime_convert('UTC', 'UTC', $owner['uri-date'].'+00:00', ATOM_TIME);
441 $picdate = datetime_convert('UTC', 'UTC', $owner['avatar-date'].'+00:00', ATOM_TIME);
443 $attributes = array("dfrn:updated" => $namdate);
444 xml_add_element($doc, $author, "name", $owner["name"], $attributes);
446 $attributes = array("dfrn:updated" => $namdate);
447 xml_add_element($doc, $author, "uri", $a->get_baseurl().'/profile/'.$owner["nickname"], $attributes);
449 $attributes = array("rel" => "photo", "type" => "image/jpeg", "dfrn:updated" => $picdate,
450 "media:width" => 175, "media:height" => 175, "href" => $owner['photo']);
451 xml_add_element($doc, $author, "link", "", $attributes);
453 $attributes = array("rel" => "avatar", "type" => "image/jpeg", "dfrn:updated" => $picdate,
454 "media:width" => 175, "media:height" => 175, "href" => $owner['photo']);
455 xml_add_element($doc, $author, "link", "", $attributes);
457 $birthday = feed_birthday($owner['user_uid'], $owner['timezone']);
460 xml_add_element($doc, $author, "dfrn:birthday", $birthday);
466 * @brief Adds the author elements in the "entry" elements of the DFRN protocol
468 * @param object $doc XML document
469 * @param string $element Element name for the author
470 * @param string $contact_url Link of the contact
471 * @param array $items Item elements
473 * @return object XML author object
475 function dfrn_add_entry_author($doc, $element, $contact_url, $item) {
478 $contact = get_contact_details_by_url($contact_url, $item["uid"]);
480 $r = q("SELECT `profile`.`about`, `profile`.`name`, `profile`.`homepage`, `contact`.`nick`, `contact`.`location` FROM `profile`
481 INNER JOIN `contact` ON `contact`.`uid` = `profile`.`uid`
482 INNER JOIN `user` ON `user`.`uid` = `profile`.`uid`
483 WHERE `contact`.`self` AND `profile`.`is-default` AND NOT `user`.`hidewall` AND `contact`.`nurl`='%s'",
484 dbesc(normalise_link($contact_url)));
488 $author = $doc->createElement($element);
489 xml_add_element($doc, $author, "name", $contact["name"]);
490 xml_add_element($doc, $author, "uri", $contact["url"]);
493 /// - Check real image type and image size
494 /// - Check which of these boths elements we really use
497 "type" => "image/jpeg",
499 "media:height" => 80,
500 "href" => $contact["photo"]);
501 xml_add_element($doc, $author, "link", "", $attributes);
505 "type" => "image/jpeg",
507 "media:height" => 80,
508 "href" => $contact["photo"]);
509 xml_add_element($doc, $author, "link", "", $attributes);
511 // Only show contact details when it is a user from our system and we are allowed to
513 xml_add_element($doc, $author, "poco:preferredUsername", $profile["nick"]);
514 xml_add_element($doc, $author, "poco:displayName", $profile["name"]);
515 xml_add_element($doc, $author, "poco:note", $profile["about"]);
517 if (trim($contact["location"]) != "") {
518 $element = $doc->createElement("poco:address");
519 xml_add_element($doc, $element, "poco:formatted", $profile["location"]);
520 $author->appendChild($element);
523 if (trim($profile["homepage"]) != "") {
524 $urls = $doc->createElement("poco:urls");
525 xml_add_element($doc, $urls, "poco:type", "homepage");
526 xml_add_element($doc, $urls, "poco:value", $profile["homepage"]);
527 xml_add_element($doc, $urls, "poco:primary", "true");
528 $author->appendChild($urls);
536 * @brief Adds the activity elements
538 * @param object $doc XML document
539 * @param string $element Element name for the activity
540 * @param string $activity activity value
542 * @return object XML activity object
544 function dfrn_create_activity($doc, $element, $activity) {
547 $entry = $doc->createElement($element);
549 $r = parse_xml_string($activity, false);
553 xml_add_element($doc, $entry, "activity:object-type", $r->type);
555 xml_add_element($doc, $entry, "id", $r->id);
557 xml_add_element($doc, $entry, "title", $r->title);
559 if(substr($r->link,0,1) === '<') {
560 if(strstr($r->link,'&') && (! strstr($r->link,'&')))
561 $r->link = str_replace('&','&', $r->link);
563 $r->link = preg_replace('/\<link(.*?)\"\>/','<link$1"/>',$r->link);
565 $data = parse_xml_string($r->link, false);
566 foreach ($data->attributes() AS $parameter => $value)
567 $attributes[$parameter] = $value;
569 $attributes = array("rel" => "alternate", "type" => "text/html", "href" => $r->link);
571 xml_add_element($doc, $entry, "link", "", $attributes);
574 xml_add_element($doc, $entry, "content", bbcode($r->content), array("type" => "html"));
583 * @brief Adds the elements for attachments
585 * @param object $doc XML document
586 * @param object $root XML root
587 * @param array $item Item element
589 * @return object XML attachment object
591 function dfrn_get_attachment($doc, $root, $item) {
592 $arr = explode('[/attach],',$item['attach']);
594 foreach($arr as $r) {
596 $cnt = preg_match('|\[attach\]href=\"(.*?)\" length=\"(.*?)\" type=\"(.*?)\" title=\"(.*?)\"|',$r,$matches);
598 $attributes = array("rel" => "enclosure",
599 "href" => $matches[1],
600 "type" => $matches[3]);
602 if(intval($matches[2]))
603 $attributes["length"] = intval($matches[2]);
605 if(trim($matches[4]) != "")
606 $attributes["title"] = trim($matches[4]);
608 xml_add_element($doc, $root, "link", "", $attributes);
615 * @brief Adds the "entry" elements for the DFRN protocol
617 * @param object $doc XML document
618 * @param string $type "text" or "html"
619 * @param array $item Item element
620 * @param array $owner Owner record
621 * @param bool $comment Trigger the sending of the "comment" element
624 * @return object XML entry object
626 function dfrn_entry($doc, $type, $item, $owner, $comment = false, $cid = 0) {
629 $mentioned = array();
634 if($item['deleted']) {
635 $attributes = array("ref" => $item['uri'], "when" => datetime_convert('UTC','UTC',$item['edited'] . '+00:00',ATOM_TIME));
636 return xml_create_element($doc, "at:deleted-entry", "", $attributes);
639 $entry = $doc->createElement("entry");
641 if($item['allow_cid'] || $item['allow_gid'] || $item['deny_cid'] || $item['deny_gid'])
642 $body = fix_private_photos($item['body'],$owner['uid'],$item,$cid);
644 $body = $item['body'];
646 if ($type == 'html') {
649 if ($item['title'] != "")
650 $htmlbody = "[b]".$item['title']."[/b]\n\n".$htmlbody;
652 $htmlbody = bbcode($htmlbody, false, false, 7);
655 $author = dfrn_add_entry_author($doc, "author", $item["author-link"], $item);
656 $entry->appendChild($author);
658 $dfrnowner = dfrn_add_entry_author($doc, "dfrn:owner", $item["owner-link"], $item);
659 $entry->appendChild($dfrnowner);
661 if(($item['parent'] != $item['id']) || ($item['parent-uri'] !== $item['uri']) || (($item['thr-parent'] !== '') && ($item['thr-parent'] !== $item['uri']))) {
662 $parent = q("SELECT `guid` FROM `item` WHERE `id` = %d", intval($item["parent"]));
663 $parent_item = (($item['thr-parent']) ? $item['thr-parent'] : $item['parent-uri']);
664 $attributes = array("ref" => $parent_item, "type" => "text/html", "href" => $a->get_baseurl().'/display/'.$parent[0]['guid']);
665 xml_add_element($doc, $entry, "thr:in-reply-to", "", $attributes);
668 xml_add_element($doc, $entry, "id", $item["uri"]);
669 xml_add_element($doc, $entry, "title", $item["title"]);
671 xml_add_element($doc, $entry, "published", datetime_convert("UTC","UTC",$item["created"]."+00:00",ATOM_TIME));
672 xml_add_element($doc, $entry, "updated", datetime_convert("UTC","UTC",$item["edited"]."+00:00",ATOM_TIME));
674 xml_add_element($doc, $entry, "dfrn:env", base64url_encode($body, true));
675 xml_add_element($doc, $entry, "content", (($type === 'html') ? $htmlbody : $body), array("type" => $type));
677 xml_add_element($doc, $entry, "link", "", array("rel" => "alternate", "type" => "text/html",
678 "href" => $a->get_baseurl()."/display/".$item["guid"]));
681 xml_add_element($doc, $entry, "dfrn:comment-allow", intval($item['last-child']));
683 if($item['location'])
684 xml_add_element($doc, $entry, "dfrn:location", $item['location']);
687 xml_add_element($doc, $entry, "georss:point", $item['coord']);
689 if(($item['private']) || strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid']))
690 xml_add_element($doc, $entry, "dfrn:private", (($item['private']) ? $item['private'] : 1));
693 xml_add_element($doc, $entry, "dfrn:extid", $item['extid']);
695 if($item['bookmark'])
696 xml_add_element($doc, $entry, "dfrn:bookmark", "true");
699 xml_add_element($doc, $entry, "statusnet:notice_info", "", array("local_id" => $item['id'], "source" => $item['app']));
701 xml_add_element($doc, $entry, "dfrn:diaspora_guid", $item["guid"]);
703 if($item['signed_text']) {
704 $sign = base64_encode(json_encode(array('signed_text' => $item['signed_text'],'signature' => $item['signature'],'signer' => $item['signer'])));
705 xml_add_element($doc, $entry, "dfrn:diaspora_signature", $sign);
708 xml_add_element($doc, $entry, "activity:verb", construct_verb($item));
710 $actobj = dfrn_create_activity($doc, "activity:object", $item['object']);
712 $entry->appendChild($actobj);
714 $actarg = dfrn_create_activity($doc, "activity:target", $item['target']);
716 $entry->appendChild($actarg);
718 $tags = item_getfeedtags($item);
722 if (($type != 'html') OR ($t[0] != "@"))
723 xml_add_element($doc, $entry, "category", "", array("scheme" => "X-DFRN:".$t[0].":".$t[1], "term" => $t[2]));
729 $mentioned[$t[1]] = $t[1];
731 foreach ($mentioned AS $mention) {
732 $r = q("SELECT `forum`, `prv` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s'",
733 intval($owner["uid"]),
734 dbesc(normalise_link($mention)));
735 if ($r[0]["forum"] OR $r[0]["prv"])
736 xml_add_element($doc, $entry, "link", "", array("rel" => "mentioned",
737 "ostatus:object-type" => ACTIVITY_OBJ_GROUP,
738 "href" => $mention));
740 xml_add_element($doc, $entry, "link", "", array("rel" => "mentioned",
741 "ostatus:object-type" => ACTIVITY_OBJ_PERSON,
742 "href" => $mention));
745 dfrn_get_attachment($doc, $entry, $item);