From a13d62e8fd92e50305470168666f68b3bd836d3f Mon Sep 17 00:00:00 2001 From: Alexander Minkin Date: Sat, 6 Jul 2024 14:34:18 +0300 Subject: [PATCH] feat(groups): add option to enforce global feed exclusion (#1122) --- VKAPI/Handlers/Groups.php | 5 ++++- Web/Models/Entities/Club.php | 5 +++++ Web/Presenters/AdminPresenter.php | 1 + Web/Presenters/GroupPresenter.php | 5 ++++- Web/Presenters/templates/Admin/Club.xml | 4 ++++ Web/Presenters/templates/Group/Edit.xml | 2 +- Web/static/css/main.css | 9 +++++++++ install/sqls/00045-enforce-hiding-from-global-feed.sql | 1 + locales/en.strings | 1 + locales/ru.strings | 1 + 10 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 install/sqls/00045-enforce-hiding-from-global-feed.sql diff --git a/VKAPI/Handlers/Groups.php b/VKAPI/Handlers/Groups.php index ffa4fedd..f83079ec 100644 --- a/VKAPI/Handlers/Groups.php +++ b/VKAPI/Handlers/Groups.php @@ -347,7 +347,10 @@ final class Groups extends VKAPIRequestHandler !empty($topics) ? $club->setEveryone_Can_Create_Topics($topics) : NULL; !empty($adminlist) ? $club->setAdministrators_List_Display($adminlist) : NULL; !empty($topicsAboveWall) ? $club->setDisplay_Topics_Above_Wall($topicsAboveWall) : NULL; - !empty($hideFromGlobalFeed) ? $club->setHide_From_Global_Feed($hideFromGlobalFeed) : NULL; + + if (!$club->isHidingFromGlobalFeedEnforced()) { + !empty($hideFromGlobalFeed) ? $club->setHide_From_Global_Feed($hideFromGlobalFeed) : NULL; + } in_array($audio, [0, 1]) ? $club->setEveryone_can_upload_audios($audio) : NULL; diff --git a/Web/Models/Entities/Club.php b/Web/Models/Entities/Club.php index a46eb573..dc1c356e 100644 --- a/Web/Models/Entities/Club.php +++ b/Web/Models/Entities/Club.php @@ -152,6 +152,11 @@ class Club extends RowModel return (bool) $this->getRecord()->hide_from_global_feed; } + function isHidingFromGlobalFeedEnforced(): bool + { + return (bool) $this->getRecord()->enforce_hiding_from_global_feed; + } + function getType(): int { return $this->getRecord()->type; diff --git a/Web/Presenters/AdminPresenter.php b/Web/Presenters/AdminPresenter.php index cf68cd84..b8f480ca 100644 --- a/Web/Presenters/AdminPresenter.php +++ b/Web/Presenters/AdminPresenter.php @@ -161,6 +161,7 @@ final class AdminPresenter extends OpenVKPresenter $club->setShortCode($this->postParam("shortcode")); $club->setVerified(empty($this->postParam("verify") ? 0 : 1)); $club->setHide_From_Global_Feed(empty($this->postParam("hide_from_global_feed") ? 0 : 1)); + $club->setEnforce_Hiding_From_Global_Feed(empty($this->postParam("enforce_hiding_from_global_feed") ? 0 : 1)); $club->save(); break; case "ban": diff --git a/Web/Presenters/GroupPresenter.php b/Web/Presenters/GroupPresenter.php index beeede13..5e8919b4 100644 --- a/Web/Presenters/GroupPresenter.php +++ b/Web/Presenters/GroupPresenter.php @@ -233,7 +233,10 @@ 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->setEveryone_can_upload_audios(empty($this->postParam("upload_audios")) ? 0 : 1); - $club->setHide_From_Global_Feed(empty($this->postParam("hide_from_global_feed")) ? 0 : 1); + + if (!$club->isHidingFromGlobalFeedEnforced()) { + $club->setHide_From_Global_Feed(empty($this->postParam("hide_from_global_feed") ? 0 : 1)); + } $website = $this->postParam("website") ?? ""; if(empty($website)) diff --git a/Web/Presenters/templates/Admin/Club.xml b/Web/Presenters/templates/Admin/Club.xml index a8f3ad50..47a2fb00 100644 --- a/Web/Presenters/templates/Admin/Club.xml +++ b/Web/Presenters/templates/Admin/Club.xml @@ -65,6 +65,10 @@ isHideFromGlobalFeedEnabled()} checked {/if} /> +
+ isHideFromGlobalFeedEnabled()} checked {/if} /> + +

diff --git a/Web/Presenters/templates/Group/Edit.xml b/Web/Presenters/templates/Group/Edit.xml index 3b865fd9..e4c177c5 100644 --- a/Web/Presenters/templates/Group/Edit.xml +++ b/Web/Presenters/templates/Group/Edit.xml @@ -83,7 +83,7 @@ {_group_hide_from_global_feed} + {_group_hide_from_global_feed} diff --git a/Web/static/css/main.css b/Web/static/css/main.css index 84184b04..8d5480f1 100644 --- a/Web/static/css/main.css +++ b/Web/static/css/main.css @@ -587,6 +587,11 @@ input[type=radio]:hover { background-position: 0 -28px; } +input[type=checkbox]:disabled { + background-position: 0 -28px; + cursor: initial; +} + input[type=checkbox]:checked, input[type=radio]:checked { background-position: 0 -14px; @@ -597,6 +602,10 @@ input[type=radio]:checked:hover { background-position: 0 -42px; } +input[type=checkbox]:checked:disabled { + background-position: 0 -42px; +} + #auth { padding: 10px; } diff --git a/install/sqls/00045-enforce-hiding-from-global-feed.sql b/install/sqls/00045-enforce-hiding-from-global-feed.sql new file mode 100644 index 00000000..50305462 --- /dev/null +++ b/install/sqls/00045-enforce-hiding-from-global-feed.sql @@ -0,0 +1 @@ +ALTER TABLE `groups` ADD COLUMN `enforce_hiding_from_global_feed` boolean NOT NULL DEFAULT 0 AFTER `hide_from_global_feed`; diff --git a/locales/en.strings b/locales/en.strings index b24b73e8..478e2271 100644 --- a/locales/en.strings +++ b/locales/en.strings @@ -1591,6 +1591,7 @@ "admin_user_online_deceased" = "Deceased"; "admin_club_search" = "Search for groups"; "admin_club_excludeglobalfeed" = "Do not display posts in the global feed"; +"admin_club_enforceexcludeglobalfeed" = "Disallow group staff from changing global feed status"; "admin_services" = "Paid services"; "admin_newgift" = "New gift"; diff --git a/locales/ru.strings b/locales/ru.strings index 9e886892..79c83e0b 100644 --- a/locales/ru.strings +++ b/locales/ru.strings @@ -1487,6 +1487,7 @@ "admin_user_online_deceased" = "Покойник"; "admin_club_search" = "Поиск групп"; "admin_club_excludeglobalfeed" = "Не отображать записи в глобальной ленте"; +"admin_club_enforceexcludeglobalfeed" = "Запретить руководству группы изменять отображение в глобальной ленте"; "admin_services" = "Платные услуги"; "admin_newgift" = "Новый подарок"; "admin_price" = "Цена";