From 82d779a33b287699cb1e543d384445422e50710f Mon Sep 17 00:00:00 2001 From: Domovoy Date: Sun, 12 Aug 2012 17:46:02 +0200 Subject: [PATCH 1/2] Conversation and Item now handles (dis)like as they should --- include/conversation.php | 9 +++++++++ object/Conversation.php | 12 ++++++++++++ object/Item.php | 21 +++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/include/conversation.php b/include/conversation.php index 19ca0dc4cf..2c1c274695 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -862,9 +862,18 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $threads = array(); foreach($items as $item) { + // Can we put this after the visibility check? like_puller($a,$item,$alike,'like'); like_puller($a,$item,$dlike,'dislike'); + // Only add what is visible + if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) { + continue; + } + if($item['verb'] === ACTIVITY_LIKE || $item['verb'] === ACTIVITY_DISLIKE) { + continue; + } + if($item['id'] == $item['parent']) { $item_object = new Item($item); $conv->add_thread($item_object); diff --git a/object/Conversation.php b/object/Conversation.php index d8d14589d2..b9b0cb74c2 100644 --- a/object/Conversation.php +++ b/object/Conversation.php @@ -91,6 +91,18 @@ class Conversation extends BaseObject { logger('[WARN] Conversation::add_thread : Thread already exists ('. $item->get_id() .').', LOGGER_DEBUG); return false; } + + /* + * Only add will be displayed + */ + if($item->get_data_value('network') === NETWORK_MAIL && local_user() != $item->get_data_value('uid')) { + logger('[WARN] Conversation::add_thread : Thread is a mail ('. $item->get_id() .').', LOGGER_DEBUG); + return false; + } + if($item->get_data_value('verb') === ACTIVITY_LIKE || $item->get_data_value('verb') === ACTIVITY_DISLIKE) { + logger('[WARN] Conversation::add_thread : Thread is a (dis)like ('. $item->get_id() .').', LOGGER_DEBUG); + return false; + } $item->set_conversation($this); $this->threads[] = $item; return end($this->threads); diff --git a/object/Item.php b/object/Item.php index 0639e4db71..7f883b41d5 100644 --- a/object/Item.php +++ b/object/Item.php @@ -42,6 +42,15 @@ class Item extends BaseObject { // Prepare the children if(count($data['children'])) { foreach($data['children'] as $item) { + /* + * Only add will be displayed + */ + if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) { + continue; + } + if($item['verb'] === ACTIVITY_LIKE || $item['verb'] === ACTIVITY_DISLIKE) { + continue; + } $child = new Item($item); $this->add_child($child); } @@ -270,6 +279,18 @@ class Item extends BaseObject { logger('[WARN] Item::add_child : Item already exists ('. $item->get_id() .').', LOGGER_DEBUG); return false; } + /* + * Only add will be displayed + */ + if($item->get_data_value('network') === NETWORK_MAIL && local_user() != $item->get_data_value('uid')) { + logger('[WARN] Item::add_child : Item is a mail ('. $item->get_id() .').', LOGGER_DEBUG); + return false; + } + if($item->get_data_value('verb') === ACTIVITY_LIKE || $item->get_data_value('verb') === ACTIVITY_DISLIKE) { + logger('[WARN] Item::add_child : Item is a (dis)like ('. $item->get_id() .').', LOGGER_DEBUG); + return false; + } + $item->set_parent($this); $this->children[] = $item; return end($this->children); From cc4361fddf6c77839a7e252a3bcbf2ea48a86f90 Mon Sep 17 00:00:00 2001 From: Domovoy Date: Sun, 12 Aug 2012 20:11:14 +0200 Subject: [PATCH 2/2] Problem with comment box, debug. --- object/Item.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/object/Item.php b/object/Item.php index 7f883b41d5..2505b8aee0 100644 --- a/object/Item.php +++ b/object/Item.php @@ -477,6 +477,8 @@ class Item extends BaseObject { $ww = 'ww'; if($conv->is_writeable() && $this->is_writeable()) { + logger('[DEBUG] Item::get_comment_box : Comment box is visible.', LOGGER_DEBUG); + $a = $this->get_app(); $qc = $qcomment = null; @@ -514,6 +516,9 @@ 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_writeable() ? 'yes' : 'no') .' Item: '. ($this->is_writeable() ? 'yes' : 'no'), LOGGER_DEBUG); + } return $comment_box; }