2012-08-10 17:46:39 +02:00
|
|
|
<?php
|
|
|
|
if(class_exists('Item'))
|
|
|
|
return;
|
|
|
|
|
2012-08-10 19:57:39 +02:00
|
|
|
require_once('object/BaseObject.php');
|
2012-08-10 17:46:39 +02:00
|
|
|
require_once('include/text.php');
|
2012-08-11 16:56:10 +02:00
|
|
|
require_once('boot.php');
|
2012-08-10 17:46:39 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* An item
|
|
|
|
*/
|
2012-08-10 19:57:39 +02:00
|
|
|
class Item extends BaseObject {
|
2012-08-10 17:46:39 +02:00
|
|
|
private $data = array();
|
2012-08-10 19:57:39 +02:00
|
|
|
private $template = null;
|
|
|
|
private $available_templates = array(
|
|
|
|
'wall' => 'wall_thread.tpl',
|
|
|
|
'wall2wall' => 'wallwall_thread.tpl'
|
|
|
|
);
|
2012-08-12 16:02:47 +02:00
|
|
|
private $comment_box_template = 'comment_item.tpl';
|
2012-08-11 17:09:35 +02:00
|
|
|
private $toplevel = false;
|
2012-08-17 16:40:41 +02:00
|
|
|
private $writable = false;
|
2012-08-11 17:39:11 +02:00
|
|
|
private $children = array();
|
|
|
|
private $parent = null;
|
2012-08-11 18:12:35 +02:00
|
|
|
private $conversation = null;
|
2012-08-12 16:18:53 +02:00
|
|
|
private $redirect_url = null;
|
2012-08-12 17:20:38 +02:00
|
|
|
private $owner_url = '';
|
|
|
|
private $owner_photo = '';
|
|
|
|
private $owner_name = '';
|
|
|
|
private $wall_to_wall = false;
|
2012-08-10 17:46:39 +02:00
|
|
|
|
|
|
|
public function __construct($data) {
|
2012-08-12 16:18:53 +02:00
|
|
|
$a = $this->get_app();
|
|
|
|
|
2012-08-10 17:46:39 +02:00
|
|
|
$this->data = $data;
|
2012-08-11 16:56:10 +02:00
|
|
|
$this->set_template('wall');
|
2012-08-11 17:39:11 +02:00
|
|
|
$this->toplevel = ($this->get_id() == $this->get_data_value('parent'));
|
2012-08-17 16:40:41 +02:00
|
|
|
$this->writable = ($this->get_data_value('writable') || $this->get_data_value('self'));
|
2012-08-11 17:39:11 +02:00
|
|
|
|
2012-08-12 16:18:53 +02:00
|
|
|
$ssl_state = ((local_user()) ? true : false);
|
|
|
|
$this->redirect_url = $a->get_baseurl($ssl_state) . '/redir/' . $this->get_data_value('cid') ;
|
|
|
|
|
2012-08-11 17:39:11 +02:00
|
|
|
// Prepare the children
|
2012-08-12 16:26:37 +02:00
|
|
|
if(count($data['children'])) {
|
|
|
|
foreach($data['children'] as $item) {
|
2012-08-12 17:46:02 +02:00
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
}
|
2012-08-12 16:26:37 +02:00
|
|
|
$child = new Item($item);
|
|
|
|
$this->add_child($child);
|
|
|
|
}
|
2012-08-11 17:39:11 +02:00
|
|
|
}
|
2012-08-10 17:46:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get data in a form usable by a conversation template
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* _ The data requested on success
|
|
|
|
* _ false on failure
|
|
|
|
*/
|
2012-08-12 16:02:47 +02:00
|
|
|
public function get_template_data($alike, $dlike, $thread_level=1) {
|
2012-08-10 17:46:39 +02:00
|
|
|
$result = array();
|
|
|
|
|
2012-08-10 19:57:39 +02:00
|
|
|
$a = $this->get_app();
|
|
|
|
|
|
|
|
$item = $this->get_data();
|
|
|
|
|
|
|
|
$commentww = '';
|
|
|
|
$sparkle = '';
|
|
|
|
$buttons = '';
|
|
|
|
$dropping = false;
|
|
|
|
$star = false;
|
|
|
|
$isstarred = "unstarred";
|
|
|
|
$indent = '';
|
|
|
|
$osparkle = '';
|
2012-08-11 17:48:07 +02:00
|
|
|
$total_children = $this->count_descendants();
|
2012-08-10 19:57:39 +02:00
|
|
|
|
2012-08-11 18:12:35 +02:00
|
|
|
$conv = $this->get_conversation();
|
|
|
|
|
2012-08-10 19:57:39 +02:00
|
|
|
$lock = ((($item['private'] == 1) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
|
|
|
|
|| strlen($item['deny_cid']) || strlen($item['deny_gid']))))
|
|
|
|
? t('Private Message')
|
|
|
|
: false);
|
2012-08-11 18:12:35 +02:00
|
|
|
$shareable = ((($conv->get_profile_owner() == local_user()) && ($item['private'] != 1)) ? true : false);
|
2012-08-10 19:57:39 +02:00
|
|
|
if(local_user() && link_compare($a->contact['url'],$item['author-link']))
|
|
|
|
$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()))
|
|
|
|
$dropping = true;
|
|
|
|
|
|
|
|
$drop = array(
|
|
|
|
'dropping' => $dropping,
|
|
|
|
'select' => t('Select'),
|
|
|
|
'delete' => t('Delete'),
|
|
|
|
);
|
2012-08-10 17:46:39 +02:00
|
|
|
|
2012-08-11 18:12:35 +02:00
|
|
|
$filer = (($conv->get_profile_owner() == local_user()) ? t("save to folder") : false);
|
2012-08-10 19:57:39 +02:00
|
|
|
|
|
|
|
$diff_author = ((link_compare($item['url'],$item['author-link'])) ? false : true);
|
|
|
|
$profile_name = (((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']);
|
|
|
|
if($item['author-link'] && (! $item['author-name']))
|
|
|
|
$profile_name = $item['author-link'];
|
|
|
|
|
|
|
|
$sp = false;
|
|
|
|
$profile_link = best_link_url($item,$sp);
|
|
|
|
|