]> git.mxchange.org Git - friendica.git/commitdiff
Port friendica/friendica#1478229abc6c5adc265559b5489cc2eb23358994
authorDomovoy <domovoy@errlock.org>
Mon, 10 Sep 2012 08:14:30 +0000 (10:14 +0200)
committerDomovoy <domovoy@errlock.org>
Mon, 10 Sep 2012 08:14:30 +0000 (10:14 +0200)
object/Item.php

index 314f95eaff90f51d89942f9490ed27aa37c1ff26..757e0220ab77e463d17f2885f3a4d323154792e9 100644 (file)
@@ -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;
+       }
 }
 ?>