aboutsummaryrefslogtreecommitdiffstats
path: root/include/conversation.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2015-01-11 14:41:33 -0800
committerfriendica <info@friendica.com>2015-01-11 14:41:33 -0800
commit0259051a87233f32efaaa7f0b4dafc71c2f3c13d (patch)
tree3d222e3a66d14d5e4477304789e292939e3b808e /include/conversation.php
parentb018b39e6473b74599a9cefe1ed8bae923424ff4 (diff)
downloadvolse-hubzilla-0259051a87233f32efaaa7f0b4dafc71c2f3c13d.tar.gz
volse-hubzilla-0259051a87233f32efaaa7f0b4dafc71c2f3c13d.tar.bz2
volse-hubzilla-0259051a87233f32efaaa7f0b4dafc71c2f3c13d.zip
basic backend work for creating consensus items
Diffstat (limited to 'include/conversation.php')
-rw-r--r--include/conversation.php65
1 files changed, 49 insertions, 16 deletions
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;
}