From 7cb4ea52fd5ad84df71a0aa1a5f25d311cf1aa58 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Wed, 30 Sep 2015 16:58:02 +0200 Subject: [PATCH] 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 e3469b550..875e5369e 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 0199bee5a..c4605cf5d 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 b465fdbe0..cc26141ac 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 4a3bdeddf..c1f23800a 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 3baf618ca..91a94974e 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 522fa8703..4f6d6cd6d 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 2454f5d51..ddfc1f345 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 4cd0a2252..283745d34 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 5095dc5d1..cb841c314 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 5c60a5c09..dfc6b2710 100644 --- a/view/templates/jot.tpl +++ b/view/templates/jot.tpl @@ -54,12 +54,6 @@ - {{if $feature_voting}} -
- -
- {{/if}} -
{{$bang}}
diff --git a/view/theme/vier/style.css b/view/theme/vier/style.css index 526402f2e..2fc68dbb0 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 05fbc14d0..e6b0de84b 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}}