Added a disable comments setting to the "Additional features" settings with a corresponding post editor toggle button

This commit is contained in:
Andrew Manning 2016-08-14 06:41:12 -04:00
parent 82d61f194a
commit 2e7f4c1870
5 changed files with 32 additions and 0 deletions

View file

@ -81,6 +81,7 @@ class Item extends \Zotlabs\Web\Controller {
$api_source = ((x($_REQUEST,'api_source') && $_REQUEST['api_source']) ? true : false);
$consensus = intval($_REQUEST['consensus']);
$nocomment = intval($_REQUEST['nocomment']);
// 'origin' (if non-zero) indicates that this network is where the message originated,
// for the purpose of relaying comments to other conversation members.
@ -707,6 +708,7 @@ class Item extends \Zotlabs\Web\Controller {
$item_wall = (($post_type === 'wall' || $post_type === 'wall-comment') ? 1 : 0);
$item_origin = (($origin) ? 1 : 0);
$item_consensus = (($consensus) ? 1 : 0);
$item_nocomment = (($nocomment) ? 1 : 0);
// determine if this is a wall post

View file

@ -1121,6 +1121,10 @@ function status_editor($a, $x, $popup = false) {
$feature_voting = feature_enabled($x['profile_uid'], 'consensus_tools');
if(x($x, 'hide_voting'))
$feature_voting = false;
$feature_nocomment = feature_enabled($x['profile_uid'], 'disable_comments');
if(x($x, 'disable_comments'))
$feature_nocomment = false;
$feature_expire = ((feature_enabled($x['profile_uid'], 'content_expire') && (! $webpage)) ? true : false);
if(x($x, 'hide_expire'))
@ -1239,6 +1243,9 @@ function status_editor($a, $x, $popup = false) {
'$voting' => t('Toggle voting'),
'$feature_voting' => $feature_voting,
'$consensus' => 0,
'$nocommenttitle' => t('Disable comments'),
'$feature_nocomment' => $feature_nocomment,
'$nocomment' => 0,
'$clearloc' => $clearloc,
'$title' => ((x($x, 'title')) ? htmlspecialchars($x['title'], ENT_COMPAT,'UTF-8') : ''),
'$placeholdertitle' => ((x($x, 'placeholdertitle')) ? $x['placeholdertitle'] : t('Title (optional)')),

View file

@ -74,6 +74,7 @@ function get_features($filtered = true) {
array('channel_sources', t('Channel Sources'), t('Automatically import channel content from other channels or feeds'),false,get_config('feature_lock','channel_sources')),
array('content_encrypt', t('Even More Encryption'), t('Allow optional encryption of content end-to-end with a shared secret key'),false,get_config('feature_lock','content_encrypt')),
array('consensus_tools', t('Enable Voting Tools'), t('Provide a class of post which others can vote on'),false,get_config('feature_lock','consensus_tools')),
array('disable_comments', t('Enable Disabling Comments'), t('Provide the option to disable comments for a post'),false,get_config('feature_lock','disable_comments')),
array('delayed_posting', t('Delayed Posting'), t('Allow posts to be published at a later date'),false,get_config('feature_lock','delayed_posting')),
array('suppress_duplicates', t('Suppress Duplicate Posts/Comments'), t('Prevent posts with identical content to be published with less than two minutes in between submissions.'),true,get_config('feature_lock','suppress_duplicates')),

View file

@ -371,6 +371,19 @@ function enableOnUser(){
}
}
function toggleNoComment() {
if($('#jot-nocomment').val() > 0) {
$('#jot-nocomment').val(0);
$('#profile-nocomment, #profile-nocomment-sub').removeClass('fa-comments-o').addClass('fa-comments');
$('#profile-nocomment-wrapper').attr('title', 'Comments enabled');
}
else {
$('#jot-nocomment').val(1);
$('#profile-nocomment, #profile-nocomment-sub').removeClass('fa-comments').addClass('fa-comments-o');
$('#profile-nocomment-wrapper').attr('title', 'Comments disabled');
}
}
function jotReact(id,icon) {
if(id && icon) {
$.get('{{$baseurl}}/react?f=&postid=' + id + '&emoji=' + icon);

View file

@ -23,6 +23,7 @@
<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}}" />
<input type="hidden" id="jot-nocomment" name="nocomment" value="{{if $nocomment}}{{$nocomment}}{{else}}0{{/if}}" />
{{if $webpage}}
<div id="jot-pagetitle-wrap" class="jothidden">
@ -118,6 +119,11 @@
<i id="profile-voting" class="fa fa-square-o jot-icons"></i>
</button>
{{/if}}
{{if $feature_nocomment}}
<button id="profile-nocomment-wrapper" class="btn btn-default btn-sm" title="{{$nocommenttitle}}" onclick="toggleNoComment();return false;">
<i id="profile-nocomment" class="fa fa-comments jot-icons"></i>
</button>
{{/if}}
</div>
{{if $writefiles || $weblink || $setloc || $clearloc || $feature_expire || $feature_encrypt || $feature_voting}}
<div class="btn-group visible-xs visible-sm">
@ -151,6 +157,9 @@
{{if $feature_voting}}
<li><a href="#" onclick="toggleVoting(); return false;"><i id="profile-voting-sub" class="fa fa-square-o"></i>&nbsp;{{$voting}}</a></li>
{{/if}}
{{if $feature_nocomment}}
<li><a href="#" onclick="toggleNoComment(); return false;"><i id="profile-nocomment-sub" class="fa fa-comments"></i>&nbsp;{{$nocommenttitle}}</a></li>
{{/if}}
</ul>
</div>
{{/if}}