Skip to content

Commit

Permalink
feat(groups): add option to enforce global feed exclusion (#1122)
Browse files Browse the repository at this point in the history
  • Loading branch information
WerySkok authored Jul 6, 2024
1 parent 9d62bfc commit a13d62e
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 3 deletions.
5 changes: 4 additions & 1 deletion VKAPI/Handlers/Groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,10 @@ function edit(
!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;

Expand Down
5 changes: 5 additions & 0 deletions Web/Models/Entities/Club.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ function isHideFromGlobalFeedEnabled(): bool
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;
Expand Down
1 change: 1 addition & 0 deletions Web/Presenters/AdminPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ function renderClub(int $id): void
$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":
Expand Down
5 changes: 4 additions & 1 deletion Web/Presenters/GroupPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,10 @@ function renderEdit(int $id): void
$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))
Expand Down
4 changes: 4 additions & 0 deletions Web/Presenters/templates/Admin/Club.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
<input class="toggle-large" type="checkbox" id="hide_from_global_feed" name="hide_from_global_feed" value="1" {if $club->isHideFromGlobalFeedEnabled()} checked {/if} />
<label for="hide_from_global_feed">{_admin_club_excludeglobalfeed}</label>
</div>
<div class="group">
<input class="toggle-large" type="checkbox" id="enforce_hiding_from_global_feed" name="enforce_hiding_from_global_feed" value="1" {if $club->isHideFromGlobalFeedEnabled()} checked {/if} />
<label for="enforce_hiding_from_global_feed">{_admin_club_enforceexcludeglobalfeed}</label>
</div>
<hr/>
<div class="buttons-container">
<div class="buttons">
Expand Down
2 changes: 1 addition & 1 deletion Web/Presenters/templates/Group/Edit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<option value="0" n:attr="selected => $club->getWallType() == 0" /> {_group_closed_post}</option>
<select>

<input type="checkbox" name="hide_from_global_feed" value="1" n:attr="checked => $club->isHideFromGlobalFeedEnabled()" /> {_group_hide_from_global_feed}
<input type="checkbox" name="hide_from_global_feed" value="1" n:attr="checked => $club->isHideFromGlobalFeedEnabled(), disabled => $club->isHidingFromGlobalFeedEnforced()" /> {_group_hide_from_global_feed}
</td>
</tr>
<tr>
Expand Down
9 changes: 9 additions & 0 deletions Web/static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions install/sqls/00045-enforce-hiding-from-global-feed.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `groups` ADD COLUMN `enforce_hiding_from_global_feed` boolean NOT NULL DEFAULT 0 AFTER `hide_from_global_feed`;
1 change: 1 addition & 0 deletions locales/en.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions locales/ru.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1487,6 +1487,7 @@
"admin_user_online_deceased" = "Покойник";
"admin_club_search" = "Поиск групп";
"admin_club_excludeglobalfeed" = "Не отображать записи в глобальной ленте";
"admin_club_enforceexcludeglobalfeed" = "Запретить руководству группы изменять отображение в глобальной ленте";
"admin_services" = "Платные услуги";
"admin_newgift" = "Новый подарок";
"admin_price" = "Цена";
Expand Down

0 comments on commit a13d62e

Please sign in to comment.