diff --git a/include/ItemObject.php b/include/ItemObject.php index 3638b2ffb..7f5ee83a3 100644 --- a/include/ItemObject.php +++ b/include/ItemObject.php @@ -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'], diff --git a/include/conversation.php b/include/conversation.php index 4da6636fa..2c89249cb 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -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') : ''), diff --git a/include/features.php b/include/features.php index 6b4bc34c6..fc14858a8 100644 --- a/include/features.php +++ b/include/features.php @@ -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), ), diff --git a/include/items.php b/include/items.php index 0b2106572..2207635b6 100755 --- a/include/items.php +++ b/include/items.php @@ -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 diff --git a/mod/editpost.php b/mod/editpost.php index 1d9855c95..bdd3be450 100644 --- a/mod/editpost.php +++ b/mod/editpost.php @@ -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'], diff --git a/mod/item.php b/mod/item.php index 6ae02b510..ef0491895 100644 --- a/mod/item.php +++ b/mod/item.php @@ -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; } diff --git a/view/tpl/conv_item.tpl b/view/tpl/conv_item.tpl index df20eadbb..a902e5bda 100755 --- a/view/tpl/conv_item.tpl +++ b/view/tpl/conv_item.tpl @@ -76,6 +76,19 @@ {{/if}} + + {{if $item.consensus}} + + + + {{/if}} + diff --git a/view/tpl/conv_list.tpl b/view/tpl/conv_list.tpl index ad086ee0a..8d454f1eb 100755 --- a/view/tpl/conv_list.tpl +++ b/view/tpl/conv_list.tpl @@ -78,6 +78,18 @@ {{/if}} + {{if $item.consensus}} + + + + {{/if}} + diff --git a/view/tpl/jot-header.tpl b/view/tpl/jot-header.tpl index 678d16a71..8daf2ddb7 100755 --- a/view/tpl/jot-header.tpl +++ b/view/tpl/jot-header.tpl @@ -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(''); diff --git a/view/tpl/jot.tpl b/view/tpl/jot.tpl index 00ef77d93..f32dba095 100755 --- a/view/tpl/jot.tpl +++ b/view/tpl/jot.tpl @@ -11,6 +11,7 @@ + {{if $showacl}}{{$acl}}{{/if}} {{$mimeselect}} {{$layoutselect}} @@ -77,6 +78,11 @@ {{/if}} + {{if $feature_voting}} + + {{/if}}