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 @@
-
-
-
-
node == 'urn:xmpp:microblog:0'"}
@@ -113,7 +93,15 @@
{/loop}
+
+
+
+ {autoescape="off"}
+ {$c->prepareToggles($draft)}
+ {/autoescape}
+
+
-
draw('_publishhelp'), true);
}
+ public function prepareToggles(Draft $draft)
+ {
+ return (new Publish)->prepareToggles($draft);
+ }
+
public function prepareHelp()
{
$view = $this->tpl();
diff --git a/database/migrations/20240204122606_add_comments_disabled_to_drafs_table.php b/database/migrations/20240204122606_add_comments_disabled_to_drafs_table.php
new file mode 100644
index 000000000..b4d6b8cfc
--- /dev/null
+++ b/database/migrations/20240204122606_add_comments_disabled_to_drafs_table.php
@@ -0,0 +1,21 @@
+schema->table('drafts', function (Blueprint $table) {
+ $table->boolean('comments_disabled')->default(false);
+ });
+ }
+
+ public function down()
+ {
+ $this->schema->table('drafts', function (Blueprint $table) {
+ $table->dropColumn('comments_disabled');
+ });
+ }
+}
diff --git a/src/Moxl/Stanza/PubsubAtom.php b/src/Moxl/Stanza/PubsubAtom.php
index 0c7de8f08..5136b8af9 100644
--- a/src/Moxl/Stanza/PubsubAtom.php
+++ b/src/Moxl/Stanza/PubsubAtom.php
@@ -59,7 +59,7 @@ class PubsubAtom
if ($this->name) {
$author->appendChild($dom->createElement('name', $this->name));
}
- $author->appendChild($dom->createElement('uri', 'xmpp:'.$this->jid));
+ $author->appendChild($dom->createElement('uri', 'xmpp:' . $this->jid));
$entry->appendChild($author);
/*$link = $dom->createElement('link');
@@ -70,7 +70,7 @@ class PubsubAtom
$link = $dom->createElement('link');
$link->setAttribute('rel', 'alternate');
- $link->setAttribute('href', 'xmpp:'.$this->to.'?;node='.$this->node.';item='.$this->id);
+ $link->setAttribute('href', 'xmpp:' . $this->to . '?;node=' . $this->node . ';item=' . $this->id);
$entry->appendChild($link);
if ($this->comments) {
@@ -79,11 +79,11 @@ class PubsubAtom
$link->setAttribute('title', 'comments');
if ($this->repost) {
- $link->setAttribute('href', 'xmpp:'.$this->repost[0].'?;node=urn:xmpp:microblog:0:comments/'.$this->repost[2]);
+ $link->setAttribute('href', 'xmpp:' . $this->repost[0] . '?;node=urn:xmpp:microblog:0:comments/' . $this->repost[2]);
} elseif ($this->comments === true) {
- $link->setAttribute('href', 'xmpp:'.$this->to.'?;node=urn:xmpp:microblog:0:comments/'.$this->id);
+ $link->setAttribute('href', 'xmpp:' . $this->to . '?;node=urn:xmpp:microblog:0:comments/' . $this->id);
} else {
- $link->setAttribute('href', 'xmpp:'.$this->comments.'?;node=urn:xmpp:microblog:0:comments/'.$this->id);
+ $link->setAttribute('href', 'xmpp:' . $this->comments . '?;node=urn:xmpp:microblog:0:comments/' . $this->id);
}
$entry->appendChild($link);
@@ -129,7 +129,7 @@ class PubsubAtom
if ($this->repost) {
$link = $dom->createElement('link');
$link->setAttribute('rel', 'via');
- $link->setAttribute('href', 'xmpp:'.$this->repost[0].'?;node='.$this->repost[1].';item='.$this->repost[2]);
+ $link->setAttribute('href', 'xmpp:' . $this->repost[0] . '?;node=' . $this->repost[1] . ';item=' . $this->repost[2]);
$entry->appendChild($link);
}