]> git.mxchange.org Git - friendica.git/blobdiff - include/items.php
typo
[friendica.git] / include / items.php
index 4c0e8312cc3c2b863057d3f2ba750ab7050493dc..746e3b2944fc2769ec5090afc83042fe091c0238 100644 (file)
@@ -1,8 +1,9 @@
 <?php
 
-require_once('bbcode.php');
-require_once('oembed.php');
+require_once('include/bbcode.php');
+require_once('include/oembed.php');
 require_once('include/salmon.php');
+require_once('include/crypto.php');
 
 function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) {
 
@@ -112,7 +113,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
 
        $items = $r;
 
-       $feed_template = get_markup_template('atom_feed.tpl');
+       $feed_template = get_markup_template(($dfrn_id) ? 'atom_feed_dfrn.tpl' : 'atom_feed.tpl');
 
        $atom = '';
 
@@ -153,6 +154,9 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
 
                if($dfrn_id === '') {
                        $type = 'html';
+                       // catch any email that's in a public conversation and make sure it doesn't leak
+                       if($item['private'])
+                               continue;
                }
                else {
                        $type = 'text';
@@ -691,6 +695,7 @@ function item_store($arr,$force_parent = false) {
        $arr['tag']           = ((x($arr,'tag'))           ? notags(trim($arr['tag']))           : '');
        $arr['attach']        = ((x($arr,'attach'))        ? notags(trim($arr['attach']))        : '');
        $arr['app']           = ((x($arr,'app'))           ? notags(trim($arr['app']))           : '');
+       $arr['guid']          = ((x($arr,'guid'))          ? notags(trim($arr['guid']))          : get_guid());
 
        if($arr['parent-uri'] === $arr['uri']) {
                $parent_id = 0;
@@ -718,6 +723,13 @@ function item_store($arr,$force_parent = false) {
                        if($r[0]['uri'] != $r[0]['parent-uri']) {
                                $arr['thr-parent'] = $arr['parent-uri'];
                                $arr['parent-uri'] = $r[0]['parent-uri'];
+                               $z = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `parent-uri` = '%s' AND `uid` = %d LIMIT 1",
+                                       dbesc($r[0]['parent-uri']),
+                                       dbesc($r[0]['parent-uri']),
+                                       intval($arr['uid'])
+                               );
+                               if($z && count($z))
+                                       $r = $z;
                        }
 
                        $parent_id      = $r[0]['id'];
@@ -747,6 +759,7 @@ function item_store($arr,$force_parent = false) {
                }
        }
 
+
        call_hooks('post_remote',$arr);
 
        dbesc_array($arr);
@@ -1026,7 +1039,9 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $secure_fee
        if(count($hubs))
                $hub = implode(',', $hubs);
 
-       $rawtags = $feed->get_feed_tags( SIMPLEPIE_NAMESPACE_ATOM_10, 'author');
+       $rawtags = $feed->get_feed_tags( NAMESPACE_DFRN, 'owner');
+       if(! $rawtags)
+               $rawtags = $feed->get_feed_tags( SIMPLEPIE_NAMESPACE_ATOM_10, 'author');
        if($rawtags) {
                $elems = $rawtags[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10];
                if($elems['name'][0]['attribs'][NAMESPACE_DFRN]['updated']) {
@@ -1621,7 +1636,7 @@ function atom_entry($item,$type,$author,$owner,$comment = false) {
        $o .= '<published>' . xmlify(datetime_convert('UTC','UTC',$item['created'] . '+00:00',ATOM_TIME)) . '</published>' . "\r\n";
        $o .= '<updated>' . xmlify(datetime_convert('UTC','UTC',$item['edited'] . '+00:00',ATOM_TIME)) . '</updated>' . "\r\n";
        $o .= '<dfrn:env>' . base64url_encode($body, true) . '</dfrn:env>' . "\r\n";
-       $o .= '<content type="' . $type . '" >' . xmlify(($type === 'html') ? bbcode($body) : $body) . '</content>' . "\r\n";
+       $o .= '<content type="' . $type . '" >' . xmlify((($type === 'html') ? bbcode($body) : $body)) . '</content>' . "\r\n";
        $o .= '<link rel="alternate" type="text/html" href="' . xmlify($a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id']) . '" />' . "\r\n";
        if($comment)
                $o .= '<dfrn:comment-allow>' . intval($item['last-child']) . '</dfrn:comment-allow>' . "\r\n";