aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/ConversationObject.php4
-rw-r--r--include/ItemObject.php18
-rw-r--r--include/conversation.php65
3 files changed, 60 insertions, 27 deletions
diff --git a/include/ConversationObject.php b/include/ConversationObject.php
index a02ba102f..7dc4c8c19 100644
--- a/include/ConversationObject.php
+++ b/include/ConversationObject.php
@@ -197,7 +197,7 @@ class Conversation extends BaseObject {
* _ The data requested on success
* _ false on failure
*/
- public function get_template_data($alike, $dlike) {
+ public function get_template_data($conv_responses) {
$result = array();
foreach($this->threads as $item) {
@@ -206,7 +206,7 @@ class Conversation extends BaseObject {
$item_data = $this->prepared_item;
}
else {
- $item_data = $item->get_template_data($alike, $dlike);
+ $item_data = $item->get_template_data($conv_responses);
}
if(!$item_data) {
logger('[ERROR] Conversation::get_template_data : Failed to get item template data ('. $item->get_id() .').', LOGGER_DEBUG);
diff --git a/include/ItemObject.php b/include/ItemObject.php
index ec8116297..82a321732 100644
--- a/include/ItemObject.php
+++ b/include/ItemObject.php
@@ -63,7 +63,7 @@ class Item extends BaseObject {
* _ false on failure
*/
- public function get_template_data($alike, $dlike, $thread_level=1) {
+ public function get_template_data($conv_responses, $thread_level=1) {
$result = array();
@@ -135,8 +135,8 @@ class Item extends BaseObject {
$location = format_location($item);
- $like_count = ((x($alike,$item['mid'])) ? $alike[$item['mid']] : '');
- $like_list = ((x($alike,$item['mid'])) ? $alike[$item['mid'] . '-l'] : '');
+ $like_count = ((x($conv_responses['like'],$item['mid'])) ? $conv_responses['like'][$item['mid']] : '');
+ $like_list = ((x($conv_responses['like'],$item['mid'])) ? $conv_responses['like'][$item['mid'] . '-l'] : '');
if (count($like_list) > MAX_LIKERS) {
$like_list_part = array_slice($like_list, 0, MAX_LIKERS);
array_push($like_list_part, '<a href="#" data-toggle="modal" data-target="#likeModal-' . $this->get_id() . '"><b>' . t('View all') . '</b></a>');
@@ -146,8 +146,8 @@ class Item extends BaseObject {
$like_button_label = tt('Like','Likes',$like_count,'noun');
if (feature_enabled($conv->get_profile_owner(),'dislike')) {
- $dislike_count = ((x($dlike,$item['mid'])) ? $dlike[$item['mid']] : '');
- $dislike_list = ((x($dlike,$item['mid'])) ? $dlike[$item['mid'] . '-l'] : '');
+ $dislike_count = ((x($conv_responses['dislike'],$item['mid'])) ? $conv_responses['dislike'][$item['mid']] : '');
+ $dislike_list = ((x($conv_responses['dislike'],$item['mid'])) ? $conv_responses['dislike'][$item['mid'] . '-l'] : '');
$dislike_button_label = tt('Dislike','Dislikes',$dislike_count,'noun');
if (count($dislike_list) > MAX_LIKERS) {
$dislike_list_part = array_slice($dislike_list, 0, MAX_LIKERS);
@@ -157,9 +157,9 @@ class Item extends BaseObject {
}
}
- $showlike = ((x($alike,$item['mid'])) ? format_like($alike[$item['mid']],$alike[$item['mid'] . '-l'],'like',$item['mid']) : '');
- $showdislike = ((x($dlike,$item['mid']) && feature_enabled($conv->get_profile_owner(),'dislike'))
- ? format_like($dlike[$item['mid']],$dlike[$item['mid'] . '-l'],'dislike',$item['mid']) : '');
+ $showlike = ((x($conv_responses['like'],$item['mid'])) ? format_like($conv_responses['like'][$item['mid']],$conv_responses['like'][$item['mid'] . '-l'],'like',$item['mid']) : '');
+ $showdislike = ((x($conv_responses['dislike'],$item['mid']) && feature_enabled($conv->get_profile_owner(),'dislike'))
+ ? format_like($conv_responses['dislike'][$item['mid']],$conv_responses['dislike'][$item['mid'] . '-l'],'dislike',$item['mid']) : '');
/*
* We should avoid doing this all the time, but it depends on the conversation mode
@@ -336,7 +336,7 @@ class Item extends BaseObject {
if(($this->get_display_mode() === 'normal') && ($nb_children > 0)) {
foreach($children as $child) {
- $result['children'][] = $child->get_template_data($alike, $dlike, $thread_level + 1);
+ $result['children'][] = $child->get_template_data($conv_responses, $thread_level + 1);
}
// Collapse
if(($nb_children > 2) || ($thread_level > 1)) {
diff --git a/include/conversation.php b/include/conversation.php
index 986892fff..0d59ff92e 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -399,10 +399,15 @@ function count_descendants($item) {
function visible_activity($item) {
- // likes can apply to other things besides posts. Check if they are post children, in which case we handle them specially
+ // likes (etc.) can apply to other things besides posts. Check if they are post children,
+ // in which case we handle them specially
- if((activity_match($item['verb'],ACTIVITY_LIKE) || activity_match($item['verb'],ACTIVITY_DISLIKE)) && ($item['mid'] != $item['parent_mid']))
- return false;
+ $hidden_activities = array(ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_AGREE, ACTIVITY_DISAGREE, ACTIVITY_ABSTAIN);
+ foreach($hidden_activities as $act) {
+ if((activity_match($item['verb'],$act)) && ($item['mid'] != $item['parent_mid'])) {
+ return false;
+ }
+ }
return true;
}
@@ -547,8 +552,7 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
$items = $cb['items'];
- $alike = array();
- $dlike = array();
+ $conv_responses = array(array('like'),array('dislike'),array('agree'),array('disagree'),array('abstain'));
// array with html for each thread (parent+comments)
$threads = array();
@@ -779,10 +783,14 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
}
}
- like_puller($a, $item, $alike, 'like');
+ like_puller($a, $item, $conv_responses, 'like');
if(feature_enabled($profile_owner, 'dislike'))
- like_puller($a, $item, $dlike, 'dislike');
+ like_puller($a, $item, $conv_responses, 'dislike');
+
+ like_puller($a, $item, $conv_responses, 'agree');
+ like_puller($a, $item, $conv_responses, 'disagree');
+ like_puller($a, $item, $conv_responses, 'abstain');
if(! visible_activity($item)) {
continue;
@@ -801,7 +809,7 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
}
}
- $threads = $conv->get_template_data($alike, $dlike);
+ $threads = $conv->get_template_data($conv_responses);
if(!$threads) {
logger('[ERROR] conversation : Failed to get template data.', LOGGER_DEBUG);
$threads = array();
@@ -972,7 +980,32 @@ function item_photo_menu($item){
function like_puller($a, $item, &$arr, $mode) {
$url = '';
- $verb = (($mode === 'like') ? ACTIVITY_LIKE : ACTIVITY_DISLIKE);
+
+ switch($mode) {
+ case 'like':
+ case 'unlike':
+ $verb = ACTIVITY_LIKE;
+ break;
+ case 'dislike':
+ case 'undislike':
+ $verb = ACTIVITY_DISLIKE;
+ break;
+ case 'agree':
+ case 'unagree':
+ $verb = ACTIVITY_AGREE;
+ break;
+ case 'disagree':
+ case 'undisagree':
+ $verb = ACTIVITY_DISAGREE;
+ break;
+ case 'abstain':
+ case 'unabstain':
+ $verb = ACTIVITY_ABSTAIN;
+ break;
+ default:
+ return;
+ break;
+ }
if((activity_match($item['verb'], $verb)) && ($item['id'] != $item['parent'])) {
@@ -982,20 +1015,20 @@ function like_puller($a, $item, &$arr, $mode) {
if(! $item['thr_parent'])
$item['thr_parent'] = $item['parent_mid'];
- if(! ((isset($arr[$item['thr_parent'] . '-l'])) && (is_array($arr[$item['thr_parent'] . '-l']))))
- $arr[$item['thr_parent'] . '-l'] = array();
+ if(! ((isset($arr[$mode][$item['thr_parent'] . '-l'])) && (is_array($arr[$mode][$item['thr_parent'] . '-l']))))
+ $arr[$mode][$item['thr_parent'] . '-l'] = array();
- if(! isset($arr[$item['thr_parent']]))
- $arr[$item['thr_parent']] = 1;
+ if(! isset($arr[$mode][$item['thr_parent']]))
+ $arr[$mode][$item['thr_parent']] = 1;
else
- $arr[$item['thr_parent']] ++;
+ $arr[$mode][$item['thr_parent']] ++;
$name = (($item['author']['xchan_name']) ? $item['author']['xchan_name'] : t('Unknown'));
if($url)
- $arr[$item['thr_parent'] . '-l'][] = '<a href="'. $url . '">' . $name . '</a>';
+ $arr[$mode][$item['thr_parent'] . '-l'][] = '<a href="'. $url . '">' . $name . '</a>';
else
- $arr[$item['thr_parent'] . '-l'][] = '<a href="#" class="disabled">' . $name . '</a>';
+ $arr[$mode][$item['thr_parent'] . '-l'][] = '<a href="#" class="disabled">' . $name . '</a>';
}
return;
}