]> git.mxchange.org Git - friendica.git/commitdiff
Better wall to wall detection (fallback on checking if we have a @ tag)
authorDomovoy <domovoy@errlock.org>
Fri, 24 Aug 2012 02:36:03 +0000 (04:36 +0200)
committerDomovoy <domovoy@errlock.org>
Fri, 24 Aug 2012 02:36:03 +0000 (04:36 +0200)
include/conversation.php

index 0b091571f1cc6f25ffdd154b6fccf285d9f161db..56446d96dfb44e6325b0002ca19333a1649c6d85 100644 (file)
@@ -490,6 +490,41 @@ function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $pr
                                                        $owner_url = zrl($owner_url);
                                        }
                                }
+                               if($commentww != 'ww') {
+                                       // Fallback, check if can find a @ tag
+                                       $tags = $item['tag'];
+                                       if(strpos($tags, '@[url') !== FALSE) {
+                                               // We have at least one @ tag
+                                               $template = $wallwall_template;
+                                               $commentww = 'ww';
+                                               
+                                               $matches = array();
+                                               preg_match_all('/\@\[url=([^\]]+)\]([^\[]+)\[\/url\]/', $tags, $matches, PREG_SET_ORDER);
+
+                                               $r = null;
+                                               foreach($matches as $wall) {
+                                                       $uri = $wall[1];
+                                                       $r = q("SELECT `url`,`name`,`photo` FROM `contact` WHERE `url`='%s' LIMIT 1",
+                                                               dbesc($uri)
+                                                       );
+
+                                                       if(count($r)) {
+                                                               $owner_url = zrl($r[0]['url']);
+                                                               $owner_name = $r[0]['name'];
+                                                               $owner_photo = $r[0]['photo'];
+                                                               break;
+                                                       }
+                                               }
+
+                                               if($commentww != 'ww') {
+                                                       // We found no matching contact in the database, just do the best we can (we'll only miss the photo)
+                                                       $this->owner_url = zrl($matches[0][1]);
+                                                       $this->owner_name = $matches[0][2];
+                                                       // Use the nosign
+                                                       $this->owner_photo = $a->get_baseurl .'/images/nosign.jpg';
+                                               }
+                                       }
+                               }
                        }
                        if($profile_owner == local_user()) {
                                $isstarred = (($item['starred']) ? "starred" : "unstarred");