item voting tools

This commit is contained in:
friendica 2015-02-10 19:10:18 -08:00
parent 79da33dafd
commit 79223b6b3d
10 changed files with 63 additions and 3 deletions

View file

@ -148,11 +148,13 @@ class Item extends BaseObject {
$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';
$conlabels = array( t('I agree'), t('I disagree'), t('I abstain'));
}
$responses = get_responses($conv_responses,$response_verbs,$this,$item);
@ -280,6 +282,8 @@ class Item extends BaseObject {
'id' => $this->get_id(),
'isevent' => $isevent,
'attend' => $attend,
'consensus' => $consensus,
'conlabels' => $conlabels,
'linktitle' => sprintf( t('View %s\'s profile - %s'), $profile_name, $item['author']['xchan_addr']),
'olinktitle' => sprintf( t('View %s\'s profile - %s'), $this->get_owner_name(), $item['owner']['xchan_addr']),
'llink' => $item['llink'],

View file

@ -1085,6 +1085,8 @@ function status_editor($a,$x,$popup=false) {
// if(feature_enabled(local_channel(),'richtext'))
// $plaintext = false;
$voting = feature_enabled(local_channel(),'consensus_tools');
$mimeselect = '';
if(array_key_exists('mimetype',$x) && $x['mimetype']) {
if($x['mimetype'] != 'text/bbcode')
@ -1176,6 +1178,9 @@ function status_editor($a,$x,$popup=false) {
'$shortaudio' => t('audio link'),
'$setloc' => t('Set your location'),
'$shortsetloc' => t('set location'),
'$voting' => t('Toggle voting'),
'$feature_voting' => $voting,
'$consensus' => 0,
'$noloc' => ((get_pconfig($x['profile_uid'],'system','use_browser_location')) ? t('Clear browser location') : ''),
'$shortnoloc' => t('clear location'),
'$title' => ((x($x,'title')) ? htmlspecialchars($x['title'], ENT_COMPAT,'UTF-8') : ''),

View file

@ -60,6 +60,7 @@ function get_features() {
array('large_photos', t('Large Photos'), t('Include large (640px) photo thumbnails in posts. If not enabled, use small (320px) photo thumbnails'),false),
array('channel_sources', t('Channel Sources'), t('Automatically import channel content from other channels or feeds'),false),
array('content_encrypt', t('Even More Encryption'), t('Allow optional encryption of content end-to-end with a shared secret key'),false),
array('consensus_tools', t('Enable voting tools'), t('Provide a class of post which others can vote on'),false),
array('adult_photo_flagging', t('Flag Adult Photos'), t('Provide photo edit option to hide adult photos from default album view'),false),
),

View file

@ -843,9 +843,9 @@ function get_item_elements($x) {
if(array_key_exists('flags',$x) && in_array('deleted',$x['flags']))
$arr['item_restrict'] = ITEM_DELETED;
$arr['item_restrict'] |= ITEM_DELETED;
if(array_key_exists('flags',$x) && in_array('hidden',$x['flags']))
$arr['item_restrict'] = ITEM_HIDDEN;
$arr['item_restrict'] |= ITEM_HIDDEN;
// Here's the deal - the site might be down or whatever but if there's a new person you've never
// seen before sending stuff to your stream, we MUST be able to look them up and import their data from their

View file

@ -74,7 +74,8 @@ function editpost_content(&$a) {
$channel = $a->get_channel();
//$tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));
$voting = feature_enabled(local_channel(),'consensus_tools');
$category = '';
$catsenabled = ((feature_enabled(local_channel(),'categories')) ? 'categories' : '');
@ -118,6 +119,9 @@ function editpost_content(&$a) {
'$audio' => t('Insert Vorbis [.ogg] audio'),
'$setloc' => t('Set your location'),
'$noloc' => t('Clear browser location'),
'$voting' => t('Toggle voting'),
'$feature_voting' => $voting,
'$consensus' => (($itm[0]['item_flags'] & ITEM_CONSENSUS) ? 1 : 0),
'$wait' => t('Please wait'),
'$permset' => t('Permission settings'),
'$ptyp' => $itm[0]['type'],

View file

@ -59,6 +59,8 @@ function item_post(&$a) {
$api_source = ((x($_REQUEST,'api_source') && $_REQUEST['api_source']) ? true : false);
$consensus = intval($_REQUEST['consensus']);
// 'origin' (if non-zero) indicates that this network is where the message originated,
// for the purpose of relaying comments to other conversation members.
// If using the API from a device (leaf node) you must set origin to 1 (default) or leave unset.
@ -683,6 +685,9 @@ function item_post(&$a) {
$item_flags = $item_flags | ITEM_THREAD_TOP;
}
if($consensus)
$item_flags |= ITEM_CONSENSUS;
if ((! $plink) && ($item_flags & ITEM_THREAD_TOP)) {
$plink = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $mid;
}

View file

@ -76,6 +76,19 @@
<i class="icon-question" ></i>
</button>
{{/if}}
{{if $item.consensus}}
<button type="button" title="{{$item.conlabels.0}}" class="btn btn-default btn-sm" onclick="dolike({{$item.id}},'agree'); return false;">
<i class="icon-check" ></i>
</button>
<button type="button" title="{{$item.conlabels.1}}" class="btn btn-default btn-sm" onclick="dolike({{$item.id}},'disagree'); return false;">
<i class="icon-check-empty" ></i>
</button>
<button type="button" title="{{$item.conlabels.2}}" class="btn btn-default btn-sm" onclick="dolike({{$item.id}},'abstain'); return false;">
<i class="icon-question" ></i>
</button>
{{/if}}
<button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown" id="wall-item-menu-{{$item.id}}">
<i class="icon-caret-down"></i>
</button>

View file

@ -78,6 +78,18 @@
</button>
{{/if}}
{{if $item.consensus}}
<button type="button" title="{{$item.conlabels.0}}" class="btn btn-default btn-sm" onclick="dolike({{$item.id}},'agree'); return false;">
<i class="icon-plus" ></i>
</button>
<button type="button" title="{{$item.conlabels.1}}" class="btn btn-default btn-sm" onclick="dolike({{$item.id}},'disagree'); return false;">
<i class="icon-minus" ></i>
</button>
<button type="button" title="{{$item.conlabels.2}}" class="btn btn-default btn-sm" onclick="dolike({{$item.id}},'abstain'); return false;">
<i class="icon-question" ></i>
</button>
{{/if}}
<button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown" id="wall-item-menu-{{$item.id}}">
<i class="icon-caret-down"></i>
</button>

View file

@ -309,6 +309,16 @@ function enableOnUser(){
timer = setTimeout(NavUpdate,1000);
}
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('');

View file

@ -11,6 +11,7 @@
<input type="hidden" name="post_id" value="{{$post_id}}" />
<input type="hidden" name="webpage" value="{{$webpage}}" />
<input type="hidden" name="preview" id="jot-preview" value="0" />
<input type="hidden" id="jot-consensus" name="consensus" value="{{if $consensus}}{{$consensus}}{{else}}0{{/if}}" />
{{if $showacl}}{{$acl}}{{/if}}
{{$mimeselect}}
{{$layoutselect}}
@ -77,6 +78,11 @@
<i id="profile-encrypt" class="icon-key jot-icons"></i>
</button>
{{/if}}
{{if $feature_voting}}
<button id="profile-voting-wrapper" class="btn btn-default btn-sm" title="{{$voting}}" onclick="toggleVoting();return false;">
<i id="profile-voting" class="icon-check-empty jot-icons"></i>
</button>
{{/if}}
</div>
</div>
<div id="profile-rotator-wrapper">