port of the event attendance feature of red matrix with example implementation for vier theme.

This commit is contained in:
rabuzarus 2015-09-30 16:58:02 +02:00
parent a13280ac4a
commit 7cb4ea52fd
12 changed files with 7 additions and 133 deletions

View file

@ -270,9 +270,6 @@ define ( 'NAMESPACE_ATOM1', 'http://www.w3.org/2005/Atom' );
define ( 'ACTIVITY_LIKE', NAMESPACE_ACTIVITY_SCHEMA . 'like' ); define ( 'ACTIVITY_LIKE', NAMESPACE_ACTIVITY_SCHEMA . 'like' );
define ( 'ACTIVITY_DISLIKE', NAMESPACE_DFRN . '/dislike' ); 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_ATTEND', NAMESPACE_ZOT . '/activity/attendyes' );
define ( 'ACTIVITY_ATTENDNO', NAMESPACE_ZOT . '/activity/attendno' ); define ( 'ACTIVITY_ATTENDNO', NAMESPACE_ZOT . '/activity/attendno' );
define ( 'ACTIVITY_ATTENDMAYBE', NAMESPACE_ZOT . '/activity/attendmaybe' ); define ( 'ACTIVITY_ATTENDMAYBE', NAMESPACE_ZOT . '/activity/attendmaybe' );

View file

@ -344,7 +344,7 @@ function visible_activity($item) {
// likes (etc.) can apply to other things besides posts. Check if they are post children, // likes (etc.) can apply to other things besides posts. Check if they are post children,
// in which case we handle them specially // 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) { foreach($hidden_activities as $act) {
if(activity_match($item['verb'],$act)) { if(activity_match($item['verb'],$act)) {
return false; return false;
@ -492,8 +492,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
$hide_comments_tpl = get_markup_template('hide_comments.tpl'); $hide_comments_tpl = get_markup_template('hide_comments.tpl');
$conv_responses = array( $conv_responses = array(
'like' => array('title' => t('Likes','title')),'dislike' => array('title' => t('Dislikes','title')), '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')) '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': case 'dislike':
$verb = ACTIVITY_DISLIKE; $verb = ACTIVITY_DISLIKE;
break; break;
case 'agree':
$verb = ACTIVITY_AGREE;
break;
case 'disagree':
$verb = ACTIVITY_DISAGREE;
break;
case 'abstain':
$verb = ACTIVITY_ABSTAIN;
break;
case 'attendyes': case 'attendyes':
$verb = ACTIVITY_ATTEND; $verb = ACTIVITY_ATTEND;
break; break;
@ -991,7 +981,7 @@ function builtin_activity_puller($item, &$conv_responses) {
// Format the vote text for a profile item // Format the vote text for a profile item
// $cnt = number of people who vote the item // $cnt = number of people who vote the item
// $arr = array of pre-linked names of likers/dislikers // $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 // $id = item id
// returns formatted text // returns formatted text
@ -1038,15 +1028,6 @@ function format_like($cnt,$arr,$type,$id) {
case 'attendmaybe' : case 'attendmaybe' :
$phrase = sprintf( t('%s attends maybe.'), $likers); $phrase = sprintf( t('%s attends maybe.'), $likers);
break; 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) { 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') ) if( local_user() && feature_enabled(local_user(),'richtext') )
$plaintext = false; $plaintext = false;
$voting = feature_enabled(local_user(),'consensus_tools');
$tpl = get_markup_template('jot-header.tpl'); $tpl = get_markup_template('jot-header.tpl');
$a->page['htmlhead'] .= replace_macros($tpl, array( $a->page['htmlhead'] .= replace_macros($tpl, array(
'$newpost' => 'true', '$newpost' => 'true',
@ -1182,9 +1161,6 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
'$shortsetloc' => t('set location'), '$shortsetloc' => t('set location'),
'$noloc' => t('Clear browser location'), '$noloc' => t('Clear browser location'),
'$shortnoloc' => t('clear location'), '$shortnoloc' => t('clear location'),
'$voting' => t('Toggle voting'),
'$feature_voting' => $voting,
'$consensus' => 0,
'$title' => $x['title'], '$title' => $x['title'],
'$placeholdertitle' => t('Set title'), '$placeholdertitle' => t('Set title'),
'$category' => $x['category'], '$category' => $x['category'],
@ -1400,17 +1376,5 @@ function get_response_button_text($v,$count) {
case 'attendmaybe': case 'attendmaybe':
return tt('Undecided','Undecided',$count,'noun'); return tt('Undecided','Undecided',$count,'noun');
break; 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;
} }
} }

View file

@ -31,7 +31,6 @@ function get_features() {
array('richtext', t('Richtext Editor'), t('Enable richtext editor')), 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('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 // Network sidebar widgets

View file

@ -123,10 +123,6 @@ function editpost_content(&$a) {
'$noloc' => t('Clear browser location'), '$noloc' => t('Clear browser location'),
'$shortnoloc' => t('clear location'), '$shortnoloc' => t('clear location'),
'$voting' => t('Toggle voting'), '$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'), '$wait' => t('Please wait'),
'$permset' => t('Permission settings'), '$permset' => t('Permission settings'),
'$ptyp' => $itm[0]['type'], '$ptyp' => $itm[0]['type'],

View file

@ -51,7 +51,6 @@ function item_post(&$a) {
$message_id = ((x($_REQUEST,'message_id') && $api_source) ? strip_tags($_REQUEST['message_id']) : ''); $message_id = ((x($_REQUEST,'message_id') && $api_source) ? strip_tags($_REQUEST['message_id']) : '');
$return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : ''); $return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
$consensus = intval($_REQUEST['consensus']);
$preview = ((x($_REQUEST,'preview')) ? intval($_REQUEST['preview']) : 0); $preview = ((x($_REQUEST,'preview')) ? intval($_REQUEST['preview']) : 0);
@ -656,15 +655,6 @@ function item_post(&$a) {
if(!$thr_parent) if(!$thr_parent)
$thr_parent = $uri; $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 = array();
$datarray['uid'] = $profile_uid; $datarray['uid'] = $profile_uid;
$datarray['type'] = $post_type; $datarray['type'] = $post_type;

View file

@ -26,18 +26,6 @@ function like_content(&$a) {
case 'undislike': case 'undislike':
$activity = ACTIVITY_DISLIKE; $activity = ACTIVITY_DISLIKE;
break; 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 'attendyes':
case 'unattendyes': case 'unattendyes':
$activity = ACTIVITY_ATTEND; $activity = ACTIVITY_ATTEND;
@ -134,14 +122,11 @@ function like_content(&$a) {
$verbs = " '".dbesc($activity)."' "; $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. // we need to eradicate your first choice.
if($activity === ACTIVITY_ATTEND || $activity === ACTIVITY_ATTENDNO || $activity === ACTIVITY_ATTENDMAYBE) { if($activity === ACTIVITY_ATTEND || $activity === ACTIVITY_ATTENDNO || $activity === ACTIVITY_ATTENDMAYBE) {
$verbs = " '" . dbesc(ACTIVITY_ATTEND) . "','" . dbesc(ACTIVITY_ATTENDNO) . "','" . dbesc(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 $r = q("SELECT `id`, `guid` FROM `item` WHERE `verb` IN ( $verbs ) AND `deleted` = 0
AND `contact-id` = %d AND `uid` = %d AND `contact-id` = %d AND `uid` = %d
@ -202,12 +187,6 @@ EOT;
$bodyverb = t('%1$s likes %2$s\'s %3$s'); $bodyverb = t('%1$s likes %2$s\'s %3$s');
if($verb === 'dislike') if($verb === 'dislike')
$bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s'); $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') if($verb === 'attendyes')
$bodyverb = t('%1$s is attending %2$s\'s %3$s'); $bodyverb = t('%1$s is attending %2$s\'s %3$s');
if($verb === 'attendno') if($verb === 'attendno')

View file

@ -1603,7 +1603,6 @@ function photos_content(&$a) {
$conv_responses = array( $conv_responses = array(
'like' => array('title' => t('Likes','title')),'dislike' => array('title' => t('Dislikes','title')), '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')) 'attendyes' => array('title' => t('Attending','title')), 'attendno' => array('title' => t('Not attending','title')), 'attendmaybe' => array('title' => t('Might attend','title'))
); );

View file

@ -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); $responses = get_responses($conv_responses,$response_verbs,$this,$item);
foreach ($response_verbs as $value=>$verbs) { foreach ($response_verbs as $value=>$verbs) {
@ -322,7 +307,7 @@ class Item extends BaseObject {
// Disable features that aren't available in several networks // Disable features that aren't available in several networks
if (($item["item_network"] != NETWORK_DFRN) AND isset($buttons["dislike"])) { if (($item["item_network"] != NETWORK_DFRN) AND isset($buttons["dislike"])) {
unset($buttons["dislike"],$isevent,$consensus); unset($buttons["dislike"],$isevent);
$tagger = ''; $tagger = '';
} }
@ -360,9 +345,6 @@ class Item extends BaseObject {
'guid' => urlencode($item['guid']), 'guid' => urlencode($item['guid']),
'isevent' => $isevent, 'isevent' => $isevent,
'attend' => $attend, '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'])), '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'])), 'olinktitle' => sprintf( t('View %s\'s profile @ %s'), $this->get_owner_name(), ((strlen($item['owner-link'])) ? $item['owner-link'] : $item['url'])),
'to' => t('to'), 'to' => t('to'),

View file

@ -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() { function jotClearLocation() {
$('#jot-coord').val(''); $('#jot-coord').val('');
$('#profile-nolocation-wrapper').hide(); $('#profile-nolocation-wrapper').hide();

View file

@ -54,12 +54,6 @@
<a id="profile-nolocation" class="icon noglobe" title="{{$noloc|escape:'html'}}" onclick="jotClearLocation();return false;"></a> <a id="profile-nolocation" class="icon noglobe" title="{{$noloc|escape:'html'}}" onclick="jotClearLocation();return false;"></a>
</div> </div>
{{if $feature_voting}}
<div id="profile-voting-wrapper" style="display: {{$visitor}};" >
<a id="profile-voting" class="icon icon-check-empty" title="{{$voting|escape:'html'}}" onclick="toggleVoting();return false;"></a>
</div>
{{/if}}
<div id="profile-jot-perms" class="profile-jot-perms" style="display: {{$pvisit}};" > <div id="profile-jot-perms" class="profile-jot-perms" style="display: {{$pvisit}};" >
<a href="#profile-jot-acl-wrapper" id="jot-perms-icon" class="icon {{$lockstate}}" title="{{$permset|escape:'html'}}" ></a>{{$bang}} <a href="#profile-jot-acl-wrapper" id="jot-perms-icon" class="icon {{$lockstate}}" title="{{$permset|escape:'html'}}" ></a>{{$bang}}
</div> </div>

View file

@ -1348,14 +1348,12 @@ section.minimal {
margin-bottom: 0.3em; 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-isevent {
.wall-item-container .wall-item-actions-canvote {
float: left; float: left;
margin-bottom: 1px; 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-isevent a {
.wall-item-container .wall-item-actions-canvote a{
float: left; float: left;
margin-right: 1em; margin-right: 1em;
cursor: pointer; cursor: pointer;
@ -1867,11 +1865,6 @@ section.minimal {
margin-left: 15px; margin-left: 15px;
cursor: pointer; cursor: pointer;
} }
#profile-voting-wrapper {
float: left;
margin-left: 15px;
cursor: pointer;
}
#profile-smiley-wrapper { #profile-smiley-wrapper {
float: left; float: left;
margin-left: 15px; margin-left: 15px;

View file

@ -130,14 +130,6 @@
</div> </div>
{{/if}} {{/if}}
{{if $item.canvote}}<!--Consensus isn't implemented at this time. It's just for testing. -->
<div class="clear"></div>
<div class="wall-item-actions-canvote">
<a href="#" id="attendyes-{{$item.id}}" title="{{$item.conlabels.0}}" onclick="dolike({{$item.id}},'agree'); return false;"><i class="icon-ok icon-large"></i></a>
<a href="#" id="attendno-{{$item.id}}" title="{{$item.conlabels.1}}" onclick="dolike({{$item.id}},'disagree'); return false;"><i class="icon-remove icon-large"></i></a>
<a href="#" id="attendmaybe-{{$item.id}}" title="{{$item.conlabels.2}}" onclick="dolike({{$item.id}},'abstain'); return false;"><i class="icon-question icon-large"></i></a>
</div>
{{/if}}
<div class="wall-item-actions-tools"> <div class="wall-item-actions-tools">
{{if $item.drop.pagedrop}} {{if $item.drop.pagedrop}}