From 37fccee503341ce1363e57cc81d465ef224e702d Mon Sep 17 00:00:00 2001
From: rabuzarus <>
Date: Mon, 1 Jun 2015 01:23:04 +0200
Subject: [PATCH 01/16] first work for consensus
---
boot.php | 4 +++
include/conversation.php | 62 +++++++++++++++++++++++++++++++---------
mod/like.php | 18 ++++++++++++
object/Conversation.php | 4 +--
object/Item.php | 8 +++---
5 files changed, 76 insertions(+), 20 deletions(-)
diff --git a/boot.php b/boot.php
index 5f633fd878..4dcfdc4952 100644
--- 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' );
diff --git a/include/conversation.php b/include/conversation.php
index 5a84ca42a6..a5d8ac551f 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -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'][] = '' . $item['author-name'] . '';
+ $arr[$mode][$item['thr-parent']] ++;
+
+ $arr[$mode][$item['thr-parent'] . '-l'][] = '' . $item['author-name'] . '';
}
return;
}}
diff --git a/mod/like.php b/mod/like.php
index bbb0728965..6f0c5a5095 100755
--- a/mod/like.php
+++ b/mod/like.php
@@ -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;
diff --git a/object/Conversation.php b/object/Conversation.php
index fd1e282cab..94eed94d5f 100644
--- a/object/Conversation.php
+++ b/object/Conversation.php
@@ -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);
diff --git a/object/Item.php b/object/Item.php
index 8d364e6023..7ff4c438c7 100644
--- a/object/Item.php
+++ b/object/Item.php
@@ -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)) {
From 0077494396a963b748f30a1e47f75fe097189956 Mon Sep 17 00:00:00 2001
From: rabuzarus <>
Date: Mon, 1 Jun 2015 13:57:45 +0200
Subject: [PATCH 02/16] make event confirmation work
---
boot.php | 9 +++--
include/conversation.php | 82 ++++++++++++++++++++++++++++++++++++++--
mod/like.php | 20 ++++++++++
object/Item.php | 48 ++++++++++++++++++++++-
4 files changed, 152 insertions(+), 7 deletions(-)
diff --git a/boot.php b/boot.php
index 4dcfdc4952..e3469b5509 100644
--- a/boot.php
+++ b/boot.php
@@ -270,9 +270,12 @@ 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_AGREE', NAMESPACE_ZOT . '/activity/agree' );
+define ( 'ACTIVITY_DISAGREE', NAMESPACE_ZOT . '/activity/disagree' );
+define ( 'ACTIVITY_ABSTAIN', NAMESPACE_ZOT . '/activity/abstain' );
+define ( 'ACTIVITY_ATTEND', NAMESPACE_ZOT . '/activity/attendyes' );
+define ( 'ACTIVITY_ATTENDNO', NAMESPACE_ZOT . '/activity/attendno' );
+define ( 'ACTIVITY_ATTENDMAYBE', NAMESPACE_ZOT . '/activity/attendmaybe' );
define ( 'ACTIVITY_OBJ_HEART', NAMESPACE_DFRN . '/heart' );
diff --git a/include/conversation.php b/include/conversation.php
index a5d8ac551f..cdc7ba3bd8 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -344,7 +344,7 @@ function visible_activity($item) {
// 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);
+ $hidden_activities = array(ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_AGREE, ACTIVITY_DISAGREE, ACTIVITY_ABSTAIN, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE);
foreach($hidden_activities as $act) {
if(activity_match($item['verb'],$act)) {
return false;
@@ -491,7 +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');
- $conv_responses = array(array('like'),array('dislike'),array('agree'),array('disagree'),array('abstain'));
+ $conv_responses = array(array('like'),array('dislike'),array('agree'),array('disagree'),array('abstain'),array('attendyes'),array('attendno'),array('attendmaybe'));
// array with html for each thread (parent+comments)
$threads = array();
@@ -742,6 +742,14 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
// Can we put this after the visibility check?
like_puller($a, $item, $conv_responses, 'like');
like_puller($a, $item, $conv_responses, 'dislike');
+
+// if($item['object-type'] === ACTIVITY_OBJ_EVENT) {
+ like_puller($a, $item, $conv_responses, 'attendyes');
+ like_puller($a, $item, $conv_responses, 'attendno');
+ like_puller($a, $item, $conv_responses, 'attendmaybe');
+logger('responses: ' . print_r($conv_responses,true));
+
+
like_puller($a, $item, $conv_responses, 'agree');
like_puller($a, $item, $conv_responses, 'disagree');
like_puller($a, $item, $conv_responses, 'abstain');
@@ -934,12 +942,29 @@ function like_puller($a,$item,&$arr,$mode) {
case 'unabstain':
$verb = ACTIVITY_ABSTAIN;
break;
+ case 'attendyes':
+ case 'unattendyes':
+ $verb = ACTIVITY_ATTEND;
+ break;
+ case 'attendno':
+ case 'unattendno':
+ $verb = ACTIVITY_ATTENDNO;
+ break;
+ case 'attendmaybe':
+ case 'unattendmaybe':
+ $verb = ACTIVITY_ATTENDMAYBE;
+ break;
default:
return;
break;
}
+logger('verb: ' . $verb);
+if($verb === ACTIVITY_ATTENDNO)
+ logger('item: ' . $item['verb']);
+
if((activity_match($item['verb'],$verb)) && ($item['id'] != $item['parent'])) {
+logger('match:' . $verb);
$url = $item['author-link'];
if((local_user()) && (local_user() == $item['uid']) && ($item['network'] === NETWORK_DFRN) && (! $item['self']) && (link_compare($item['author-link'],$item['url']))) {
$url = $a->get_baseurl(true) . '/redir/' . $item['contact-id'];
@@ -951,7 +976,7 @@ function like_puller($a,$item,&$arr,$mode) {
if(! $item['thr-parent'])
$item['thr-parent'] = $item['parent-uri'];
- if(! ((isset($arr[$mode][$item['thr-parent'] . '-l'])) && (is_array($arr[$item['thr-parent'] . '-l']))))
+ 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[$mode][$item['thr-parent']]))
$arr[$mode][$item['thr-parent']] = 1;
@@ -1270,3 +1295,54 @@ function render_location_dummy($item) {
if ($item['coord'] != "")
return $item['coord'];
}
+
+function get_responses($conv_responses,$response_verbs,$ob,$item) {
+ $ret = array();
+ foreach($response_verbs as $v) {
+ $ret[$v] = array();
+ $ret[$v]['count'] = ((x($conv_responses[$v],$item['uri'])) ? $conv_responses[$v][$item['uri']] : '');
+ $ret[$v]['list'] = ((x($conv_responses[$v],$item['uri'])) ? $conv_responses[$v][$item['uri'] . '-l'] : '');
+ if(count($ret[$v]['list']) > MAX_LIKERS) {
+ $ret[$v]['list_part'] = array_slice($ret[$v]['list'], 0, MAX_LIKERS);
+ array_push($ret[$v]['list_part'], '' . t('View all') . '');
+ }
+ else {
+ $ret[$v]['list_part'] = '';
+ }
+ $ret[$v]['button'] = get_response_button_text($v,$ret[$v]['count']);
+ }
+ $ret['count'] = count($ret);
+ return $ret;
+}
+function get_response_button_text($v,$count) {
+ switch($v) {
+ case 'like':
+ return tt('Like','Likes',$count,'noun');
+ break;
+ case 'dislike':
+ return tt('Dislike','Dislikes',$count,'noun');
+ break;
+ case 'attendyes':
+ return tt('Attending','Attending',$count,'noun');
+ break;
+ case 'attendno':
+ return tt('Not Attending','Not Attending',$count,'noun');
+ break;
+ case 'attendmaybe':
+ return tt('Undecided','Undecided',$count,'noun');
+ break;
+ case 'agree':
+ return tt('Agree','Agrees',$count,'noun');
+ break;
+ case 'agree':
+ return tt('Disagree','Disagrees',$count,'noun');
+ break;
+ case 'abstain':
+ return tt('Abstain','Abstains',$count,'noun');
+ break;
+ default:
+ return '';
+ break;
+ }
+}
diff --git a/mod/like.php b/mod/like.php
index 6f0c5a5095..aef3473c30 100755
--- a/mod/like.php
+++ b/mod/like.php
@@ -38,6 +38,18 @@ function like_content(&$a) {
case 'unabstain':
$activity = ACTIVITY_ABSTAIN;
break;
+ case 'attendyes':
+ case 'unattendyes':
+ $activity = ACTIVITY_ATTEND;
+ break;
+ case 'attendno':
+ case 'unattendno':
+ $activity = ACTIVITY_ATTENDNO;
+ break;
+ case 'attendmaybe':
+ case 'unattendmaybe':
+ $activity = ACTIVITY_ATTENDMAYBE;
+ break;
default:
return;
break;
@@ -159,6 +171,8 @@ function like_content(&$a) {
$uri = item_new_uri($a->get_hostname(),$owner_uid);
$post_type = (($item['resource-id']) ? t('photo') : t('status'));
+ if($item['resource-type'] === 'event')
+ $post_type = t('event');
$objtype = (($item['resource-id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE );
$link = xmlify('' . "\n") ;
$body = $item['body'];
@@ -184,6 +198,12 @@ EOT;
$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($verb === 'attendyes')
+ $bodyverb = t('%1$s is attending %2$s\'s %3$s');
+ if($verb === 'attendno')
+ $bodyverb = t('%1$s is not attending %2$s\'s %3$s');
+ if($verb === 'attendmaybe')
+ $bodyverb = t('%1$s may attend %2$s\'s %3$s');
if(! isset($bodyverb))
return;
diff --git a/object/Item.php b/object/Item.php
index 7ff4c438c7..e680e29362 100644
--- a/object/Item.php
+++ b/object/Item.php
@@ -175,8 +175,51 @@ class Item extends BaseObject {
}
}*/
+
+ // process action responses - e.g. like/dislike/attend/agree/whatever
+ $response_verbs = array('like');
+ $response_verbs[] = 'dislike';
+ if($item['object-type'] === ACTIVITY_OBJ_EVENT) {
+ $response_verbs[] = 'attendyes';
+ $response_verbs[] = 'attendno';
+ $response_verbs[] = 'attendmaybe';
+ $isevent = true;
+ $attend = array( t('I will attend'), t('I will not attend'), t('I might attend'));
+ }
+ $consensus = (($item['item_flags'] & ITEM_CONSENSUS)? true : false);
+ if($consensus) {
+ $response_verbs[] = 'agree';
+ $response_verbs[] = 'disagree';
+ $response_verbs[] = 'abstain';
+ }
+ $responses = get_responses($conv_responses,$response_verbs,$this,$item);
+
+ // like_button_label from red -> needs to be removed
+ //$like_button_label = tt('Like','Likes',$like_count,'noun');
+
+ // another part from red - it is here for compatility - maybe removed later
+ $like_count = ((x($conv_responses['like'],$item['uri'])) ? $conv_responses['like'][$item['uri']] : '');
+ $like_list = ((x($conv_responses['like'],$item['uri'])) ? $conv_responses['like'][$item['uri'] . '-l'] : '');
+ if (count($like_list) > MAX_LIKERS) {
+ $like_list_part = array_slice($like_list, 0, MAX_LIKERS);
+ array_push($like_list_part, '' . t('View all') . '');
+ } else {
+ $like_list_part = '';
+ }
+ $like_button_label = tt('Like','Likes',$like_count,'noun');
+ $dislike_count = ((x($conv_responses['dislike'],$item['uri'])) ? $conv_responses['dislike'][$item['uri']] : '');
+ $dislike_list = ((x($conv_responses['dislike'],$item['uri'])) ? $conv_responses['dislike'][$item['uri'] . '-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);
+ array_push($dislike_list_part, '' . t('View all') . '');
+ } else {
+ $dislike_list_part = '';
+ }
+
$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']) : '');
+ $like = ((x($conv_responses['like'],$item['uri'])) ? format_like($conv_responses['like'][$item['uri']],$conv_responses['like'][$item['uri'] . '-l'],'like',$item['uri']) : '');
/*
* We should avoid doing this all the time, but it depends on the conversation mode
@@ -324,7 +367,9 @@ class Item extends BaseObject {
'body' => $body_e,
'text' => $text_e,
'id' => $this->get_id(),
- 'guid' => urlencode($item['guid']),
+ 'guid' => $item['guid'],
+ 'isevent' => $isevent,
+ 'attend' => $attend,
'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])),
'olinktitle' => sprintf( t('View %s\'s profile @ %s'), $this->get_owner_name(), ((strlen($item['owner-link'])) ? $item['owner-link'] : $item['url'])),
'to' => t('to'),
@@ -360,6 +405,7 @@ class Item extends BaseObject {
'vote' => $buttons,
'like' => $like,
'dislike' => $dislike,
+ 'responses' => $responses,
'switchcomment' => t('Comment'),
'comment' => $this->get_comment_box($indent),
'previewing' => ($conv->is_preview() ? ' preview ' : ''),
From f5c7006f30cf12f031737da72125abff238780d5 Mon Sep 17 00:00:00 2001
From: rabuzarus <>
Date: Wed, 3 Jun 2015 20:57:30 +0200
Subject: [PATCH 03/16] rest of the consensus porting work and integration into
friendica Credits to Mike Macgirvin for the code
---
include/conversation.php | 274 ++++++++++++++--------
include/features.php | 3 +-
mod/editpost.php | 12 +-
mod/item.php | 10 +
mod/like.php | 14 +-
object/Item.php | 58 ++---
view/templates/jot-header.tpl | 17 +-
view/templates/jot.tpl | 6 +
view/theme/vier/style.css | 13 +-
view/theme/vier/templates/wall_thread.tpl | 27 ++-
10 files changed, 285 insertions(+), 149 deletions(-)
diff --git a/include/conversation.php b/include/conversation.php
index cdc7ba3bd8..4924470875 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -491,7 +491,11 @@ 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');
- $conv_responses = array(array('like'),array('dislike'),array('agree'),array('disagree'),array('abstain'),array('attendyes'),array('attendno'),array('attendmaybe'));
+ $conv_responses = array(
+ 'like' => array('title' => t('Likes','title')),'dislike' => array('title' => t('Dislikes','title')),
+ 'agree' => array('title' => t('Agree','title')),'disagree' => array('title' => t('Disagree','title')), 'abstain' => array('title' => t('Abstain','title')),
+ 'attendyes' => array('title' => t('Attending','title')), 'attendno' => array('title' => t('Not attending','title')), 'attendmaybe' => array('title' => t('Might attend','title'))
+ );
// array with html for each thread (parent+comments)
$threads = array();
@@ -740,19 +744,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
// Can we put this after the visibility check?
- like_puller($a, $item, $conv_responses, 'like');
- like_puller($a, $item, $conv_responses, 'dislike');
-
-// if($item['object-type'] === ACTIVITY_OBJ_EVENT) {
- like_puller($a, $item, $conv_responses, 'attendyes');
- like_puller($a, $item, $conv_responses, 'attendno');
- like_puller($a, $item, $conv_responses, 'attendmaybe');
-logger('responses: ' . print_r($conv_responses,true));
-
-
- like_puller($a, $item, $conv_responses, 'agree');
- like_puller($a, $item, $conv_responses, 'disagree');
- like_puller($a, $item, $conv_responses, 'abstain');
+ builtin_activity_puller($item, $conv_responses);
// Only add what is visible
if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
@@ -916,107 +908,102 @@ function item_photo_menu($item){
return $o;
}}
-if(! function_exists('like_puller')) {
-function like_puller($a,$item,&$arr,$mode) {
+/**
+ * @brief Checks item to see if it is one of the builtin activities (like/dislike, event attendance, consensus items, etc.)
+ * Increments the count of each matching activity and adds a link to the author as needed.
+ *
+ * @param array $a (not used)
+ * @param array $item
+ * @param array &$conv_responses (already created with builtin activity structure)
+ * @return void
+ */
+if(! function_exists(builtin_activity_puller)) {
+function builtin_activity_puller($item, &$conv_responses) {
+ foreach($conv_responses as $mode => $v) {
+ $url = '';
+ $sparkle = '';
- $url = '';
- $sparkle = '';
- 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;
- case 'attendyes':
- case 'unattendyes':
- $verb = ACTIVITY_ATTEND;
- break;
- case 'attendno':
- case 'unattendno':
- $verb = ACTIVITY_ATTENDNO;
- break;
- case 'attendmaybe':
- case 'unattendmaybe':
- $verb = ACTIVITY_ATTENDMAYBE;
- break;
- default:
- return;
- break;
- }
-
-logger('verb: ' . $verb);
-if($verb === ACTIVITY_ATTENDNO)
- logger('item: ' . $item['verb']);
-
- if((activity_match($item['verb'],$verb)) && ($item['id'] != $item['parent'])) {
-logger('match:' . $verb);
- $url = $item['author-link'];
- if((local_user()) && (local_user() == $item['uid']) && ($item['network'] === NETWORK_DFRN) && (! $item['self']) && (link_compare($item['author-link'],$item['url']))) {
- $url = $a->get_baseurl(true) . '/redir/' . $item['contact-id'];
- $sparkle = ' class="sparkle" ';
+ switch($mode) {
+ case 'like':
+ $verb = ACTIVITY_LIKE;
+ break;
+ case 'dislike':
+ $verb = ACTIVITY_DISLIKE;
+ break;
+ case 'agree':
+ $verb = ACTIVITY_AGREE;
+ break;
+ case 'disagree':
+ $verb = ACTIVITY_DISAGREE;
+ break;
+ case 'abstain':
+ $verb = ACTIVITY_ABSTAIN;
+ break;
+ case 'attendyes':
+ $verb = ACTIVITY_ATTEND;
+ break;
+ case 'attendno':
+ $verb = ACTIVITY_ATTENDNO;
+ break;
+ case 'attendmaybe':
+ $verb = ACTIVITY_ATTENDMAYBE;
+ break;
+ default:
+ return;
+ break;
}
- else
- $url = zrl($url);
- if(! $item['thr-parent'])
- $item['thr-parent'] = $item['parent-uri'];
+ if((activity_match($item['verb'], $verb)) && ($item['id'] != $item['parent'])) {
+ $url = $item['author-link'];
+ if((local_user()) && (local_user() == $item['uid']) && ($item['network'] === NETWORK_DFRN) && (! $item['self']) && (link_compare($item['author-link'],$item['url']))) {
+ $url = z_root(true) . '/redir/' . $item['contact-id'];
+ $sparkle = ' class="sparkle" ';
+ }
+ else
+ $url = zrl($url);
+
+ $url = '' . $item['author-name'] . '';
- 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[$mode][$item['thr-parent']]))
- $arr[$mode][$item['thr-parent']] = 1;
- else
- $arr[$mode][$item['thr-parent']] ++;
+ if(! $item['thr-parent'])
+ $item['thr-parent'] = $item['parent-uri'];
- $arr[$mode][$item['thr-parent'] . '-l'][] = '' . $item['author-name'] . '';
+ if(! ((isset($conv_responses[$mode][$item['thr-parent'] . '-l']))
+ && (is_array($conv_responses[$mode][$item['thr-parent'] . '-l']))))
+ $conv_responses[$mode][$item['thr-parent'] . '-l'] = array();
+
+ // only list each unique author once
+ if(in_array($url,$conv_responses[$mode][$item['thr-parent'] . '-l']))
+ continue;
+
+ if(! isset($conv_responses[$mode][$item['thr-parent']]))
+ $conv_responses[$mode][$item['thr-parent']] = 1;
+ else
+ $conv_responses[$mode][$item['thr-parent']] ++;
+
+ $conv_responses[$mode][$item['thr-parent'] . '-l'][] = $url;
+
+ // there can only be one activity verb per item so if we found anything, we can stop looking
+ return;
+ }
}
- return;
}}
-// Format the like/dislike text for a profile item
-// $cnt = number of people who like/dislike the item
+// Format the vote text for a profile item
+// $cnt = number of people who vote the item
// $arr = array of pre-linked names of likers/dislikers
-// $type = one of 'like, 'dislike'
+// $type = one of 'like, 'dislike', 'attendyes', 'attendno', 'attendmaybe', 'agree', 'disagree', 'abstain'
// $id = item id
// returns formatted text
if(! function_exists('format_like')) {
function format_like($cnt,$arr,$type,$id) {
$o = '';
- if($cnt == 1)
- $o .= (($type === 'like') ? sprintf( t('%s likes this.'), $arr[0]) : sprintf( t('%s doesn\'t like this.'), $arr[0])) . EOL ;
- else {
- $spanatts = "class=\"fakelink\" onclick=\"openClose('{$type}list-$id');\"";
- switch($type) {
- case 'like':
- $phrase = sprintf( t('%2$d people like this'), $spanatts, $cnt);
- break;
- case 'dislike':
- $phrase = sprintf( t('%2$d people don\'t like this'), $spanatts, $cnt);
- break;
- }
- $phrase .= EOL ;
- $o .= replace_macros(get_markup_template('voting_fakelink.tpl'), array(
- '$phrase' => $phrase,
- '$type' => $type,
- '$id' => $id
- ));
+ $expanded = '';
+ if($cnt == 1)
+ $likers = $arr[0];
+
+ else {
$total = count($arr);
if($total >= MAX_LIKERS)
$arr = array_slice($arr, 0, MAX_LIKERS - 1);
@@ -1029,9 +1016,76 @@ function format_like($cnt,$arr,$type,$id) {
$str = implode(', ', $arr);
$str .= sprintf( t(', and %d other people'), $total - MAX_LIKERS );
}
- $str = (($type === 'like') ? sprintf( t('%s like this.'), $str) : sprintf( t('%s don\'t like this.'), $str));
- $o .= "\t" . '
' . $str . '
';
+
+ $likers = $str;
}
+
+ // Phrase if there is only one liker. In other cases it will be uses for the expanded
+ // list which show all likers
+ switch($type) {
+ case 'like' :
+ $phrase = sprintf( t('%s likes this.'), $likers);
+ break;
+ case 'dislike' :
+ $phrase = sprintf( t('%s doesn\'t like this.'), $likers);
+ break;
+ case 'attendyes' :
+ $phrase = sprintf( t('%s attends.'), $likers);
+ break;
+ case 'attendno' :
+ $phrase = sprintf( t('%s doesn\'t attend.'), $likers);
+ break;
+ case 'attendmaybe' :
+ $phrase = sprintf( t('%s attends maybe.'), $likers);
+ break;
+ case 'agree' :
+ $phrase = sprintf( t('%s agrees.'), $likers);
+ break;
+ case 'disagree' :
+ $phrase = sprintf( t('%s doesn\'t agree.'), $likers);
+ break;
+ case 'abstain' :
+ $phrase = sprintf( t('%s abstains.'), $likers);
+ break;
+ }
+
+ if($cnt > 1) {
+ $spanatts = "class=\"fakelink\" onclick=\"openClose('{$type}list-$id');\"";
+ $expanded .= "\t" . '' . $phrase . EOL . '
';
+ switch($type) {
+ case 'like':
+ $phrase = sprintf( t('%2$d people like this'), $spanatts, $cnt);
+ break;
+ case 'dislike':
+ $phrase = sprintf( t('%2$d people don\'t like this'), $spanatts, $cnt);
+ break;
+ case 'attendyes':
+ $phrase = sprintf( t('%2$d people attend'), $spanatts, $cnt);
+ break;
+ case 'attendno':
+ $phrase = sprintf( t('%2$d people don\'t attend'), $spanatts, $cnt);
+ break;
+ case 'attendmaybe':
+ $phrase = sprintf( t('%2$d people anttend maybe'), $spanatts, $cnt);
+ case 'agree':
+ $phrase = sprintf( t('%2$d people agree'), $spanatts, $cnt);
+ break;
+ case 'disagree':
+ $phrase = sprintf( t('%2$d people don\'t agree'), $spanatts, $cnt);
+ break;
+ case 'abstain':
+ $phrase = sprintf( t('%2$d people abstains'), $spanatts, $cnt);
+ }
+ }
+
+ $phrase .= EOL ;
+ $o .= replace_macros(get_markup_template('voting_fakelink.tpl'), array(
+ '$phrase' => $phrase,
+ '$type' => $type,
+ '$id' => $id
+ ));
+ $o .= $expanded;
+
return $o;
}}
@@ -1049,6 +1103,8 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
if( local_user() && feature_enabled(local_user(),'richtext') )
$plaintext = false;
+ $voting = feature_enabled(local_user(),'consensus_tools');
+
$tpl = get_markup_template('jot-header.tpl');
$a->page['htmlhead'] .= replace_macros($tpl, array(
'$newpost' => 'true',
@@ -1126,6 +1182,9 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
'$shortsetloc' => t('set location'),
'$noloc' => t('Clear browser location'),
'$shortnoloc' => t('clear location'),
+ '$voting' => t('Toggle voting'),
+ '$feature_voting' => $voting,
+ '$consensus' => 0,
'$title' => $x['title'],
'$placeholdertitle' => t('Set title'),
'$category' => $x['category'],
@@ -1311,10 +1370,19 @@ function get_responses($conv_responses,$response_verbs,$ob,$item) {
$ret[$v]['list_part'] = '';
}
$ret[$v]['button'] = get_response_button_text($v,$ret[$v]['count']);
+ $ret[$v]['title'] = $conv_responses[$v]['title'];
}
- $ret['count'] = count($ret);
+
+ $count = 0;
+ foreach($ret as $key) {
+ if ($key['count'] == true)
+ $count++;
+ }
+ $ret['count'] = $count;
+
return $ret;
}
+
function get_response_button_text($v,$count) {
switch($v) {
case 'like':
@@ -1335,7 +1403,7 @@ function get_response_button_text($v,$count) {
case 'agree':
return tt('Agree','Agrees',$count,'noun');
break;
- case 'agree':
+ case 'disagree':
return tt('Disagree','Disagrees',$count,'noun');
break;
case 'abstain':
diff --git a/include/features.php b/include/features.php
index 091dfc6e9d..b465fdbe03 100644
--- a/include/features.php
+++ b/include/features.php
@@ -29,8 +29,9 @@ function get_features() {
'composition' => array(
t('Post Composition Features'),
array('richtext', t('Richtext Editor'), t('Enable richtext editor')),
- array('preview', t('Post Preview'), t('Allow previewing posts and comments before publishing them')),
+ array('preview', t('Post Preview'), t('Allow previewing posts and comments before publishing them')),
array('aclautomention', t('Auto-mention Forums'), t('Add/remove mention when a fourm page is selected/deselected in ACL window.')),
+ array('consensus_tools', t('Enable voting tools'), t('Provide a class of post which others can vote on'),false),
),
// Network sidebar widgets
diff --git a/mod/editpost.php b/mod/editpost.php
index b039341023..4a3bdeddfe 100644
--- a/mod/editpost.php
+++ b/mod/editpost.php
@@ -93,15 +93,16 @@ function editpost_content(&$a) {
$jotnets .= ' '
. t("Post to Email") . '
';
}*/
-
+
call_hooks('jot_tool', $jotplugins);
//call_hooks('jot_networks', $jotnets);
- //$tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));
-
+ //$tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));
+
+ $voting = feature_enabled(local_user(),'consensus_tools');
$o .= replace_macros($tpl,array(
'$return_path' => $_SESSION['return_url'],
@@ -121,6 +122,11 @@ function editpost_content(&$a) {
'$shortsetloc' => t('set location'),
'$noloc' => t('Clear browser location'),
'$shortnoloc' => t('clear location'),
+ '$voting' => t('Toggle voting'),
+ '$feature_voting' => $voting,
+
+ // we need a solution for the red flags to make consensus work
+ '$consensus' => (($itm[0]['item_flags'] & ITEM_CONSENSUS) ? 1 : 0),
'$wait' => t('Please wait'),
'$permset' => t('Permission settings'),
'$ptyp' => $itm[0]['type'],
diff --git a/mod/item.php b/mod/item.php
index 91a94974e9..3baf618ca8 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -51,6 +51,7 @@ function item_post(&$a) {
$message_id = ((x($_REQUEST,'message_id') && $api_source) ? strip_tags($_REQUEST['message_id']) : '');
$return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
+ $consensus = intval($_REQUEST['consensus']);
$preview = ((x($_REQUEST,'preview')) ? intval($_REQUEST['preview']) : 0);
@@ -655,6 +656,15 @@ function item_post(&$a) {
if(!$thr_parent)
$thr_parent = $uri;
+
+ /* *
+ * to make consensus work, red requests the consensus flag from boot.php
+ * this have to be inserted into the lower $datarray
+ *
+ * if($consensus)
+ * $item_flags |= ITEM_CONSENSUS;
+ */
+
$datarray = array();
$datarray['uid'] = $profile_uid;
$datarray['type'] = $post_type;
diff --git a/mod/like.php b/mod/like.php
index aef3473c30..522fa87039 100755
--- a/mod/like.php
+++ b/mod/like.php
@@ -132,11 +132,21 @@ function like_content(&$a) {
// See if we've been passed a return path to redirect to
$return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
+ $verbs = " '".dbesc($activity)."' ";
- $r = q("SELECT `id`, `guid` FROM `item` WHERE `verb` = '%s' AND `deleted` = 0
+ // event participation and consensus items are essentially radio toggles. If you make a subsequent choice,
+ // we need to eradicate your first choice.
+ if($activity === ACTIVITY_ATTEND || $activity === ACTIVITY_ATTENDNO || $activity === ACTIVITY_ATTENDMAYBE) {
+ $verbs = " '" . dbesc(ACTIVITY_ATTEND) . "','" . dbesc(ACTIVITY_ATTENDNO) . "','" . dbesc(ACTIVITY_ATTENDMAYBE) . "' ";
+ }
+ if($activity === ACTIVITY_AGREE || $activity === ACTIVITY_DISAGREE || $activity === ACTIVITY_ABSTAIN) {
+ $verbs = " '" . dbesc(ACTIVITY_AGREE) . "','" . dbesc(ACTIVITY_DISAGREE) . "','" . dbesc(ACTIVITY_ABSTAIN) . "' ";
+ }
+
+ $r = q("SELECT `id`, `guid` FROM `item` WHERE `verb` IN ( $verbs ) AND `deleted` = 0
AND `contact-id` = %d AND `uid` = %d
AND (`parent` = '%s' OR `parent-uri` = '%s' OR `thr-parent` = '%s') LIMIT 1",
- dbesc($activity), intval($contact['id']), intval($owner_uid),
+ intval($contact['id']), intval($owner_uid),
dbesc($item_id), dbesc($item_id), dbesc($item['uri'])
);
diff --git a/object/Item.php b/object/Item.php
index e680e29362..d27be50ee2 100644
--- a/object/Item.php
+++ b/object/Item.php
@@ -175,7 +175,6 @@ class Item extends BaseObject {
}
}*/
-
// process action responses - e.g. like/dislike/attend/agree/whatever
$response_verbs = array('like');
$response_verbs[] = 'dislike';
@@ -183,43 +182,33 @@ class Item extends BaseObject {
$response_verbs[] = 'attendyes';
$response_verbs[] = 'attendno';
$response_verbs[] = 'attendmaybe';
- $isevent = true;
- $attend = array( t('I will attend'), t('I will not attend'), t('I might attend'));
+ if($conv->is_writable()) {
+ $isevent = true;
+ $attend = array( t('I will attend'), t('I will not attend'), t('I might attend'));
+ }
}
- $consensus = (($item['item_flags'] & ITEM_CONSENSUS)? true : false);
+
+ // red part for consensus
+ // we need a solution in friendica for missing item_flags
+ // to test $consensus with friendica set $consensus = true
+ // $consensus = (($item['item_flags'] & ITEM_CONSENSUS)? true : false);
+ $consensus = false;
+
if($consensus) {
$response_verbs[] = 'agree';
$response_verbs[] = 'disagree';
$response_verbs[] = 'abstain';
+ if($conv->is_writable()) {
+ $conlabels = array( t('I agree'), t('I disagree'), t('I abstain'));
+ $canvote = true;
+ }
}
$responses = get_responses($conv_responses,$response_verbs,$this,$item);
- // like_button_label from red -> needs to be removed
- //$like_button_label = tt('Like','Likes',$like_count,'noun');
+ foreach ($response_verbs as $value=>$verbs) {
+ $responses[$verbs][output] = ((x($conv_responses[$verbs],$item['uri'])) ? format_like($conv_responses[$verbs][$item['uri']],$conv_responses[$verbs][$item['uri'] . '-l'],$verbs,$item['uri']) : '');
- // another part from red - it is here for compatility - maybe removed later
- $like_count = ((x($conv_responses['like'],$item['uri'])) ? $conv_responses['like'][$item['uri']] : '');
- $like_list = ((x($conv_responses['like'],$item['uri'])) ? $conv_responses['like'][$item['uri'] . '-l'] : '');
- if (count($like_list) > MAX_LIKERS) {
- $like_list_part = array_slice($like_list, 0, MAX_LIKERS);
- array_push($like_list_part, '' . t('View all') . '');
- } else {
- $like_list_part = '';
}
- $like_button_label = tt('Like','Likes',$like_count,'noun');
- $dislike_count = ((x($conv_responses['dislike'],$item['uri'])) ? $conv_responses['dislike'][$item['uri']] : '');
- $dislike_list = ((x($conv_responses['dislike'],$item['uri'])) ? $conv_responses['dislike'][$item['uri'] . '-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);
- array_push($dislike_list_part, '' . t('View all') . '');
- } else {
- $dislike_list_part = '';
- }
-
- $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']) : '');
- $like = ((x($conv_responses['like'],$item['uri'])) ? format_like($conv_responses['like'][$item['uri']],$conv_responses['like'][$item['uri'] . '-l'],'like',$item['uri']) : '');
/*
* We should avoid doing this all the time, but it depends on the conversation mode
@@ -332,7 +321,7 @@ class Item extends BaseObject {
// Disable features that aren't available in several networks
if (($item["item_network"] != NETWORK_DFRN) AND isset($buttons["dislike"])) {
- unset($buttons["dislike"]);
+ unset($buttons["dislike"],$isevent,$consensus);
$tagger = '';
}
@@ -370,6 +359,9 @@ class Item extends BaseObject {
'guid' => $item['guid'],
'isevent' => $isevent,
'attend' => $attend,
+ 'consensus' => $consensus,
+ 'conlabels' => $conlabels,
+ 'canvote' => $canvote,
'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])),
'olinktitle' => sprintf( t('View %s\'s profile @ %s'), $this->get_owner_name(), ((strlen($item['owner-link'])) ? $item['owner-link'] : $item['url'])),
'to' => t('to'),
@@ -403,16 +395,16 @@ class Item extends BaseObject {
'filer' => ((feature_enabled($conv->get_profile_owner(),'filing')) ? $filer : ''),
'drop' => $drop,
'vote' => $buttons,
- 'like' => $like,
- 'dislike' => $dislike,
+ 'like' => $responses['like']['output'],
+ 'dislike' => $responses['dislike']['output'],
'responses' => $responses,
'switchcomment' => t('Comment'),
'comment' => $this->get_comment_box($indent),
'previewing' => ($conv->is_preview() ? ' preview ' : ''),
'wait' => t('Please wait'),
'thread_level' => $thread_level,
- 'postopts' => $langstr,
- 'edited' => $edited,
+ 'postopts' => $langstr,
+ 'edited' => $edited,
'network' => $item["item_network"],
'network_name' => network_to_name($item['item_network'], $profile_link),
);
diff --git a/view/templates/jot-header.tpl b/view/templates/jot-header.tpl
index 8d009fd40c..5095dc5d1a 100644
--- a/view/templates/jot-header.tpl
+++ b/view/templates/jot-header.tpl
@@ -21,7 +21,7 @@ function initEditor(cb){
$(".jothidden").show();
if (typeof cb!="undefined") cb();
return;
- }
+ }
tinyMCE.init({
theme : "advanced",
mode : "specific_textareas",
@@ -203,7 +203,7 @@ function enableOnUser(){
else {
checkedstr = $(this).val();
}
- }
+ }
});
$.post('item', { dropitems: checkedstr }, function(data) {
window.location.reload();
@@ -330,7 +330,18 @@ function enableOnUser(){
return false;
});
});
-
+
+ }
+
+ function toggleVoting() {
+ if($('#jot-consensus').val() > 0) {
+ $('#jot-consensus').val(0);
+ $('#profile-voting').removeClass('icon-check').addClass('icon-check-empty');
+ }
+ else {
+ $('#jot-consensus').val(1);
+ $('#profile-voting').removeClass('icon-check-empty').addClass('icon-check');
+ }
}
function jotClearLocation() {
diff --git a/view/templates/jot.tpl b/view/templates/jot.tpl
index dfc6b27104..5c60a5c09c 100644
--- a/view/templates/jot.tpl
+++ b/view/templates/jot.tpl
@@ -54,6 +54,12 @@
+ {{if $feature_voting}}
+
+ {{/if}}
+
diff --git a/view/theme/vier/style.css b/view/theme/vier/style.css
index 77ffb53fd1..526402f2e3 100644
--- a/view/theme/vier/style.css
+++ b/view/theme/vier/style.css
@@ -1347,11 +1347,15 @@ section.minimal {
width: 100%;
margin-bottom: 0.3em;
}
-.wall-item-container .wall-item-actions-social {
+.wall-item-container .wall-item-actions-social,
+.wall-item-container .wall-item-actions-isevent,
+.wall-item-container .wall-item-actions-canvote {
float: left;
margin-bottom: 1px;
}
-.wall-item-container .wall-item-actions-social a {
+.wall-item-container .wall-item-actions-social a,
+.wall-item-container .wall-item-actions-isevent a,
+.wall-item-container .wall-item-actions-canvote a{
float: left;
margin-right: 1em;
cursor: pointer;
@@ -1863,6 +1867,11 @@ section.minimal {
margin-left: 15px;
cursor: pointer;
}
+#profile-voting-wrapper {
+ float: left;
+ margin-left: 15px;
+ cursor: pointer;
+}
#profile-smiley-wrapper {
float: left;
margin-left: 15px;
diff --git a/view/theme/vier/templates/wall_thread.tpl b/view/theme/vier/templates/wall_thread.tpl
index 25b97a0cc5..05fbc14d00 100644
--- a/view/theme/vier/templates/wall_thread.tpl
+++ b/view/theme/vier/templates/wall_thread.tpl
@@ -118,7 +118,26 @@
{{$item.filer}}
{{/if}}
+
{{$item.location}} {{$item.postopts}}
+
+ {{if $item.isevent}}
+
+
+ {{/if}}
+
+ {{if $item.canvote}}
+
+
+ {{/if}}
{{if $item.drop.pagedrop}}
@@ -137,8 +156,12 @@
-
{{$item.like}}
-
{{$item.dislike}}
+ {{if $item.responses}}
+ {{foreach $item.responses as $verb=>$response}}
+
{{$response.output}}
+ {{/foreach}}
+ {{/if}}
+
{{if $item.threaded}}{{if $item.comment}}
From 2ff67ef5ed7e67d048fb54e1d2af8de49b84434f Mon Sep 17 00:00:00 2001
From: rabuzarus <>
Date: Thu, 4 Jun 2015 04:19:06 +0200
Subject: [PATCH 04/16] fixes like/dislike for photos
---
include/conversation.php | 4 ++--
mod/photos.php | 20 ++++++++++++++++----
object/Item.php | 1 +
3 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/include/conversation.php b/include/conversation.php
index 4924470875..0199bee5af 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -1364,8 +1364,8 @@ function get_responses($conv_responses,$response_verbs,$ob,$item) {
if(count($ret[$v]['list']) > MAX_LIKERS) {
$ret[$v]['list_part'] = array_slice($ret[$v]['list'], 0, MAX_LIKERS);
array_push($ret[$v]['list_part'], '
' . t('View all') . '');
- }
+ . (($ob) ? $ob->get_id() : $item['id']) . '">
' . t('View all') . '');
+ }
else {
$ret[$v]['list_part'] = '';
}
diff --git a/mod/photos.php b/mod/photos.php
index a19cfaaa72..2454f5d518 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -1601,18 +1601,23 @@ function photos_content(&$a) {
$like = '';
$dislike = '';
+ $conv_responses = array(
+ 'like' => array('title' => t('Likes','title')),'dislike' => array('title' => t('Dislikes','title')),
+ 'agree' => array('title' => t('Agree','title')),'disagree' => array('title' => t('Disagree','title')), 'abstain' => array('title' => t('Abstain','title')),
+ 'attendyes' => array('title' => t('Attending','title')), 'attendno' => array('title' => t('Not attending','title')), 'attendmaybe' => array('title' => t('Might attend','title'))
+ );
+
// display comments
if(count($r)) {
foreach($r as $item) {
- like_puller($a,$item,$alike,'like');
- like_puller($a,$item,$dlike,'dislike');
+ builtin_activity_puller($item, $conv_responses);
}
- $like = ((isset($alike[$link_item['id']])) ? format_like($alike[$link_item['id']],$alike[$link_item['id'] . '-l'],'like',$link_item['id']) : '');
- $dislike = ((isset($dlike[$link_item['id']])) ? format_like($dlike[$link_item['id']],$dlike[$link_item['id'] . '-l'],'dislike',$link_item['id']) : '');
+ $like = ((x($conv_responses['like'],$link_item['uri'])) ? format_like($conv_responses['like'][$link_item['uri']],$conv_responses['like'][$link_item['uri'] . '-l'],'like',$link_item['id']) : '');
+ $dislike = ((x($conv_responses['dislike'],$link_item['uri'])) ? format_like($conv_responses['dislike'][$link_item['uri']],$conv_responses['dislike'][$link_item['uri'] . '-l'],'dislike',$link_item['id']) : '');
@@ -1731,6 +1736,12 @@ function photos_content(&$a) {
$paginate = paginate($a);
}
+
+ $response_verbs = array('like');
+ if(feature_enabled($owner_uid,'dislike'))
+ $response_verbs[] = 'dislike';
+ $responses = get_responses($conv_responses,$response_verbs,'',$link_item);
+
$photo_tpl = get_markup_template('photo_view.tpl');
if($a->theme['template_engine'] === 'internal') {
@@ -1760,6 +1771,7 @@ function photos_content(&$a) {
'$likebuttons' => $likebuttons,
'$like' => $like_e,
'$dislike' => $dikslike_e,
+ 'responses' => $responses,
'$comments' => $comments,
'$paginate' => $paginate,
));
diff --git a/object/Item.php b/object/Item.php
index d27be50ee2..8b51f420c6 100644
--- a/object/Item.php
+++ b/object/Item.php
@@ -177,6 +177,7 @@ class Item extends BaseObject {
// process action responses - e.g. like/dislike/attend/agree/whatever
$response_verbs = array('like');
+ if(feature_enabled($conv->get_profile_owner(),'dislike'))
$response_verbs[] = 'dislike';
if($item['object-type'] === ACTIVITY_OBJ_EVENT) {
$response_verbs[] = 'attendyes';
From a13280ac4a10b4158289c825bed79261ceab5b10 Mon Sep 17 00:00:00 2001
From: rabuzarus <>
Date: Wed, 30 Sep 2015 15:30:13 +0200
Subject: [PATCH 05/16] revert little rebase mistake
---
object/Item.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/object/Item.php b/object/Item.php
index 8b51f420c6..4cd0a22528 100644
--- a/object/Item.php
+++ b/object/Item.php
@@ -357,7 +357,7 @@ class Item extends BaseObject {
'body' => $body_e,
'text' => $text_e,
'id' => $this->get_id(),
- 'guid' => $item['guid'],
+ 'guid' => urlencode($item['guid']),
'isevent' => $isevent,
'attend' => $attend,
'consensus' => $consensus,
From 7cb4ea52fd5ad84df71a0aa1a5f25d311cf1aa58 Mon Sep 17 00:00:00 2001
From: rabuzarus <>
Date: Wed, 30 Sep 2015 16:58:02 +0200
Subject: [PATCH 06/16] port of the event attendance feature of red matrix with
example implementation for vier theme.
---
boot.php | 3 --
include/conversation.php | 42 ++---------------------
include/features.php | 1 -
mod/editpost.php | 4 ---
mod/item.php | 10 ------
mod/like.php | 23 +------------
mod/photos.php | 1 -
object/Item.php | 20 +----------
view/templates/jot-header.tpl | 11 ------
view/templates/jot.tpl | 6 ----
view/theme/vier/style.css | 11 ++----
view/theme/vier/templates/wall_thread.tpl | 8 -----
12 files changed, 7 insertions(+), 133 deletions(-)
diff --git a/boot.php b/boot.php
index e3469b5509..875e5369ed 100644
--- a/boot.php
+++ b/boot.php
@@ -270,9 +270,6 @@ 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_ZOT . '/activity/agree' );
-define ( 'ACTIVITY_DISAGREE', NAMESPACE_ZOT . '/activity/disagree' );
-define ( 'ACTIVITY_ABSTAIN', NAMESPACE_ZOT . '/activity/abstain' );
define ( 'ACTIVITY_ATTEND', NAMESPACE_ZOT . '/activity/attendyes' );
define ( 'ACTIVITY_ATTENDNO', NAMESPACE_ZOT . '/activity/attendno' );
define ( 'ACTIVITY_ATTENDMAYBE', NAMESPACE_ZOT . '/activity/attendmaybe' );
diff --git a/include/conversation.php b/include/conversation.php
index 0199bee5af..c4605cf5d1 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -344,7 +344,7 @@ function visible_activity($item) {
// 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, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE);
+ $hidden_activities = array(ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE);
foreach($hidden_activities as $act) {
if(activity_match($item['verb'],$act)) {
return false;
@@ -492,8 +492,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
$hide_comments_tpl = get_markup_template('hide_comments.tpl');
$conv_responses = array(
- 'like' => array('title' => t('Likes','title')),'dislike' => array('title' => t('Dislikes','title')),
- 'agree' => array('title' => t('Agree','title')),'disagree' => array('title' => t('Disagree','title')), 'abstain' => array('title' => t('Abstain','title')),
+ 'like' => array('title' => t('Likes','title')), 'dislike' => array('title' => t('Dislikes','title')),
'attendyes' => array('title' => t('Attending','title')), 'attendno' => array('title' => t('Not attending','title')), 'attendmaybe' => array('title' => t('Might attend','title'))
);
@@ -930,15 +929,6 @@ function builtin_activity_puller($item, &$conv_responses) {
case 'dislike':
$verb = ACTIVITY_DISLIKE;
break;
- case 'agree':
- $verb = ACTIVITY_AGREE;
- break;
- case 'disagree':
- $verb = ACTIVITY_DISAGREE;
- break;
- case 'abstain':
- $verb = ACTIVITY_ABSTAIN;
- break;
case 'attendyes':
$verb = ACTIVITY_ATTEND;
break;
@@ -991,7 +981,7 @@ function builtin_activity_puller($item, &$conv_responses) {
// Format the vote text for a profile item
// $cnt = number of people who vote the item
// $arr = array of pre-linked names of likers/dislikers
-// $type = one of 'like, 'dislike', 'attendyes', 'attendno', 'attendmaybe', 'agree', 'disagree', 'abstain'
+// $type = one of 'like, 'dislike', 'attendyes', 'attendno', 'attendmaybe'
// $id = item id
// returns formatted text
@@ -1038,15 +1028,6 @@ function format_like($cnt,$arr,$type,$id) {
case 'attendmaybe' :
$phrase = sprintf( t('%s attends maybe.'), $likers);
break;
- case 'agree' :
- $phrase = sprintf( t('%s agrees.'), $likers);
- break;
- case 'disagree' :
- $phrase = sprintf( t('%s doesn\'t agree.'), $likers);
- break;
- case 'abstain' :
- $phrase = sprintf( t('%s abstains.'), $likers);
- break;
}
if($cnt > 1) {
@@ -1103,8 +1084,6 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
if( local_user() && feature_enabled(local_user(),'richtext') )
$plaintext = false;
- $voting = feature_enabled(local_user(),'consensus_tools');
-
$tpl = get_markup_template('jot-header.tpl');
$a->page['htmlhead'] .= replace_macros($tpl, array(
'$newpost' => 'true',
@@ -1182,9 +1161,6 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
'$shortsetloc' => t('set location'),
'$noloc' => t('Clear browser location'),
'$shortnoloc' => t('clear location'),
- '$voting' => t('Toggle voting'),
- '$feature_voting' => $voting,
- '$consensus' => 0,
'$title' => $x['title'],
'$placeholdertitle' => t('Set title'),
'$category' => $x['category'],
@@ -1400,17 +1376,5 @@ function get_response_button_text($v,$count) {
case 'attendmaybe':
return tt('Undecided','Undecided',$count,'noun');
break;
- case 'agree':
- return tt('Agree','Agrees',$count,'noun');
- break;
- case 'disagree':
- return tt('Disagree','Disagrees',$count,'noun');
- break;
- case 'abstain':
- return tt('Abstain','Abstains',$count,'noun');
- break;
- default:
- return '';
- break;
}
}
diff --git a/include/features.php b/include/features.php
index b465fdbe03..cc26141ac3 100644
--- a/include/features.php
+++ b/include/features.php
@@ -31,7 +31,6 @@ function get_features() {
array('richtext', t('Richtext Editor'), t('Enable richtext editor')),
array('preview', t('Post Preview'), t('Allow previewing posts and comments before publishing them')),
array('aclautomention', t('Auto-mention Forums'), t('Add/remove mention when a fourm page is selected/deselected in ACL window.')),
- array('consensus_tools', t('Enable voting tools'), t('Provide a class of post which others can vote on'),false),
),
// Network sidebar widgets
diff --git a/mod/editpost.php b/mod/editpost.php
index 4a3bdeddfe..c1f23800a3 100644
--- a/mod/editpost.php
+++ b/mod/editpost.php
@@ -123,10 +123,6 @@ function editpost_content(&$a) {
'$noloc' => t('Clear browser location'),
'$shortnoloc' => t('clear location'),
'$voting' => t('Toggle voting'),
- '$feature_voting' => $voting,
-
- // we need a solution for the red flags to make consensus work
- '$consensus' => (($itm[0]['item_flags'] & ITEM_CONSENSUS) ? 1 : 0),
'$wait' => t('Please wait'),
'$permset' => t('Permission settings'),
'$ptyp' => $itm[0]['type'],
diff --git a/mod/item.php b/mod/item.php
index 3baf618ca8..91a94974e9 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -51,7 +51,6 @@ function item_post(&$a) {
$message_id = ((x($_REQUEST,'message_id') && $api_source) ? strip_tags($_REQUEST['message_id']) : '');
$return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
- $consensus = intval($_REQUEST['consensus']);
$preview = ((x($_REQUEST,'preview')) ? intval($_REQUEST['preview']) : 0);
@@ -656,15 +655,6 @@ function item_post(&$a) {
if(!$thr_parent)
$thr_parent = $uri;
-
- /* *
- * to make consensus work, red requests the consensus flag from boot.php
- * this have to be inserted into the lower $datarray
- *
- * if($consensus)
- * $item_flags |= ITEM_CONSENSUS;
- */
-
$datarray = array();
$datarray['uid'] = $profile_uid;
$datarray['type'] = $post_type;
diff --git a/mod/like.php b/mod/like.php
index 522fa87039..4f6d6cd6d7 100755
--- a/mod/like.php
+++ b/mod/like.php
@@ -26,18 +26,6 @@ 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;
case 'attendyes':
case 'unattendyes':
$activity = ACTIVITY_ATTEND;
@@ -134,14 +122,11 @@ function like_content(&$a) {
$verbs = " '".dbesc($activity)."' ";
- // event participation and consensus items are essentially radio toggles. If you make a subsequent choice,
+ // event participation are essentially radio toggles. If you make a subsequent choice,
// we need to eradicate your first choice.
if($activity === ACTIVITY_ATTEND || $activity === ACTIVITY_ATTENDNO || $activity === ACTIVITY_ATTENDMAYBE) {
$verbs = " '" . dbesc(ACTIVITY_ATTEND) . "','" . dbesc(ACTIVITY_ATTENDNO) . "','" . dbesc(ACTIVITY_ATTENDMAYBE) . "' ";
}
- if($activity === ACTIVITY_AGREE || $activity === ACTIVITY_DISAGREE || $activity === ACTIVITY_ABSTAIN) {
- $verbs = " '" . dbesc(ACTIVITY_AGREE) . "','" . dbesc(ACTIVITY_DISAGREE) . "','" . dbesc(ACTIVITY_ABSTAIN) . "' ";
- }
$r = q("SELECT `id`, `guid` FROM `item` WHERE `verb` IN ( $verbs ) AND `deleted` = 0
AND `contact-id` = %d AND `uid` = %d
@@ -202,12 +187,6 @@ 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($verb === 'attendyes')
$bodyverb = t('%1$s is attending %2$s\'s %3$s');
if($verb === 'attendno')
diff --git a/mod/photos.php b/mod/photos.php
index 2454f5d518..ddfc1f345a 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -1603,7 +1603,6 @@ function photos_content(&$a) {
$conv_responses = array(
'like' => array('title' => t('Likes','title')),'dislike' => array('title' => t('Dislikes','title')),
- 'agree' => array('title' => t('Agree','title')),'disagree' => array('title' => t('Disagree','title')), 'abstain' => array('title' => t('Abstain','title')),
'attendyes' => array('title' => t('Attending','title')), 'attendno' => array('title' => t('Not attending','title')), 'attendmaybe' => array('title' => t('Might attend','title'))
);
diff --git a/object/Item.php b/object/Item.php
index 4cd0a22528..283745d34d 100644
--- a/object/Item.php
+++ b/object/Item.php
@@ -189,21 +189,6 @@ class Item extends BaseObject {
}
}
- // red part for consensus
- // we need a solution in friendica for missing item_flags
- // to test $consensus with friendica set $consensus = true
- // $consensus = (($item['item_flags'] & ITEM_CONSENSUS)? true : false);
- $consensus = false;
-
- if($consensus) {
- $response_verbs[] = 'agree';
- $response_verbs[] = 'disagree';
- $response_verbs[] = 'abstain';
- if($conv->is_writable()) {
- $conlabels = array( t('I agree'), t('I disagree'), t('I abstain'));
- $canvote = true;
- }
- }
$responses = get_responses($conv_responses,$response_verbs,$this,$item);
foreach ($response_verbs as $value=>$verbs) {
@@ -322,7 +307,7 @@ class Item extends BaseObject {
// Disable features that aren't available in several networks
if (($item["item_network"] != NETWORK_DFRN) AND isset($buttons["dislike"])) {
- unset($buttons["dislike"],$isevent,$consensus);
+ unset($buttons["dislike"],$isevent);
$tagger = '';
}
@@ -360,9 +345,6 @@ class Item extends BaseObject {
'guid' => urlencode($item['guid']),
'isevent' => $isevent,
'attend' => $attend,
- 'consensus' => $consensus,
- 'conlabels' => $conlabels,
- 'canvote' => $canvote,
'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])),
'olinktitle' => sprintf( t('View %s\'s profile @ %s'), $this->get_owner_name(), ((strlen($item['owner-link'])) ? $item['owner-link'] : $item['url'])),
'to' => t('to'),
diff --git a/view/templates/jot-header.tpl b/view/templates/jot-header.tpl
index 5095dc5d1a..cb841c314d 100644
--- a/view/templates/jot-header.tpl
+++ b/view/templates/jot-header.tpl
@@ -333,17 +333,6 @@ function enableOnUser(){
}
- function toggleVoting() {
- if($('#jot-consensus').val() > 0) {
- $('#jot-consensus').val(0);
- $('#profile-voting').removeClass('icon-check').addClass('icon-check-empty');
- }
- else {
- $('#jot-consensus').val(1);
- $('#profile-voting').removeClass('icon-check-empty').addClass('icon-check');
- }
- }
-
function jotClearLocation() {
$('#jot-coord').val('');
$('#profile-nolocation-wrapper').hide();
diff --git a/view/templates/jot.tpl b/view/templates/jot.tpl
index 5c60a5c09c..dfc6b27104 100644
--- a/view/templates/jot.tpl
+++ b/view/templates/jot.tpl
@@ -54,12 +54,6 @@
- {{if $feature_voting}}
-
- {{/if}}
-
diff --git a/view/theme/vier/style.css b/view/theme/vier/style.css
index 526402f2e3..2fc68dbb05 100644
--- a/view/theme/vier/style.css
+++ b/view/theme/vier/style.css
@@ -1348,14 +1348,12 @@ section.minimal {
margin-bottom: 0.3em;
}
.wall-item-container .wall-item-actions-social,
-.wall-item-container .wall-item-actions-isevent,
-.wall-item-container .wall-item-actions-canvote {
+.wall-item-container .wall-item-actions-isevent {
float: left;
margin-bottom: 1px;
}
.wall-item-container .wall-item-actions-social a,
-.wall-item-container .wall-item-actions-isevent a,
-.wall-item-container .wall-item-actions-canvote a{
+.wall-item-container .wall-item-actions-isevent a {
float: left;
margin-right: 1em;
cursor: pointer;
@@ -1867,11 +1865,6 @@ section.minimal {
margin-left: 15px;
cursor: pointer;
}
-#profile-voting-wrapper {
- float: left;
- margin-left: 15px;
- cursor: pointer;
-}
#profile-smiley-wrapper {
float: left;
margin-left: 15px;
diff --git a/view/theme/vier/templates/wall_thread.tpl b/view/theme/vier/templates/wall_thread.tpl
index 05fbc14d00..e6b0de84bd 100644
--- a/view/theme/vier/templates/wall_thread.tpl
+++ b/view/theme/vier/templates/wall_thread.tpl
@@ -130,14 +130,6 @@
{{/if}}
- {{if $item.canvote}}
-
-
- {{/if}}
{{if $item.drop.pagedrop}}
From f93a2242e03377f9ae1c866be05c219434611e72 Mon Sep 17 00:00:00 2001
From: rabuzarus <>
Date: Sun, 4 Oct 2015 01:00:24 +0200
Subject: [PATCH 07/16] missed one to delete
---
mod/editpost.php | 3 ---
1 file changed, 3 deletions(-)
diff --git a/mod/editpost.php b/mod/editpost.php
index c1f23800a3..0cf6d0d4cf 100644
--- a/mod/editpost.php
+++ b/mod/editpost.php
@@ -102,8 +102,6 @@ function editpost_content(&$a) {
//$tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));
- $voting = feature_enabled(local_user(),'consensus_tools');
-
$o .= replace_macros($tpl,array(
'$return_path' => $_SESSION['return_url'],
'$action' => 'item',
@@ -122,7 +120,6 @@ function editpost_content(&$a) {
'$shortsetloc' => t('set location'),
'$noloc' => t('Clear browser location'),
'$shortnoloc' => t('clear location'),
- '$voting' => t('Toggle voting'),
'$wait' => t('Please wait'),
'$permset' => t('Permission settings'),
'$ptyp' => $itm[0]['type'],
From d2d084b8144e1fb9e937bf8a09953c14fb7a24c7 Mon Sep 17 00:00:00 2001
From: rabuzarus <>
Date: Thu, 8 Oct 2015 18:35:33 +0200
Subject: [PATCH 08/16] treat attendance as like activity
---
include/items.php | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/include/items.php b/include/items.php
index 0d442e3170..a5d2c36911 100644
--- a/include/items.php
+++ b/include/items.php
@@ -2751,7 +2751,11 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
$datarray['parent-uri'] = $parent_uri;
$datarray['uid'] = $importer['uid'];
$datarray['contact-id'] = $contact['id'];
- if((activity_match($datarray['verb'],ACTIVITY_LIKE)) || (activity_match($datarray['verb'],ACTIVITY_DISLIKE))) {
+ if(($datarray['verb'] === ACTIVITY_LIKE)
+ || ($datarray['verb'] === ACTIVITY_DISLIKE)
+ || ($datarray['verb'] === ACTIVITY_ATTEND)
+ || ($datarray['verb'] === ACTIVITY_ATTENDNO)
+ || ($datarray['verb'] === ACTIVITY_ATTENDMAYBE)) {
$datarray['type'] = 'activity';
$datarray['gravity'] = GRAVITY_LIKE;
// only one like or dislike per person
@@ -3738,7 +3742,11 @@ function local_delivery($importer,$data) {
$datarray['owner-avatar'] = $own[0]['thumb'];
$datarray['contact-id'] = $importer['id'];
- if(($datarray['verb'] === ACTIVITY_LIKE) || ($datarray['verb'] === ACTIVITY_DISLIKE)) {
+ if(($datarray['verb'] === ACTIVITY_LIKE)
+ || ($datarray['verb'] === ACTIVITY_DISLIKE)
+ || ($datarray['verb'] === ACTIVITY_ATTEND)
+ || ($datarray['verb'] === ACTIVITY_ATTENDNO)
+ || ($datarray['verb'] === ACTIVITY_ATTENDMAYBE)) {
$is_like = true;
$datarray['type'] = 'activity';
$datarray['gravity'] = GRAVITY_LIKE;
@@ -3927,7 +3935,11 @@ function local_delivery($importer,$data) {
$datarray['parent-uri'] = $parent_uri;
$datarray['uid'] = $importer['importer_uid'];
$datarray['contact-id'] = $importer['id'];
- if(($datarray['verb'] == ACTIVITY_LIKE) || ($datarray['verb'] == ACTIVITY_DISLIKE)) {
+ if(($datarray['verb'] === ACTIVITY_LIKE)
+ || ($datarray['verb'] === ACTIVITY_DISLIKE)
+ || ($datarray['verb'] === ACTIVITY_ATTEND)
+ || ($datarray['verb'] === ACTIVITY_ATTENDNO)
+ || ($datarray['verb'] === ACTIVITY_ATTENDMAYBE)) {
$datarray['type'] = 'activity';
$datarray['gravity'] = GRAVITY_LIKE;
// only one like or dislike per person
From 6a9ec1487829003f77079ec7efcf7df1d41445ce Mon Sep 17 00:00:00 2001
From: rabuzarus <>
Date: Thu, 8 Oct 2015 20:26:11 +0200
Subject: [PATCH 09/16] small bugfix in like.php
---
mod/like.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mod/like.php b/mod/like.php
index 4f6d6cd6d7..90782687d3 100755
--- a/mod/like.php
+++ b/mod/like.php
@@ -166,7 +166,7 @@ function like_content(&$a) {
$uri = item_new_uri($a->get_hostname(),$owner_uid);
$post_type = (($item['resource-id']) ? t('photo') : t('status'));
- if($item['resource-type'] === 'event')
+ if($item['obj_type'] === ACTIVITY_OBJ_EVENT)
$post_type = t('event');
$objtype = (($item['resource-id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE );
$link = xmlify('
' . "\n") ;
From ba1207e6e1a69570da9a4f91121defc9d81a9a6e Mon Sep 17 00:00:00 2001
From: rabuzarus <>
Date: Thu, 8 Oct 2015 22:23:09 +0200
Subject: [PATCH 10/16] translate attendance with localize_item()
---
include/conversation.php | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/include/conversation.php b/include/conversation.php
index c4605cf5d1..5bc6525b72 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -100,7 +100,11 @@ function localize_item(&$item){
$item['body'] = item_redir_and_replace_images($extracted['body'], $extracted['images'], $item['contact-id']);
$xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
- if (activity_match($item['verb'],ACTIVITY_LIKE) || activity_match($item['verb'],ACTIVITY_DISLIKE)){
+ if (activity_match($item['verb'],ACTIVITY_LIKE)
+ || activity_match($item['verb'],ACTIVITY_DISLIKE)
+ || activity_match($item['verb'],ACTIVITY_ATTEND)
+ || activity_match($item['verb'],ACTIVITY_ATTENDNO)
+ || activity_match($item['verb'],ACTIVITY_ATTENDMAYBE)){
$r = q("SELECT * from `item`,`contact` WHERE
`item`.`contact-id`=`contact`.`id` AND `item`.`uri`='%s';",
@@ -139,6 +143,15 @@ function localize_item(&$item){
elseif(activity_match($item['verb'],ACTIVITY_DISLIKE)) {
$bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s');
}
+ elseif(activity_match($item['verb'],ACTIVITY_ATTEND)) {
+ $bodyverb = t('%1$s attends %2$s\'s %3$s');
+ }
+ elseif(activity_match($item['verb'],ACTIVITY_ATTENDNO)) {
+ $bodyverb = t('%1$s doesn\'t attend %2$s\'s %3$s');
+ }
+ elseif(activity_match($item['verb'],ACTIVITY_ATTENDMAYBE)) {
+ $bodyverb = t('%1$s attends maybe %2$s\'s %3$s');
+ }
$item['body'] = sprintf($bodyverb, $author, $objauthor, $plink);
}
From d85d215bb86a7777467727fa4564b3018e4632eb Mon Sep 17 00:00:00 2001
From: rabuzarus <>
Date: Fri, 9 Oct 2015 13:46:08 +0200
Subject: [PATCH 11/16] attendance update in network stream
---
mod/network.php | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/mod/network.php b/mod/network.php
index a92e0c691b..9daec49761 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -732,7 +732,10 @@ function network_content(&$a, $update = 0) {
// Fetch a page full of parent items for this page
if($update) {
if (!get_config("system", "like_no_comment"))
- $sql_extra4 = "(`item`.`deleted` = 0 OR `item`.`verb` = '".ACTIVITY_LIKE."' OR `item`.`verb` = '".ACTIVITY_DISLIKE."')";
+ $sql_extra4 = "(`item`.`deleted` = 0
+ OR `item`.`verb` = '".ACTIVITY_LIKE."' OR `item`.`verb` = '".ACTIVITY_DISLIKE."'
+ OR `item`.`verb` = '".ACTIVITY_ATTEND."' OR `item`.`verb` = '".ACTIVITY_ATTENDNO."'
+ OR `item`.`verb` = '".ACTIVITY_ATTENDMAYBE."')";
else
$sql_extra4 = "`item`.`deleted` = 0 AND `item`.`verb` = '".ACTIVITY_POST."'";
From 0eae67ea48dbce33f0037bc1f77aa71c42f2df02 Mon Sep 17 00:00:00 2001
From: rabuzarus <>
Date: Fri, 9 Oct 2015 14:20:01 +0200
Subject: [PATCH 12/16] update attendance state on profile wall
---
include/conversation.php | 6 +++---
include/items.php | 14 +++++++-------
mod/network.php | 6 +++---
mod/profile.php | 6 ++++--
4 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/include/conversation.php b/include/conversation.php
index 5bc6525b72..fd03f4b788 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -101,9 +101,9 @@ function localize_item(&$item){
$xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
if (activity_match($item['verb'],ACTIVITY_LIKE)
- || activity_match($item['verb'],ACTIVITY_DISLIKE)
- || activity_match($item['verb'],ACTIVITY_ATTEND)
- || activity_match($item['verb'],ACTIVITY_ATTENDNO)
+ || activity_match($item['verb'],ACTIVITY_DISLIKE)
+ || activity_match($item['verb'],ACTIVITY_ATTEND)
+ || activity_match($item['verb'],ACTIVITY_ATTENDNO)
|| activity_match($item['verb'],ACTIVITY_ATTENDMAYBE)){
$r = q("SELECT * from `item`,`contact` WHERE
diff --git a/include/items.php b/include/items.php
index a5d2c36911..ad41a0380d 100644
--- a/include/items.php
+++ b/include/items.php
@@ -2751,9 +2751,9 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
$datarray['parent-uri'] = $parent_uri;
$datarray['uid'] = $importer['uid'];
$datarray['contact-id'] = $contact['id'];
- if(($datarray['verb'] === ACTIVITY_LIKE)
- || ($datarray['verb'] === ACTIVITY_DISLIKE)
- || ($datarray['verb'] === ACTIVITY_ATTEND)
+ if(($datarray['verb'] === ACTIVITY_LIKE)
+ || ($datarray['verb'] === ACTIVITY_DISLIKE)
+ || ($datarray['verb'] === ACTIVITY_ATTEND)
|| ($datarray['verb'] === ACTIVITY_ATTENDNO)
|| ($datarray['verb'] === ACTIVITY_ATTENDMAYBE)) {
$datarray['type'] = 'activity';
@@ -3743,8 +3743,8 @@ function local_delivery($importer,$data) {
$datarray['contact-id'] = $importer['id'];
if(($datarray['verb'] === ACTIVITY_LIKE)
- || ($datarray['verb'] === ACTIVITY_DISLIKE)
- || ($datarray['verb'] === ACTIVITY_ATTEND)
+ || ($datarray['verb'] === ACTIVITY_DISLIKE)
+ || ($datarray['verb'] === ACTIVITY_ATTEND)
|| ($datarray['verb'] === ACTIVITY_ATTENDNO)
|| ($datarray['verb'] === ACTIVITY_ATTENDMAYBE)) {
$is_like = true;
@@ -3936,8 +3936,8 @@ function local_delivery($importer,$data) {
$datarray['uid'] = $importer['importer_uid'];
$datarray['contact-id'] = $importer['id'];
if(($datarray['verb'] === ACTIVITY_LIKE)
- || ($datarray['verb'] === ACTIVITY_DISLIKE)
- || ($datarray['verb'] === ACTIVITY_ATTEND)
+ || ($datarray['verb'] === ACTIVITY_DISLIKE)
+ || ($datarray['verb'] === ACTIVITY_ATTEND)
|| ($datarray['verb'] === ACTIVITY_ATTENDNO)
|| ($datarray['verb'] === ACTIVITY_ATTENDMAYBE)) {
$datarray['type'] = 'activity';
diff --git a/mod/network.php b/mod/network.php
index 9daec49761..9389c07e1b 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -732,9 +732,9 @@ function network_content(&$a, $update = 0) {
// Fetch a page full of parent items for this page
if($update) {
if (!get_config("system", "like_no_comment"))
- $sql_extra4 = "(`item`.`deleted` = 0
- OR `item`.`verb` = '".ACTIVITY_LIKE."' OR `item`.`verb` = '".ACTIVITY_DISLIKE."'
- OR `item`.`verb` = '".ACTIVITY_ATTEND."' OR `item`.`verb` = '".ACTIVITY_ATTENDNO."'
+ $sql_extra4 = "(`item`.`deleted` = 0
+ OR `item`.`verb` = '".ACTIVITY_LIKE."' OR `item`.`verb` = '".ACTIVITY_DISLIKE."'
+ OR `item`.`verb` = '".ACTIVITY_ATTEND."' OR `item`.`verb` = '".ACTIVITY_ATTENDNO."'
OR `item`.`verb` = '".ACTIVITY_ATTENDMAYBE."')";
else
$sql_extra4 = "`item`.`deleted` = 0 AND `item`.`verb` = '".ACTIVITY_POST."'";
diff --git a/mod/profile.php b/mod/profile.php
index 608971d08d..b7b76cbb5b 100644
--- a/mod/profile.php
+++ b/mod/profile.php
@@ -221,8 +221,10 @@ function profile_content(&$a, $update = 0) {
FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND
- (`item`.`deleted` = 0 OR item.verb = '" . ACTIVITY_LIKE ."' OR item.verb = '" . ACTIVITY_DISLIKE . "')
- and `item`.`moderated` = 0 and `item`.`unseen` = 1
+ (`item`.`deleted` = 0 OR item.verb = '" . ACTIVITY_LIKE ."'
+ OR item.verb = '" . ACTIVITY_DISLIKE . "' OR item.verb = '" . ACTIVITY_ATTEND . "'
+ OR item.verb = '" . ACTIVITY_ATTENDNO . "' OR item.verb = '" . ACTIVITY_ATTENDMAYBE . "')
+ AND `item`.`moderated` = 0 and `item`.`unseen` = 1
AND `item`.`wall` = 1
$sql_extra
ORDER BY `item`.`created` DESC",
From 0b36b09823396834379b622c225d023b90366323 Mon Sep 17 00:00:00 2001
From: rabuzarus <>
Date: Sun, 11 Oct 2015 13:07:19 +0200
Subject: [PATCH 13/16] don't send attendance activities to diaspora
(unsupported)
---
include/delivery.php | 13 +++++++++----
include/notifier.php | 13 +++++++++----
2 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/include/delivery.php b/include/delivery.php
index a913e13170..3b554370f5 100644
--- a/include/delivery.php
+++ b/include/delivery.php
@@ -520,11 +520,16 @@ function delivery_run(&$argv, &$argc){
if((! $contact['pubkey']) && (! $public_message))
break;
- if($target_item['verb'] === ACTIVITY_DISLIKE) {
- // unsupported
- break;
+ $unsupported_activities = array(ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE);
+
+ //don't transmit activities which are not supported by diaspora
+ foreach($unsupported_activities as $act) {
+ if(activity_match($target_item['verb'],$act)) {
+ break 2;
+ }
}
- elseif(($target_item['deleted']) && ($target_item['uri'] === $target_item['parent-uri'])) {
+
+ if(($target_item['deleted']) && ($target_item['uri'] === $target_item['parent-uri'])) {
// top-level retraction
logger('delivery: diaspora retract: ' . $loc);
diff --git a/include/notifier.php b/include/notifier.php
index d4d254f1c9..4d97649c95 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -908,11 +908,16 @@ function notifier_run(&$argv, &$argc){
if(! $contact['pubkey'])
break;
- if($target_item['verb'] === ACTIVITY_DISLIKE) {
- // unsupported
- break;
+ $unsupported_activities = array(ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE);
+
+ //don't transmit activities which are not supported by diaspora
+ foreach($unsupported_activities as $act) {
+ if(activity_match($target_item['verb'],$act)) {
+ break 2;
+ }
}
- elseif(($target_item['deleted']) && (($target_item['uri'] === $target_item['parent-uri']) || $followup)) {
+
+ if(($target_item['deleted']) && (($target_item['uri'] === $target_item['parent-uri']) || $followup)) {
// send both top-level retractions and relayable retractions for owner to relay
diaspora_send_retraction($target_item,$owner,$contact);
break;
From 6f04c57ed389232afb36c4ce0ed1d089f30a2672 Mon Sep 17 00:00:00 2001
From: rabuzarus <>
Date: Sun, 11 Oct 2015 15:34:56 +0200
Subject: [PATCH 14/16] correct a little mistake (ACTIVITY_LIKE is supported)
---
include/notifier.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/notifier.php b/include/notifier.php
index 4d97649c95..0f9cc80464 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -908,7 +908,7 @@ function notifier_run(&$argv, &$argc){
if(! $contact['pubkey'])
break;
- $unsupported_activities = array(ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE);
+ $unsupported_activities = array(ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE);
//don't transmit activities which are not supported by diaspora
foreach($unsupported_activities as $act) {
From a539455d813d99c5737ed4fa2e868278978fbf8b Mon Sep 17 00:00:00 2001
From: rabuzarus <>
Date: Sun, 11 Oct 2015 18:20:06 +0200
Subject: [PATCH 15/16] correct a little mistake (delivery.php was not
commited)
---
include/delivery.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/delivery.php b/include/delivery.php
index 3b554370f5..659add2ad6 100644
--- a/include/delivery.php
+++ b/include/delivery.php
@@ -520,7 +520,7 @@ function delivery_run(&$argv, &$argc){
if((! $contact['pubkey']) && (! $public_message))
break;
- $unsupported_activities = array(ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE);
+ $unsupported_activities = array(ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE);
//don't transmit activities which are not supported by diaspora
foreach($unsupported_activities as $act) {
From 5c2923869ac02e2bb39074640c37264504434912 Mon Sep 17 00:00:00 2001
From: rabuzarus <>
Date: Sun, 11 Oct 2015 20:00:54 +0200
Subject: [PATCH 16/16] this got lost by merge
---
include/conversation.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/conversation.php b/include/conversation.php
index 7417dbf812..0907b5dce2 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -987,7 +987,7 @@ function builtin_activity_puller($item, &$conv_responses) {
else
$url = zrl($url);
- $url = '
' . $item['author-name'] . '';
+ $url = '
' . htmlentities($item['author-name']) . '';
if(! $item['thr-parent'])
$item['thr-parent'] = $item['parent-uri'];