diff --git a/Web/Models/Entities/Topic.php b/Web/Models/Entities/Topic.php
index dfe010fcd..30893b078 100644
--- a/Web/Models/Entities/Topic.php
+++ b/Web/Models/Entities/Topic.php
@@ -42,6 +42,11 @@ public function isClosed(): bool
return (bool) $this->getRecord()->closed;
}
+ public function isRestricted(): bool
+ {
+ return (bool) $this->getRecord()->restricted;
+ }
+
public function isPinned(): bool
{
return (bool) $this->getRecord()->pinned;
diff --git a/Web/Presenters/CommentPresenter.php b/Web/Presenters/CommentPresenter.php
index f9317cff1..3dd2b5460 100644
--- a/Web/Presenters/CommentPresenter.php
+++ b/Web/Presenters/CommentPresenter.php
@@ -80,6 +80,10 @@ public function renderMakeComment(string $repo, int $eId): void
$this->flashFail("err", tr("error"), tr("forbidden"));
}
+ if ($entity instanceof Topic && $entity->isRestricted() && !$entity->getClub()->canBeModifiedBy($this->user->identity)) {
+ $this->flashFail("err", tr("error"), tr("forbidden"));
+ }
+
$flags = 0;
if ($this->postParam("as_group") === "on" && !is_null($club) && $club->canBeModifiedBy($this->user->identity)) {
$flags |= 0b10000000;
diff --git a/Web/Presenters/TopicsPresenter.php b/Web/Presenters/TopicsPresenter.php
index 04987b6e1..0fb9f635d 100644
--- a/Web/Presenters/TopicsPresenter.php
+++ b/Web/Presenters/TopicsPresenter.php
@@ -181,6 +181,7 @@ public function renderEdit(int $clubId, int $topicId): void
$topic->setClosed(empty($this->postParam("close")) ? 0 : 1);
if ($topic->getClub()->canBeModifiedBy($this->user->identity)) {
+ $topic->setRestricted((empty($this->postParam("restrict")) || !$topic->isPostedOnBehalfOfGroup()) ? 0 : 1);
$topic->setPinned(empty($this->postParam("pin")) ? 0 : 1);
}
diff --git a/Web/Presenters/templates/Topics/Edit.xml b/Web/Presenters/templates/Topics/Edit.xml
index 49a6156b7..55d046b81 100644
--- a/Web/Presenters/templates/Topics/Edit.xml
+++ b/Web/Presenters/templates/Topics/Edit.xml
@@ -34,6 +34,9 @@
{if $topic->getClub()->canBeModifiedBy($thisUser)}
+ {if $topic->isPostedOnBehalfOfGroup()}
+
+ {/if}
{/if}
|
diff --git a/Web/Presenters/templates/Topics/Topic.xml b/Web/Presenters/templates/Topics/Topic.xml
index dddeabc42..786dde2c8 100644
--- a/Web/Presenters/templates/Topics/Topic.xml
+++ b/Web/Presenters/templates/Topics/Topic.xml
@@ -24,6 +24,6 @@
{tr("topic_messages_count", $count)}
- {include "../components/comments.xml", comments => $comments, count => $count, page => $page, model => "topics", club => $club, readOnly => $topic->isClosed(), showTitle => false, parent => $topic}
+ {include "../components/comments.xml", comments => $comments, count => $count, page => $page, model => "topics", club => $club, readOnly => $topic->isClosed() || ($topic->isRestricted() && !$topic->getClub()->canBeModifiedBy($thisUser)), showTitle => false, parent => $topic}
{/block}
diff --git a/install/sqls/00059-only-admins-topics.sql b/install/sqls/00059-only-admins-topics.sql
new file mode 100644
index 000000000..ecc101454
--- /dev/null
+++ b/install/sqls/00059-only-admins-topics.sql
@@ -0,0 +1,2 @@
+ALTER TABLE `topics`
+ADD `restricted` TINYINT(1) NOT NULL DEFAULT '0' AFTER `closed`;
diff --git a/locales/en.strings b/locales/en.strings
index c21c05525..a63b3b6da 100644
--- a/locales/en.strings
+++ b/locales/en.strings
@@ -1461,6 +1461,8 @@
"failed_to_change_topic" = "Failed to change topic";
"no_title_specified" = "No title specified.";
+"restrict_topic" = "Only administrators can comment";
+
/* Errors */
"error_1" = "Incorrect query";
diff --git a/locales/ru.strings b/locales/ru.strings
index e531072fd..d61d10a62 100644
--- a/locales/ru.strings
+++ b/locales/ru.strings
@@ -1380,6 +1380,7 @@
"failed_to_create_topic" = "Не удалось создать тему";
"failed_to_change_topic" = "Не удалось изменить тему";
"no_title_specified" = "Заголовок не указан.";
+"restrict_topic" = "Комментировать могут только администраторы";
/* Errors */