]> git.mxchange.org Git - friendica.git/commitdiff
give orphans a second chance, linkify naked links
authorFriendika <info@friendika.com>
Fri, 12 Nov 2010 04:32:20 +0000 (20:32 -0800)
committerFriendika <info@friendika.com>
Fri, 12 Nov 2010 04:32:20 +0000 (20:32 -0800)
include/bbcode.php
include/items.php
include/poller.php
mod/pubsub.php

index 961494b167ee7aba5953f020347d0b88c8ccbe4f..52ca86bc1f3c7584f7437a8a62d937f217453127 100644 (file)
@@ -17,10 +17,15 @@ function bbcode($Text) {
        $MAILSearchString = $URLSearchString . " a-zA-Z0-9\.@";
 
        // Perform URL Search
+
+       $Text = preg_replace("/[^\]\=](http\:\/\/[a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'\%]*)/", ' <a href="$1" >$1</a>', $Text);
+       $Text = preg_replace("/[^\]\=](https\:\/\/[a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'\%]*)/", ' <a href="$1" >$1</a>', $Text);
+
        $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/", '<a href="$1" >$1</a>', $Text);
        $Text = preg_replace("(\[url\=([$URLSearchString]*)\](.+?)\[/url\])", '<a href="$1" >$2</a>', $Text);
        //$Text = preg_replace("(\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[/url\])", '<a href="$1" target="_blank">$2</a>', $Text);
 
+
        // Perform MAIL Search
        $Text = preg_replace("(\[mail\]([$MAILSearchString]*)\[/mail\])", '<a href="mailto:$1">$1</a>', $Text);
        $Text = preg_replace("/\[mail\=([$MAILSearchString]*)\](.+?)\[\/mail\]/", '<a href="mailto:$1">$2</a>', $Text);
index 65041418bca3526223b10fbda31957309e68f28c..584236f78001f41c0abcc04415f6ae69525319be 100644 (file)
@@ -546,9 +546,41 @@ function item_store($arr) {
        $arr['object']        = ((x($arr,'object'))        ? trim($arr['object'])                : '');
        $arr['target-type']   = ((x($arr,'target-type'))   ? notags(trim($arr['target-type']))   : '');
        $arr['target']        = ((x($arr,'target'))        ? trim($arr['target'])                : '');
+       $arr['allow_cid']     = ((x($arr,'allow_cid'))     ? trim($arr['allow_cid'])             : '');
+       $arr['allow_gid']     = ((x($arr,'allow_gid'))     ? trim($arr['allow_gid'])             : '');
+       $arr['deny_cid']      = ((x($arr,'deny_cid'))      ? trim($arr['deny_cid'])              : '');
+       $arr['deny_gid']      = ((x($arr,'deny_gid'))      ? trim($arr['deny_gid'])              : '');
 
-       $parent_id = 0;
-       $parent_missing = false;
+
+
+       if($arr['parent-uri'] === $arr['uri']) {
+               $parent_id = 0;
+               $allow_cid = $arr['allow_cid'];
+               $allow_gid = $arr['allow_gid'];
+               $deny_cid  = $arr['deny_cid'];
+               $deny_gid  = $arr['deny_gid'];
+       }
+       else { 
+
+               // find the parent and snarf the item id and ACL's
+
+               $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+                       dbesc($arr['parent-uri']),
+                       intval($arr['uid'])
+               );
+
+               if(count($r)) {
+                       $parent_id = $r[0]['id'];
+                       $allow_cid = $r[0]['allow_cid'];
+                       $allow_gid = $r[0]['allow_gid'];
+                       $deny_cid  = $r[0]['deny_cid'];
+                       $deny_gid  = $r[0]['deny_gid'];
+               }
+               else {
+                       logger('item_store: item parent was not found - ignoring item');
+                       return 0;
+               }
+       }
 
        dbesc_array($arr);
 
@@ -560,23 +592,7 @@ function item_store($arr) {
                        . implode("', '", array_values($arr)) 
                        . "')" );
 
-       // find the parent and snarf the item id and ACL's
-
-       $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
-               dbesc($arr['parent-uri']),
-               intval($arr['uid'])
-       );
-
-       if(count($r)) {
-               $parent_id = $r[0]['id'];
-               $allow_cid = $r[0]['allow_cid'];
-               $allow_gid = $r[0]['allow_gid'];
-               $deny_cid  = $r[0]['deny_cid'];
-               $deny_gid  = $r[0]['deny_gid'];
-       }
-       else {
-               $parent_missing = true;
-       }
+       // find the item we just created
 
        $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
                $arr['uri'],           // already dbesc'd
@@ -586,23 +602,15 @@ function item_store($arr) {
                $current_post = $r[0]['id'];
                logger('item_store: created item ' . $current_post);
        }
-       else
-               return 0;
-
-       if($parent_missing) {
-
-               logger('item_store: item parent was not found - ignoring item');
-
-               // perhaps the parent was deleted, but in any case, this thread is dead
-               // and unfortunately our brand new item now has to be destroyed
-
-               q("DELETE FROM `item` WHERE `id` = %d LIMIT 1",
-                       intval($current_post)
-               );
+       else {
+               logger('item_store: could not locate created item');
                return 0;
        }
 
-       // Set parent id - all of the parent's ACL's are also inherited by this post
+       if($arr['parent-uri'] === $arr['uri'])
+               $parent_id = $current_post;
+       // Set parent id - and also make sure to inherit the parent's ACL's.
 
        $r = q("UPDATE `item` SET `parent` = %d, `allow_cid` = '%s', `allow_gid` = '%s',
                `deny_cid` = '%s', `deny_gid` = '%s' WHERE `id` = %d LIMIT 1",
index f214625a19fa1c575a4ae21c47775756ba5adda3..3d19d003b1939fbbdbb8613f7a8723dd070d94d3 100644 (file)
 
                consume_feed($xml,$importer,$contact,$hub);
 
+               // do it twice. Ensures that children of parents which may be later in the stream aren't tossed
+
+               consume_feed($xml,$importer,$contact,$hub);
+
+
                if((strlen($hub)) && (($contact['rel'] == REL_BUD) || (($contact['network'] === 'stat') && (! $contact['readonly'])))) {
                        logger('poller: subscribing to hub(s) : ' . $hub . ' contact name : ' . $contact['name'] . ' local user : ' . $importer['name']);
                        $hubs = explode(',', $hub);
index 0f8d7fdc6686dac8250afe5c7f20d7da7876fd6d..c55100c96a3a5b54cc323d645012e72a3e9a0539 100644 (file)
@@ -115,6 +115,10 @@ function pubsub_post(&$a) {
 
        consume_feed($xml,$importer,$contact,$feedhub,1);
 
+       // do it a second time so that any children find their parents.
+
+       consume_feed($xml,$importer,$contact,$feedhub,1);
+
        hub_post_return();
 
 }