aboutsummaryrefslogtreecommitdiffstats
path: root/include/ConversationObject.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/ConversationObject.php')
-rw-r--r--include/ConversationObject.php54
1 files changed, 47 insertions, 7 deletions
diff --git a/include/ConversationObject.php b/include/ConversationObject.php
index 37633369e..30026e908 100644
--- a/include/ConversationObject.php
+++ b/include/ConversationObject.php
@@ -1,4 +1,5 @@
-<?php
+<?php /** @file */
+
if(class_exists('Conversation'))
return;
@@ -10,12 +11,14 @@ require_once('include/text.php');
/**
* A list of threads
*
- * We should think about making this a SPL Iterator
*/
+
class Conversation extends BaseObject {
private $threads = array();
private $mode = null;
+ private $observer = null;
private $writable = false;
+ private $commentable = false;
private $profile_owner = 0;
private $preview = false;
@@ -33,8 +36,8 @@ class Conversation extends BaseObject {
$a = $this->get_app();
- $observer = $a->get_observer();
- $ob_hash = (($observer) ? $observer['xchan_hash'] : '');
+ $this->observer = $a->get_observer();
+ $ob_hash = (($this->observer) ? $this->observer['xchan_hash'] : '');
switch($mode) {
case 'network':
@@ -46,7 +49,10 @@ class Conversation extends BaseObject {
$this->writable = perm_is_allowed($this->profile_owner,$ob_hash,'post_comments');
break;
case 'display':
- $this->profile_owner = $a->profile['uid'];
+ // in this mode we set profile_owner after initialisation (from conversation()) and then
+ // pull some trickery which allows us to re-invoke this function afterward
+ // it's an ugly hack so FIXME
+// $this->profile_owner = $a->profile['uid'];
$this->writable = perm_is_allowed($this->profile_owner,$ob_hash,'post_comments');
break;
case 'page':
@@ -75,6 +81,10 @@ class Conversation extends BaseObject {
return $this->writable;
}
+ public function is_commentable() {
+ return $this->commentable;
+ }
+
/**
* Check if page is a preview
*/
@@ -89,6 +99,18 @@ class Conversation extends BaseObject {
return $this->profile_owner;
}
+ public function set_profile_owner($uid) {
+ $this->profile_owner = $uid;
+ $mode = $this->get_mode();
+ $this->mode = null;
+ $this->set_mode($mode);
+ }
+
+ public function get_observer() {
+ return $this->observer;
+ }
+
+
/**
* Add a thread to the conversation
*
@@ -108,12 +130,30 @@ class Conversation extends BaseObject {
}
/*
- * Only add will be displayed
+ * Only add things that will be displayed
*/
- if(activity_match($item->get_data_value('verb'),ACTIVITY_LIKE) || activity_match($item->get_data_value('verb'),ACTIVITY_DISLIKE)) {
+
+ if(($item->get_data_value('id') != $item->get_data_value('parent')) && (activity_match($item->get_data_value('verb'),ACTIVITY_LIKE) || activity_match($item->get_data_value('verb'),ACTIVITY_DISLIKE))) {
return false;
}
+
+ if(local_user() && $item->get_data_value('uid') == local_user())
+ $this->commentable = true;
+
+ if($this->writable)
+ $this->commentable = true;
+
+ if($item->get_data_value('item_flags') & ITEM_NOCOMMENT) {
+ $this->commentable = false;
+ }
+ elseif(($this->observer) && (! $this->writable)) {
+ $this->commentable = can_comment_on_post($this->observer['xchan_hash'],$item->data);
+ }
+
+
+
+
$item->set_conversation($this);
$this->threads[] = $item;
return end($this->threads);