diff --git a/Web/Models/Entities/Club.php b/Web/Models/Entities/Club.php index 15c458a9..0ace9224 100644 --- a/Web/Models/Entities/Club.php +++ b/Web/Models/Entities/Club.php @@ -389,6 +389,11 @@ class Club extends RowModel return (object) $res; } + function isAnonCommentsAllowed(): bool + { + return (bool) $this->getRecord()->allow_anon_comments; + } + use Traits\TBackDrops; use Traits\TSubscribable; } diff --git a/Web/Models/Entities/User.php b/Web/Models/Entities/User.php index 348631e4..9a4a465c 100644 --- a/Web/Models/Entities/User.php +++ b/Web/Models/Entities/User.php @@ -1126,6 +1126,11 @@ class User extends RowModel return $res; } + + function isAnonCommentsAllowed(): bool + { + return (bool) $this->getRecord()->allow_anon_comments; + } use Traits\TBackDrops; use Traits\TSubscribable; diff --git a/Web/Presenters/CommentPresenter.php b/Web/Presenters/CommentPresenter.php index 8c6f6a85..6baa1043 100644 --- a/Web/Presenters/CommentPresenter.php +++ b/Web/Presenters/CommentPresenter.php @@ -51,7 +51,7 @@ final class CommentPresenter extends OpenVKPresenter if($_FILES["_vid_attachment"] && OPENVK_ROOT_CONF['openvk']['preferences']['videos']['disableUploading']) $this->flashFail("err", tr("error"), "Video uploads are disabled by the system administrator."); - $anon = OPENVK_ROOT_CONF["openvk"]["preferences"]["wall"]["anonymousPosting"]["enable"] && $this->postParam("anon") === "on"; + $anon = OPENVK_ROOT_CONF["openvk"]["preferences"]["wall"]["anonymousPosting"]["enable"] && $this->postParam("anon") === "on" && $entity->getWallOwner()->isAnonCommentsAllowed(); $flags = 0; if($this->postParam("as_group") === "on" && !is_null($club) && $club->canBeModifiedBy($this->user->identity)) diff --git a/Web/Presenters/GroupPresenter.php b/Web/Presenters/GroupPresenter.php index 4f671df3..65db1d85 100644 --- a/Web/Presenters/GroupPresenter.php +++ b/Web/Presenters/GroupPresenter.php @@ -208,6 +208,7 @@ final class GroupPresenter extends OpenVKPresenter $club->setEveryone_Can_Create_Topics(empty($this->postParam("everyone_can_create_topics")) ? 0 : 1); $club->setDisplay_Topics_Above_Wall(empty($this->postParam("display_topics_above_wall")) ? 0 : 1); $club->setHide_From_Global_Feed(empty($this->postParam("hide_from_global_feed")) ? 0 : 1); + $club->setAllow_Anon_Comments(empty($this->postParam("allow_anon_comments")) ? 0 : 1); $website = $this->postParam("website") ?? ""; if(empty($website)) diff --git a/Web/Presenters/UserPresenter.php b/Web/Presenters/UserPresenter.php index 9cfa3654..590a456c 100644 --- a/Web/Presenters/UserPresenter.php +++ b/Web/Presenters/UserPresenter.php @@ -418,6 +418,8 @@ final class UserPresenter extends OpenVKPresenter if(!$user->setShortCode(empty($this->postParam("sc")) ? NULL : $this->postParam("sc"))) $this->flashFail("err", tr("error"), tr("error_shorturl_incorrect")); + + $user->setAllow_Anon_Comments(empty($this->postParam("allow_anon_comments")) ? 0 : 1); } else if($_GET['act'] === "privacy") { $settings = [ "page.read", diff --git a/Web/Presenters/templates/Group/Edit.xml b/Web/Presenters/templates/Group/Edit.xml index 22f0b490..28231d13 100644 --- a/Web/Presenters/templates/Group/Edit.xml +++ b/Web/Presenters/templates/Group/Edit.xml @@ -101,7 +101,14 @@ {_group_dont_display_administrators_list}
- + + + + + + {_allow_anon_comments} + + diff --git a/Web/Presenters/templates/User/Settings.xml b/Web/Presenters/templates/User/Settings.xml index e61f900d..9c375bf9 100644 --- a/Web/Presenters/templates/User/Settings.xml +++ b/Web/Presenters/templates/User/Settings.xml @@ -101,6 +101,15 @@ +
+ + + + + + {_allow_anon_comments} + + diff --git a/Web/Presenters/templates/components/comments.xml b/Web/Presenters/templates/components/comments.xml index ee61dfcd..069bff63 100644 --- a/Web/Presenters/templates/components/comments.xml +++ b/Web/Presenters/templates/components/comments.xml @@ -3,8 +3,9 @@
{var $commentsURL = "/al_comments/create/$model/" . $parent->getId()} {var $club = $parent instanceof \openvk\Web\Models\Entities\Post && $parent->getTargetWall() < 0 ? (new openvk\Web\Models\Repositories\Clubs)->get(abs($parent->getTargetWall())) : $club} + {var $oObj = $parent->getWallOwner()} {if !$readOnly} - {include "textArea.xml", route => $commentsURL, postOpts => false, graffiti => (bool) ovkGetQuirk("comments.allow-graffiti"), club => $club, isComment => true} + {include "textArea.xml", route => $commentsURL, postOpts => false, graffiti => (bool) ovkGetQuirk("comments.allow-graffiti"), club => $club, isComment => true, oObj => $oObj} {/if}
diff --git a/Web/Presenters/templates/components/textArea.xml b/Web/Presenters/templates/components/textArea.xml index 5d7a28d8..4f3d9262 100644 --- a/Web/Presenters/templates/components/textArea.xml +++ b/Web/Presenters/templates/components/textArea.xml @@ -17,7 +17,7 @@
- {var $anonEnabled = OPENVK_ROOT_CONF['openvk']['preferences']['wall']['anonymousPosting']['enable']} + {var $anonEnabled = OPENVK_ROOT_CONF['openvk']['preferences']['wall']['anonymousPosting']['enable'] && $oObj->isAnonCommentsAllowed()}
{if !is_null($thisUser) && !is_null($club ?? NULL) && $owner < 0} {if $club->canBeModifiedBy($thisUser)} diff --git a/install/sqls/00038-anonymous-comments-toggles.sql b/install/sqls/00038-anonymous-comments-toggles.sql new file mode 100644 index 00000000..5a602871 --- /dev/null +++ b/install/sqls/00038-anonymous-comments-toggles.sql @@ -0,0 +1,2 @@ +ALTER TABLE `profiles` ADD `allow_anon_comments` BOOLEAN NULL DEFAULT NULL AFTER `client_name`; +ALTER TABLE `groups` ADD `allow_anon_comments` BOOLEAN NULL DEFAULT NULL AFTER `backdrop_2`; diff --git a/locales/en.strings b/locales/en.strings index 4aaa4483..ed4e6f68 100644 --- a/locales/en.strings +++ b/locales/en.strings @@ -214,6 +214,8 @@ "reply" = "Reply"; +"allow_anon_comments" = "Allow anonymous comments"; + /* Friends */ "friends" = "Friends"; diff --git a/locales/ru.strings b/locales/ru.strings index 6faa5e2e..15a15d42 100644 --- a/locales/ru.strings +++ b/locales/ru.strings @@ -191,6 +191,7 @@ "version_incompatibility" = "Не удалось отобразить это вложение. Возможно, база данных несовместима с текущей версией OpenVK."; "graffiti" = "Граффити"; "reply" = "Ответить"; +"allow_anon_comments" = "Разрешить анонимные комментарии"; /* Friends */