From 51bcd862d7031e91d1eabe7b906d4f50c09115b0 Mon Sep 17 00:00:00 2001 From: Domovoy Date: Mon, 10 Sep 2012 10:14:30 +0200 Subject: [PATCH] Port friendica/friendica#1478229abc6c5adc265559b5489cc2eb23358994 --- object/Item.php | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/object/Item.php b/object/Item.php index 314f95eaff..757e0220ab 100644 --- a/object/Item.php +++ b/object/Item.php @@ -28,6 +28,7 @@ class Item extends BaseObject { private $owner_name = ''; private $wall_to_wall = false; private $threaded = false; + private $visiting = false; public function __construct($data) { $a = $this->get_app(); @@ -35,6 +36,16 @@ class Item extends BaseObject { $this->data = $data; $this->set_template('wall'); $this->toplevel = ($this->get_id() == $this->get_data_value('parent')); + + if(is_array($_SESSION['remote'])) { + foreach($_SESSION['remote'] as $visitor) { + if($visitor['cid'] == $this->get_data_value('contact-id')) { + $this->visiting = true; + break; + } + } + } + $this->writable = ($this->get_data_value('writable') || $this->get_data_value('self')); $ssl_state = ((local_user()) ? true : false); @@ -96,16 +107,8 @@ class Item extends BaseObject { $edpost = array($a->get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit")); else $edpost = false; - if($this->get_data_value('uid') == local_user()) + if(($this->get_data_value('uid') == local_user()) || $this->is_visiting()) $dropping = true; - elseif(is_array($_SESSION['remote'])) { - foreach($_SESSION['remote'] as $visitor) { - if($visitor['cid'] == $this->get_data_value('contact-id')) { - $dropping = true; - break; - } - } - } $drop = array( 'dropping' => $dropping, @@ -451,6 +454,13 @@ class Item extends BaseObject { * Check if this is writable */ private function is_writable() { + $conv = $this->get_conversation(); + + if($conv) { + // This will allow us to comment on wall-to-wall items owned by our friends + // and community forums even if somebody else wrote the post. + return ($this->writable || ($this->is_visiting() && $conv->get_mode() == 'profile')); + } return $this->writable; } @@ -620,5 +630,9 @@ class Item extends BaseObject { private function get_owner_name() { return $this->owner_name; } + + private function is_visiting() { + return $this->visiting; + } } ?> -- 2.39.5