From: Domovoy <domovoy@errlock.org>
Date: Sat, 18 Aug 2012 15:17:33 +0000 (+0200)
Subject: Checks done on topmost parent in local_delivery, closes #10
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=17f9fcaec960644d0168da769abd81ec774c56dd;p=friendica.git

Checks done on topmost parent in local_delivery, closes #10
---

diff --git a/include/items.php b/include/items.php
index 8de6f7cc8e..a2b0fe053c 100755
--- a/include/items.php
+++ b/include/items.php
@@ -2617,22 +2617,32 @@ function local_delivery($importer,$data) {
 			// Specifically, the recipient? 
 
 			$is_a_remote_comment = false;
-
-			// POSSIBLE CLEANUP --> Why select so many fields when only forum_mode and wall are used?
-			$r = q("select `item`.`id`, `item`.`uri`, `item`.`tag`, `item`.`forum_mode`,`item`.`origin`,`item`.`wall`, 
-				`contact`.`name`, `contact`.`url`, `contact`.`thumb` from `item` 
-				LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` 
-				WHERE `item`.`uri` = '%s' AND (`item`.`parent-uri` = '%s' or `item`.`thr-parent` = '%s')
-				AND `item`.`uid` = %d 
-				$sql_extra
+			$top_uri = $parent_uri;
+			
+			$r = q("select `item`.`parent-uri` from `item`
+				WHERE `item`.`uri` = '%s'
 				LIMIT 1",
-				dbesc($parent_uri),
-				dbesc($parent_uri),
-				dbesc($parent_uri),
-				intval($importer['importer_uid'])
+				dbesc($parent_uri)
 			);
-			if($r && count($r))
-				$is_a_remote_comment = true;			
+			if($r && count($r)) {
+				$top_uri = $r[0]['parent-uri'];
+
+				// POSSIBLE CLEANUP --> Why select so many fields when only forum_mode and wall are used?
+				$r = q("select `item`.`id`, `item`.`uri`, `item`.`tag`, `item`.`forum_mode`,`item`.`origin`,`item`.`wall`, 
+					`contact`.`name`, `contact`.`url`, `contact`.`thumb` from `item` 
+					LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` 
+					WHERE `item`.`uri` = '%s' AND (`item`.`parent-uri` = '%s' or `item`.`thr-parent` = '%s')
+					AND `item`.`uid` = %d 
+					$sql_extra
+					LIMIT 1",
+					dbesc($top_uri),
+					dbesc($top_uri),
+					dbesc($top_uri),
+					intval($importer['importer_uid'])
+				);
+				if($r && count($r))
+					$is_a_remote_comment = true;
+			}
 
 			// Does this have the characteristics of a community or private group comment?
 			// If it's a reply to a wall post on a community/prvgroup page it's a 
@@ -2936,7 +2946,7 @@ function local_delivery($importer,$data) {
 				if(!x($datarray['type']) || $datarray['type'] != 'activity') {
 
 					$myconv = q("SELECT `author-link`, `author-avatar`, `parent` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `parent` != 0 AND `deleted` = 0",
-						dbesc($parent_uri),
+						dbesc($top_uri),
 						intval($importer['importer_uid'])
 					);
 
diff --git a/object/Item.php b/object/Item.php
index 01e117ff78..bfd2db711a 100644
--- a/object/Item.php
+++ b/object/Item.php
@@ -396,7 +396,7 @@ class Item extends BaseObject {
 	 * 		_ false on failure
 	 */
 	public function get_data_value($name) {
-		if(!x($this->data, $name)) {
+		if(!isset($this->data[$name])) {
 			logger('[ERROR] Item::get_data_value : Item has no value name "'. $name .'".', LOGGER_DEBUG);
 			return false;
 		}
@@ -477,8 +477,6 @@ class Item extends BaseObject {
 			$ww = 'ww';
 
 		if($conv->is_writable() && $this->is_writable()) {
-			logger('[DEBUG] Item::get_comment_box : Comment box is visible.', LOGGER_DEBUG);
-			
 			$a = $this->get_app();
 			$qc = $qcomment =  null;
 
@@ -516,9 +514,6 @@ class Item extends BaseObject {
 				'$ww' => (($conv->get_mode() === 'network') ? $ww : '')
 			));
 		}
-		else {
-			logger('[DEBUG] Item::get_comment_box : Comment box is NOT visible. Conv: '. ($conv->is_writable() ? 'yes' : 'no') .' Item: '. ($this->is_writable() ? 'yes' : 'no'), LOGGER_DEBUG);
-		}
 
 		return $comment_box;
 	}