From 2e7f4c1870dcd8ce05329b80d97be1269ff2a1a7 Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Sun, 14 Aug 2016 06:41:12 -0400 Subject: Added a disable comments setting to the "Additional features" settings with a corresponding post editor toggle button --- Zotlabs/Module/Item.php | 2 ++ include/conversation.php | 7 +++++++ include/features.php | 1 + view/tpl/jot-header.tpl | 13 +++++++++++++ view/tpl/jot.tpl | 9 +++++++++ 5 files changed, 32 insertions(+) diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 2d0c1ba02..8d6d75426 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -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 diff --git a/include/conversation.php b/include/conversation.php index b53498d20..de917c44e 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -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)')), diff --git a/include/features.php b/include/features.php index 041c028c6..f9001d7be 100644 --- a/include/features.php +++ b/include/features.php @@ -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')), diff --git a/view/tpl/jot-header.tpl b/view/tpl/jot-header.tpl index fc87c14d7..32d5cae03 100755 --- a/view/tpl/jot-header.tpl +++ b/view/tpl/jot-header.tpl @@ -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); diff --git a/view/tpl/jot.tpl b/view/tpl/jot.tpl index 692cf129d..bd615b1df 100755 --- a/view/tpl/jot.tpl +++ b/view/tpl/jot.tpl @@ -23,6 +23,7 @@ + {{if $webpage}}
@@ -118,6 +119,11 @@ {{/if}} + {{if $feature_nocomment}} + + {{/if}}
{{if $writefiles || $weblink || $setloc || $clearloc || $feature_expire || $feature_encrypt || $feature_voting}}
@@ -151,6 +157,9 @@ {{if $feature_voting}}
  •  {{$voting}}
  • {{/if}} + {{if $feature_nocomment}} +
  •  {{$nocommenttitle}}
  • + {{/if}}
    {{/if}} -- cgit v1.2.3 From cb9ac6dd3435a429a58250d326ff76ca5f97398a Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Sun, 14 Aug 2016 06:46:48 -0400 Subject: Replace hardcoded button title in javascript to translatable text --- include/conversation.php | 2 ++ view/tpl/jot-header.tpl | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index de917c44e..567336646 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1194,6 +1194,8 @@ function status_editor($a, $x, $popup = false) { '$modalerrorlist' => t('Error getting album list'), '$modalerrorlink' => t('Error getting photo link'), '$modalerroralbum' => t('Error getting album'), + '$nocomment_enabled' => t('Comments enabled'), + '$nocomment_disabled' => t('Comments disabled'), )); $tpl = get_markup_template('jot.tpl'); diff --git a/view/tpl/jot-header.tpl b/view/tpl/jot-header.tpl index 32d5cae03..3d38df0f0 100755 --- a/view/tpl/jot-header.tpl +++ b/view/tpl/jot-header.tpl @@ -375,12 +375,12 @@ function enableOnUser(){ 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'); + $('#profile-nocomment-wrapper').attr('title', '{{$nocomment_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'); + $('#profile-nocomment-wrapper').attr('title', '{{$nocomment_disabled}}'); } } -- cgit v1.2.3 From 229cc2ac431cdcef80cc45a42178fe7a1e4233e4 Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Sun, 14 Aug 2016 06:55:02 -0400 Subject: Change text for submenu on small screens to be static toggle statement --- include/conversation.php | 1 + view/tpl/jot.tpl | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/conversation.php b/include/conversation.php index 567336646..7d1473fe2 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1246,6 +1246,7 @@ function status_editor($a, $x, $popup = false) { '$feature_voting' => $feature_voting, '$consensus' => 0, '$nocommenttitle' => t('Disable comments'), + '$nocommenttitlesub' => t('Toggle comments'), '$feature_nocomment' => $feature_nocomment, '$nocomment' => 0, '$clearloc' => $clearloc, diff --git a/view/tpl/jot.tpl b/view/tpl/jot.tpl index bd615b1df..20357b66f 100755 --- a/view/tpl/jot.tpl +++ b/view/tpl/jot.tpl @@ -158,7 +158,7 @@
  •  {{$voting}}
  • {{/if}} {{if $feature_nocomment}} -
  •  {{$nocommenttitle}}
  • +
  •  {{$nocommenttitlesub}}
  • {{/if}} -- cgit v1.2.3