diff --git a/CHANGELOG.md b/CHANGELOG.md index 839c09b24..e97314c7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ Movim Changelog ================ +v0.23.1 +--------------------------- +* Allow comments to be disabled during the publication flow + v0.23 --------------------------- * Add the message menu in the Picture preview diff --git a/app/widgets/Post/locales.ini b/app/widgets/Post/locales.ini index f6fe6115e..c348a1c34 100644 --- a/app/widgets/Post/locales.ini +++ b/app/widgets/Post/locales.ini @@ -16,11 +16,17 @@ unknown_contact= Unknown contact read_time_singular = %s minute read_time_plural = %s minutes -public = Publish this post publicly? +public_title = Publish this article publicly +public_text = This will allow anyone outside Movim to have access to your publication public_yes = This post is public public_no = This post is private public_url = Public URL of this post +comments_disabled_title = Disable the comments +comments_disabled_text = Nobody will be able to like or comment +comments_disabled_yes = Comments disabled for this article +comments_disabled_no = Comments enabled for this article + delete_title = Delete this post delete_text = You are going to delete this post, please confirm your action delete_comment = Are you sure that you want to delete this comment? diff --git a/app/widgets/Publish/Publish.php b/app/widgets/Publish/Publish.php index a9e4635cd..5974bf30e 100644 --- a/app/widgets/Publish/Publish.php +++ b/app/widgets/Publish/Publish.php @@ -187,10 +187,12 @@ class Publish extends Base } } - if ($comments) { - $p->enableComments($comments->server); - } else { - $p->enableComments(); + if (!$draft->comments_disabled) { + if ($comments) { + $p->enableComments($comments->server); + } else { + $p->enableComments(); + } } if ($draft->open) { @@ -345,6 +347,20 @@ class Publish extends Base } } + public function ajaxToggleCommentsDisabled($id, bool $commentsDisabled) + { + $draft = $this->user->drafts()->find($id); + + if ($draft) { + $draft->comments_disabled = $commentsDisabled; + $draft->save(); + + Toast::send(($commentsDisabled) + ? $this->__('post.comments_disabled_yes') + : $this->__('post.comments_disabled_no')); + } + } + public function ajaxClearReply($id) { $draft = $this->user->drafts()->find($id); @@ -358,6 +374,13 @@ class Publish extends Base } + public function prepareToggles(Draft $draft) + { + $view = $this->tpl(); + $view->assign('draft', $draft); + return $view->draw('_publish_toggles'); + } + public function prepareEmbed(DraftEmbed $embed) { $view = $this->tpl(); diff --git a/app/widgets/Publish/_publish_toggles.tpl b/app/widgets/Publish/_publish_toggles.tpl new file mode 100644 index 000000000..06bcbb4f5 --- /dev/null +++ b/app/widgets/Publish/_publish_toggles.tpl @@ -0,0 +1,53 @@ +
  • + +
    +
    +
    + + +
    +
    +
    +
    +
    +

    {$c->__('post.public_title')}

    +

    {$c->__('post.public_text')}

    +
    +
  • + +
  • + +
    +
    +
    + + +
    +
    +
    +
    +
    +

    {$c->__('post.comments_disabled_title')}

    +

    {$c->__('post.comments_disabled_text')}

    +
    +
  • \ No newline at end of file diff --git a/app/widgets/Publish/publish.css b/app/widgets/Publish/publish.css index 564b3b600..d089be586 100644 --- a/app/widgets/Publish/publish.css +++ b/app/widgets/Publish/publish.css @@ -18,22 +18,21 @@ #publish label span.save.saved { display: initial; } -#publish span.privacy { - margin-right: 1.75rem; -} #publish textarea[name=content] { min-height: 25rem; } -#publish span.privacy form > div .checkbox > input[type="checkbox"] + label { +#publish span.privacy form > div .checkbox > input[type="checkbox"] + label, +#publish span.comments_disabled form > div .checkbox > input[type="checkbox"] + label { top: 0.5rem; left: 0.5rem; height: 3rem; width: 3rem; } -#publish span.privacy form > div .checkbox > input[type="checkbox"]:checked + label { +#publish span.privacy form > div .checkbox > input[type="checkbox"]:checked + label, +#publish span.comments_disabled form > div .checkbox > input[type="checkbox"]:checked + label { left: 2.5rem; } @@ -45,6 +44,14 @@ content: 'wifi_tethering'; } +#publish span.comments_disabled form > div .checkbox > input[type="checkbox"] + label i:before { + content: 'insert_comment'; +} + +#publish span.comments_disabled form > div .checkbox > input[type="checkbox"]:checked + label i:before { + content: 'comments_disabled'; +} + #publishreply { margin-bottom: -1rem; } \ No newline at end of file diff --git a/app/widgets/Publish/publish.tpl b/app/widgets/Publish/publish.tpl index 31e6e65b9..25f876b74 100644 --- a/app/widgets/Publish/publish.tpl +++ b/app/widgets/Publish/publish.tpl @@ -2,26 +2,6 @@
    + + +