private $owner_name = '';
private $wall_to_wall = false;
private $threaded = false;
+ private $visiting = false;
public function __construct($data) {
$a = $this->get_app();
$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);
* Get data in a form usable by a conversation template
*
* Returns:
- * _ The data requested on success
- * _ false on failure
+ * _ The data requested on success
+ * _ false on failure
*/
public function get_template_data($alike, $dlike, $thread_level=1) {
$result = array();
$edpost = array($a->get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit"));
else
$edpost = false;
- if((intval($item['contact-id']) && $item['contact-id'] == remote_user()) || ($item['uid'] == local_user()))
+ if(($this->get_data_value('uid') == local_user()) || $this->is_visiting())
$dropping = true;
$drop = array(
if($sp)
$sparkle = ' sparkle';
else
- $profile_link = zrl($profile_link);
+ $profile_link = zrl($profile_link);
$normalised = normalise_link((strlen($item['author-link'])) ? $item['author-link'] : $item['url']);
if(($normalised != 'mailbox') && (x($a->contacts,$normalised)))
'like' => $like,
'dislike' => $dislike,
'comment' => $this->get_comment_box($indent),
- 'previewing' => $previewing,
+ 'previewing' => ($conv->is_preview() ? ' preview ' : ''),
'wait' => t('Please wait'),
'thread_level' => $thread_level
);
* Get a data value
*
* Returns:
- * _ value on success
- * _ false on failure
+ * _ value on success
+ * _ false on failure
*/
public function get_data_value($name) {
if(!isset($this->data[$name])) {
* 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;
}
* Get the comment box
*
* Returns:
- * _ The comment box string (empty if no comment box)
- * _ false on failure
+ * _ The comment box string (empty if no comment box)
+ * _ false on failure
*/
private function get_comment_box($indent) {
if(!$this->is_toplevel() && !get_config('system','thread_allow')) {
}
}
- if(!$this->wall_to_wall) {
- // Fallback, check if can find a @ tag
- $tags = $this->get_data_value('tag');
- if(strpos($tags, '@[url') !== FALSE) {
- // We have at least one @ tag
- $matches = array();
- preg_match_all('/\@\[url=([^\]]+)\]([^\[]+)\[\/url\]/', $tags, $matches, PREG_SET_ORDER);
-
- $r = null;
- foreach($matches as $wall) {
- $uri = $wall[1];
- $r = q("SELECT `url`,`name`,`photo`,`forum` FROM `contact` WHERE `url`='%s' LIMIT 1",
- dbesc($uri)
- );
-
- if(count($r) && (intval($r[0]['forum']) == 1)) {
- $this->owner_url = zrl($r[0]['url']);
- $this->owner_name = $r[0]['name'];
- $this->owner_photo = $r[0]['photo'];
- $this->wall_to_wall = true;
- $this->set_template('wall2wall');
- break;
- }
- }
- }
- }
-
if(!$this->wall_to_wall) {
$this->set_template('wall');
$this->owner_url = '';
private function get_owner_name() {
return $this->owner_name;
}
+
+ private function is_visiting() {
+ return $this->visiting;
+ }
}
?>