From f746e06a37801b9635e693da16a4d45c7c252318 Mon Sep 17 00:00:00 2001 From: Domovoy Date: Fri, 24 Aug 2012 05:21:08 +0200 Subject: [PATCH] wall to wall detection: fallback using @ tags, and check if one is a forum. --- object/Item.php | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/object/Item.php b/object/Item.php index a8676260c..120497b36 100644 --- a/object/Item.php +++ b/object/Item.php @@ -590,7 +590,33 @@ class Item extends BaseObject { } if(!$this->wall_to_wall) { - // Definitely not wall to wall + // Fallback, check if can find a @ tag + $tags = $this->get_data_value('tag'); + if(strpos($tags, '@[url') !== FALSE) { + // We have at least one @ tag + $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`,`forum` FROM `contact` WHERE `url`='%s' LIMIT 1", + dbesc($uri) + ); + + if(count($r) && (intval($r[0]['forum']) == 1)) { + $this->owner_url = zrl($r[0]['url']); + $this->owner_name = $r[0]['name']; + $this->owner_photo = $r[0]['photo']; + $this->wall_to_wall = true; + $this->set_template('wall2wall'); + break; + } + } + } + } + + if(!$this->wall_to_wall) { $this->set_template('wall'); $this->owner_url = ''; $this->owner_photo = '';