aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/BaseObject.php2
-rw-r--r--include/ConversationObject.php13
-rw-r--r--include/ItemObject.php71
-rw-r--r--include/conversation.php143
-rw-r--r--include/dba.php4
5 files changed, 159 insertions, 74 deletions
diff --git a/include/BaseObject.php b/include/BaseObject.php
index 14f0d8fd0..200831e15 100644
--- a/include/BaseObject.php
+++ b/include/BaseObject.php
@@ -34,4 +34,4 @@ class BaseObject {
self::$app = $app;
}
}
-?>
+
diff --git a/include/ConversationObject.php b/include/ConversationObject.php
index ca2ae7dd6..d9a3974eb 100644
--- a/include/ConversationObject.php
+++ b/include/ConversationObject.php
@@ -35,7 +35,6 @@ class Conversation extends BaseObject {
switch($mode) {
case 'network':
- case 'notes':
$this->profile_owner = local_user();
$this->writable = true;
break;
@@ -104,12 +103,8 @@ class Conversation extends BaseObject {
/*
* Only add will be displayed
*/
- if($item->get_data_value('network') === NETWORK_MAIL && local_user() != $item->get_data_value('uid')) {
- logger('[WARN] Conversation::add_thread : Thread is a mail ('. $item->get_id() .').', LOGGER_DEBUG);
- return false;
- }
- if($item->get_data_value('verb') === ACTIVITY_LIKE || $item->get_data_value('verb') === ACTIVITY_DISLIKE) {
- logger('[WARN] Conversation::add_thread : Thread is a (dis)like ('. $item->get_id() .').', LOGGER_DEBUG);
+
+ if(activity_match($item->get_data_value('verb'),ACTIVITY_LIKE) || activity_match($item->get_data_value('verb'),ACTIVITY_DISLIKE)) {
return false;
}
$item->set_conversation($this);
@@ -130,8 +125,7 @@ class Conversation extends BaseObject {
$result = array();
foreach($this->threads as $item) {
- if($item->get_data_value('network') === NETWORK_MAIL && local_user() != $item->get_data_value('uid'))
- continue;
+
$item_data = $item->get_template_data($alike, $dlike);
if(!$item_data) {
logger('[ERROR] Conversation::get_template_data : Failed to get item template data ('. $item->get_id() .').', LOGGER_DEBUG);
@@ -159,4 +153,3 @@ class Conversation extends BaseObject {
return false;
}
}
-?>
diff --git a/include/ItemObject.php b/include/ItemObject.php
index 8571c6d84..6142d6a4d 100644
--- a/include/ItemObject.php
+++ b/include/ItemObject.php
@@ -11,11 +11,7 @@ require_once('boot.php');
*/
class Item extends BaseObject {
private $data = array();
- private $template = null;
- private $available_templates = array(
- 'wall' => 'wall_thread.tpl',
- 'wall2wall' => 'wallwall_thread.tpl'
- );
+ private $template = 'wall_thread.tpl';
private $comment_box_template = 'comment_item.tpl';
private $toplevel = false;
private $writable = false;
@@ -29,24 +25,31 @@ class Item extends BaseObject {
private $wall_to_wall = false;
private $threaded = false;
private $visiting = false;
+ private $observer = null;
+ private $channel = null;
public function __construct($data) {
$a = $this->get_app();
-
+
$this->data = $data;
- $this->set_template('wall');
+ $this->channel = $a->get_channel();
+ $this->observer = $a->get_observer();
+
$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;
- }
- }
- }
-
+// if(is_array($_SESSION['remote'])) {
+// foreach($_SESSION['remote'] as $visitor) {
+// if($visitor['cid'] == $this->get_data_value('contact-id')) {
+// $this->visiting = true;
+// break;
+// }
+// }
+// }
+
+// fixme
$this->writable = ($this->get_data_value('writable') || $this->get_data_value('self'));
+// FIXME - base this on observer permissions
+ $this->writable = ((local_user() && $channel['channel_hash'] === $item['owner_xchan']) ? true : false);
$ssl_state = ((local_user()) ? true : false);
$this->redirect_url = $a->get_baseurl($ssl_state) . '/redir/' . $this->get_data_value('cid') ;
@@ -60,9 +63,6 @@ class Item extends BaseObject {
/*
* Only add will be displayed
*/
- if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
- continue;
- }
if(! visible_activity($item)) {
continue;
}
@@ -79,12 +79,13 @@ class Item extends BaseObject {
* _ The data requested on success
* _ false on failure
*/
+
public function get_template_data($alike, $dlike, $thread_level=1) {
$result = array();
- $a = $this->get_app();
-
- $item = $this->get_data();
+ $a = $this->get_app();
+ $observer = $this->observer;
+ $item = $this->get_data();
$commentww = '';
$sparkle = '';
@@ -308,9 +309,7 @@ class Item extends BaseObject {
/*
* Only add what will be displayed
*/
- if($item->get_data_value('network') === NETWORK_MAIL && local_user() != $item->get_data_value('uid')) {
- return false;
- }
+
if(activity_match($item->get_data_value('verb'),ACTIVITY_LIKE) || activity_match($item->get_data_value('verb'),ACTIVITY_DISLIKE)) {
return false;
}
@@ -332,7 +331,7 @@ class Item extends BaseObject {
}
/**
- * Get all ou children
+ * Get all our children
*/
public function get_children() {
return $this->children;
@@ -429,17 +428,6 @@ class Item extends BaseObject {
}
/**
- * Set template
- */
- private function set_template($name) {
- if(!x($this->available_templates, $name)) {
- logger('[ERROR] Item::set_template : Template not available ("'. $name .'").', LOGGER_DEBUG);
- return false;
- }
- $this->template = $this->available_templates[$name];
- }
-
- /**
* Get template
*/
private function get_template() {
@@ -528,9 +516,9 @@ class Item extends BaseObject {
'$parent' => $this->get_id(),
'$qcomment' => $qcomment,
'$profile_uid' => $conv->get_profile_owner(),
- '$mylink' => $a->contact['url'],
+ '$mylink' => $this->observer['xchan_profile'],
'$mytitle' => t('This is you'),
- '$myphoto' => $a->contact['thumb'],
+ '$myphoto' => $this->observer['xchan_photo_s'],
'$comment' => t('Comment'),
'$submit' => t('Submit'),
'$edbold' => t('Bold'),
@@ -574,7 +562,6 @@ class Item extends BaseObject {
$this->owner_url = zrl($a->page_contact['url']);
$this->owner_photo = $a->page_contact['thumb'];
$this->owner_name = $a->page_contact['name'];
- $this->set_template('wall2wall');
$this->wall_to_wall = true;
}
else if($this->get_data_value('owner-link')) {
@@ -596,7 +583,6 @@ class Item extends BaseObject {
$this->owner_photo = $this->get_data_value('owner-avatar');
$this->owner_name = $this->get_data_value('owner-name');
- $this->set_template('wall2wall');
$this->wall_to_wall = true;
// If it is our contact, use a friendly redirect link
if((link_compare($this->get_data_value('owner-link'),$this->get_data_value('url')))
@@ -611,7 +597,6 @@ class Item extends BaseObject {
}
if(!$this->wall_to_wall) {
- $this->set_template('wall');
$this->owner_url = '';
$this->owner_photo = '';
$this->owner_name = '';
@@ -642,4 +627,4 @@ class Item extends BaseObject {
}
-?>
+
diff --git a/include/conversation.php b/include/conversation.php
index ce6f017e1..332171e03 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -331,13 +331,6 @@ function visible_activity($item) {
if(activity_match($item['verb'],ACTIVITY_LIKE) || activity_match($item['verb'],ACTIVITY_DISLIKE))
return false;
-
- if(activity_match($item['verb'],ACTIVITY_FOLLOW) && $item['object-type'] === ACTIVITY_OBJ_NOTE) {
- if(! (($item['self']) && ($item['uid'] == local_user()))) {
- return false;
- }
- }
-
return true;
}
@@ -717,6 +710,7 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') {
$profile_owner = 0;
$page_writeable = false;
+ $live_update_div = '';
$preview = (($page_mode === 'preview') ? true : false);
$previewing = (($preview) ? ' preview ' : '');
@@ -724,27 +718,77 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') {
if($mode === 'network') {
$profile_owner = local_user();
$page_writeable = true;
+
+ if(!$update) {
+ // The special div is needed for liveUpdate to kick in for this page.
+ // We only launch liveUpdate if you aren't filtering in some incompatible
+ // way and also you aren't writing a comment (discovered in javascript).
+
+ $live_update_div = '<div id="live-network"></div>' . "\r\n"
+ . "<script> var profile_uid = " . $_SESSION['uid']
+ . "; var netargs = '" . substr($a->cmd,8)
+ . '?f='
+ . ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : '')
+ . ((x($_GET,'search')) ? '&search=' . $_GET['search'] : '')
+ . ((x($_GET,'star')) ? '&star=' . $_GET['star'] : '')
+ . ((x($_GET,'order')) ? '&order=' . $_GET['order'] : '')
+ . ((x($_GET,'bmark')) ? '&bmark=' . $_GET['bmark'] : '')
+ . ((x($_GET,'liked')) ? '&liked=' . $_GET['liked'] : '')
+ . ((x($_GET,'conv')) ? '&conv=' . $_GET['conv'] : '')
+ . ((x($_GET,'spam')) ? '&spam=' . $_GET['spam'] : '')
+ . ((x($_GET,'nets')) ? '&nets=' . $_GET['nets'] : '')
+ . ((x($_GET,'cmin')) ? '&cmin=' . $_GET['cmin'] : '')
+ . ((x($_GET,'cmax')) ? '&cmax=' . $_GET['cmax'] : '')
+ . ((x($_GET,'file')) ? '&file=' . $_GET['file'] : '')
+
+ . "'; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
+ }
+
+
}
- if($mode === 'profile') {
+ elseif($mode === 'profile') {
$profile_owner = $a->profile['profile_uid'];
$page_writeable = can_write_wall($a,$profile_owner);
- }
- if($mode === 'notes') {
- $profile_owner = local_user();
- $page_writeable = true;
+ if(!$update) {
+ $tab = notags(trim($_GET['tab']));
+ if($tab === 'posts') {
+ // This is ugly, but we can't pass the profile_uid through the session to the ajax updater,
+ // because browser prefetching might change it on us. We have to deliver it with the page.
+
+ $live_update_div = '<div id="live-profile"></div>' . "\r\n"
+ . "<script> var profile_uid = " . $a->profile['profile_uid']
+ . "; var netargs = '?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
+ }
+ }
+
+
+
+
}
- if($mode === 'display') {
+ elseif($mode === 'display') {
$profile_owner = $a->profile['uid'];
$page_writeable = can_write_wall($a,$profile_owner);
+
+ $live_update_div = '<div id="live-display"></div>' . "\r\n";
+
}
- if($mode === 'community') {
+ elseif($mode === 'community') {
$profile_owner = 0;
$page_writeable = false;
+
+ if(!$update) {
+ $live_update_div = '<div id="live-community"></div>' . "\r\n"
+ . "<script> var profile_uid = -1; var netargs = '/?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
+
+ }
}
+ else if($mode === 'search') {
+ $live_update_div = '<div id="live-search"></div>' . "\r\n";
+ }
$page_dropping = ((local_user() && local_user() == $profile_owner) ? true : false);
@@ -765,8 +809,6 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') {
$items = $cb['items'];
$cmnt_tpl = get_markup_template('comment_item.tpl');
- $tpl = 'wall_item.tpl';
- $wallwall = 'wallwall_item.tpl';
$hide_comments_tpl = get_markup_template('hide_comments.tpl');
$alike = array();
@@ -893,6 +935,13 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') {
'tags' => template_escape($tags),
'hashtags' => template_escape($hashtags),
'mentions' => template_escape($mentions),
+ 'txt_cats' => t('Categories:'),
+ 'txt_folders' => t('Filed under:'),
+ 'has_cats' => ((count($categories)) ? 'true' : ''),
+ 'has_folders' => ((count($folders)) ? 'true' : ''),
+ 'categories' => $categories,
+ 'folders' => $folders,
+
'text' => strip_tags(template_escape($body)),
'ago' => relative_date($item['created']),
'app' => $item['app'],
@@ -931,6 +980,67 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') {
{
// Normal View
+ $page_template = get_markup_template("threaded_conversation.tpl");
+
+ require_once('include/ConversationObject.php');
+ require_once('include/ItemObject.php');
+
+ $conv = new Conversation($mode, $preview);
+
+ // get all the topmost parents
+ // this shouldn't be needed, as we should have only them in our array
+ // But for now, this array respects the old style, just in case
+
+ $threads = array();
+ foreach($items as $item) {
+
+ // Can we put this after the visibility check?
+ like_puller($a,$item,$alike,'like');
+ like_puller($a,$item,$dlike,'dislike');
+
+ // Only add what is visible
+ if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
+ continue;
+ }
+ if(! visible_activity($item)) {
+ continue;
+ }
+
+ $item['pagedrop'] = $page_dropping;
+
+ if($item['id'] == $item['parent']) {
+ $item_object = new Item($item);
+ $conv->add_thread($item_object);
+ }
+ }
+
+ $threads = $conv->get_template_data($alike, $dlike);
+ if(!$threads) {
+ logger('[ERROR] conversation : Failed to get template data.', LOGGER_DEBUG);
+ $threads = array();
+ }
+ }
+ }
+
+ $o = replace_macros($page_template, array(
+ '$baseurl' => $a->get_baseurl($ssl_state),
+ '$live_update' => $live_update_div,
+ '$remove' => t('remove'),
+ '$mode' => $mode,
+ '$user' => $a->user,
+ '$threads' => $threads,
+ '$dropping' => ($page_dropping?t('Delete Selected Items'):False),
+ ));
+
+ return $o;
+
+
+}}
+
+
+/*
+old code
+
// Figure out how many comments each parent has
// (Comments all have gravity of 6)
@@ -1351,6 +1461,7 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') {
return $o;
}}
+*/
function best_link_url($item,&$sparkle,$ssl_state = false) {
diff --git a/include/dba.php b/include/dba.php
index 8d224b570..d1502af12 100644
--- a/include/dba.php
+++ b/include/dba.php
@@ -287,7 +287,3 @@ function dbesc_array(&$arr) {
}}
-function dba_timer() {
- return microtime(true);
-}
-