]> git.mxchange.org Git - friendica.git/commitdiff
first work for consensus
authorrabuzarus <>
Sun, 31 May 2015 23:23:04 +0000 (01:23 +0200)
committerrabuzarus <trebor@central-unit>
Wed, 30 Sep 2015 12:34:10 +0000 (14:34 +0200)
boot.php
include/conversation.php
mod/like.php
object/Conversation.php
object/Item.php

index 5f633fd87877b37cb9ba531cdcd5b5477ca7441d..4dcfdc49523e22fa5397e176d15f9b143736ed6f 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -270,6 +270,10 @@ define ( 'NAMESPACE_ATOM1',           'http://www.w3.org/2005/Atom' );
 
 define ( 'ACTIVITY_LIKE',        NAMESPACE_ACTIVITY_SCHEMA . 'like' );
 define ( 'ACTIVITY_DISLIKE',     NAMESPACE_DFRN            . '/dislike' );
+define ( 'ACTIVITY_AGREE',       NAMESPACE_DFRN            . '/activity/agree' );
+define ( 'ACTIVITY_DISAGREE',    NAMESPACE_DFRN            . '/activity/disagree' );
+define ( 'ACTIVITY_ABSTAIN',     NAMESPACE_DFRN            . '/activity/abstain' );
+
 define ( 'ACTIVITY_OBJ_HEART',   NAMESPACE_DFRN            . '/heart' );
 
 define ( 'ACTIVITY_FRIEND',      NAMESPACE_ACTIVITY_SCHEMA . 'make-friend' );
index 5a84ca42a635be89c7c0752a34d1612dd3c07ca9..a5d8ac551f8a17c6737a67c7a7aed69fe372b57f 100644 (file)
@@ -341,8 +341,15 @@ function count_descendants($item) {
 
 function visible_activity($item) {
 
-       if(activity_match($item['verb'],ACTIVITY_LIKE) || activity_match($item['verb'],ACTIVITY_DISLIKE))
-               return false;
+       // likes (etc.) can apply to other things besides posts. Check if they are post children, 
+       // in which case we handle them specially
+
+       $hidden_activities = array(ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_AGREE, ACTIVITY_DISAGREE, ACTIVITY_ABSTAIN);
+       foreach($hidden_activities as $act) {
+               if(activity_match($item['verb'],$act)) {
+                       return false;
+               }
+       }
 
        if(activity_match($item['verb'],ACTIVITY_FOLLOW) && $item['object-type'] === ACTIVITY_OBJ_NOTE) {
                if(! (($item['self']) && ($item['uid'] == local_user()))) {
@@ -484,8 +491,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
        $cmnt_tpl    = get_markup_template('comment_item.tpl');
        $hide_comments_tpl = get_markup_template('hide_comments.tpl');
 
-       $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();
@@ -734,8 +740,11 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
 
 
                                // Can we put this after the visibility check?
-                               like_puller($a,$item,$alike,'like');
-                               like_puller($a,$item,$dlike,'dislike');
+                               like_puller($a, $item, $conv_responses, 'like');
+                               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');
 
                                // Only add what is visible
                                if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
@@ -755,7 +764,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
                                }
                        }
 
-                       $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);
@@ -904,7 +913,31 @@ function like_puller($a,$item,&$arr,$mode) {
 
        $url = '';
        $sparkle = '';
-       $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'])) {
                $url = $item['author-link'];
@@ -918,13 +951,14 @@ function like_puller($a,$item,&$arr,$mode) {
                if(! $item['thr-parent'])
                        $item['thr-parent'] = $item['parent-uri'];
 
-               if(! ((isset($arr[$item['thr-parent'] . '-l'])) && (is_array($arr[$item['thr-parent'] . '-l']))))
-                       $arr[$item['thr-parent'] . '-l'] = array();
-               if(! isset($arr[$item['thr-parent']]))
-                       $arr[$item['thr-parent']] = 1;
+               if(! ((isset($arr[$mode][$item['thr-parent'] . '-l'])) && (is_array($arr[$item['thr-parent'] . '-l']))))
+                       $arr[$mode][$item['thr-parent'] . '-l'] = array();
+               if(! isset($arr[$mode][$item['thr-parent']]))
+                       $arr[$mode][$item['thr-parent']] = 1;
                else
-                       $arr[$item['thr-parent']] ++;
-               $arr[$item['thr-parent'] . '-l'][] = '<a href="'. $url . '"'. $sparkle .'>' . $item['author-name'] . '</a>';
+                       $arr[$mode][$item['thr-parent']] ++;
+
+               $arr[$mode][$item['thr-parent'] . '-l'][] = '<a href="'. $url . '"'. $sparkle .'>' . $item['author-name'] . '</a>';
        }
        return;
 }}
index bbb07289659257b4efdbda20fc294139509427d6..6f0c5a5095bd20ef69f7b21b887d4a58b909a41b 100755 (executable)
@@ -26,6 +26,18 @@ function like_content(&$a) {
                case 'undislike':
                        $activity = ACTIVITY_DISLIKE;
                        break;
+               case 'agree':
+               case 'unagree':
+                       $activity = ACTIVITY_AGREE;
+                       break;
+               case 'disagree':
+               case 'undisagree':
+                       $activity = ACTIVITY_DISAGREE;
+                       break;
+               case 'abstain':
+               case 'unabstain':
+                       $activity = ACTIVITY_ABSTAIN;
+                       break;
                default:
                        return;
                        break;
@@ -166,6 +178,12 @@ EOT;
                $bodyverb = t('%1$s likes %2$s\'s %3$s');
        if($verb === 'dislike')
                $bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s');
+       if($verb === 'agree')
+               $bodyverb = t('%1$s agrees with %2$s\'s %3$s');
+       if($verb === 'disagree')
+               $bodyverb = t('%1$s doesn\'t agree with %2$s\'s %3$s');
+       if($verb === 'abstain')
+               $bodyverb = t('%1$s abstains from a decision on %2$s\'s %3$s');
 
        if(! isset($bodyverb))
                        return; 
index fd1e282cabf6ce7525c40e80c73d05b3d2938ccc..94eed94d5f9eaa8661d6a9508b4be21a0512ff90 100644 (file)
@@ -126,7 +126,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) {
                global $a;
                $result = array();
 
@@ -136,7 +136,7 @@ class Conversation extends BaseObject {
                        if($item->get_data_value('network') === NETWORK_MAIL && local_user() != $item->get_data_value('uid'))
                                continue;
 
-                       $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);
index 8d364e6023040e8d0ed00b0ad6e31fce33a8d1cd..7ff4c438c7197ae38632803701ae6d4d74349c26 100644 (file)
@@ -81,7 +81,7 @@ class Item extends BaseObject {
         *      _ The data requested on success
         *      _ false on failure
         */
-       public function get_template_data($alike, $dlike, $thread_level=1) {
+       public function get_template_data($conv_responses, $thread_level=1) {
                require_once("mod/proxy.php");
 
                $result = array();
@@ -175,8 +175,8 @@ class Item extends BaseObject {
                        }
                }*/
 
-               $like    = ((x($alike,$item['uri'])) ? format_like($alike[$item['uri']],$alike[$item['uri'] . '-l'],'like',$item['uri']) : '');
-               $dislike = ((x($dlike,$item['uri'])) ? format_like($dlike[$item['uri']],$dlike[$item['uri'] . '-l'],'dislike',$item['uri']) : '');
+               $like    = ((x($conv_responses['like'],$item['uri'])) ? format_like($conv_responses['like'][$item['uri']],$conv_responses['like'][$item['uri'] . '-l'],'like',$item['uri']) : '');
+               $dislike = ((x($conv_responses['dislike'],$item['uri'])) ? format_like($conv_responses['dislike'][$item['uri']],$conv_responses['dislike'][$item['uri'] . '-l'],'dislike',$item['uri']) : '');
 
                /*
                 * We should avoid doing this all the time, but it depends on the conversation mode
@@ -381,7 +381,7 @@ class Item extends BaseObject {
                $nb_children = count($children);
                if($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)) {