diff --git a/Web/Models/Entities/Club.php b/Web/Models/Entities/Club.php index fff811f4..2230b1a0 100644 --- a/Web/Models/Entities/Club.php +++ b/Web/Models/Entities/Club.php @@ -140,6 +140,11 @@ class Club extends RowModel return (bool) $this->getRecord()->display_topics_above_wall; } + function isHideFromGlobalFeedEnabled(): bool + { + return (bool) $this->getRecord()->hide_from_global_feed; + } + function getType(): int { return $this->getRecord()->type; diff --git a/Web/Presenters/GroupPresenter.php b/Web/Presenters/GroupPresenter.php index 7b9a20f2..4ad9f849 100644 --- a/Web/Presenters/GroupPresenter.php +++ b/Web/Presenters/GroupPresenter.php @@ -207,8 +207,8 @@ final class GroupPresenter extends OpenVKPresenter $club->setShortcode(empty($this->postParam("shortcode")) ? NULL : $this->postParam("shortcode")); $club->setWall(empty($this->postParam("wall")) ? 0 : 1); $club->setAdministrators_List_Display(empty($this->postParam("administrators_list_display")) ? 0 : $this->postParam("administrators_list_display")); - $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->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); $website = $this->postParam("website") ?? ""; if(empty($website)) diff --git a/Web/Presenters/WallPresenter.php b/Web/Presenters/WallPresenter.php index 999bf53c..ccb13886 100644 --- a/Web/Presenters/WallPresenter.php +++ b/Web/Presenters/WallPresenter.php @@ -122,24 +122,24 @@ final class WallPresenter extends OpenVKPresenter $page = (int) ($_GET["p"] ?? 1); $pPage = min((int) ($_GET["posts"] ?? OPENVK_DEFAULT_PER_PAGE), 50); - $posts = DatabaseConnection::i() - ->getContext() - ->table("posts") - ->where("deleted", 0) - ->order("created DESC"); - + + $queryBase = "FROM `posts` LEFT JOIN `groups` ON GREATEST(`posts`.`wall`, 0) = 0 AND `groups`.`id` = ABS(`posts`.`wall`) WHERE (`groups`.`hide_from_global_feed` = 0 OR `groups`.`name` IS NULL) AND `posts`.`deleted` = 0"; + if($this->user->identity->getNsfwTolerance() === User::NSFW_INTOLERANT) - $posts = $posts->where("nsfw", false); + $queryBase .= " AND `nsfw` = 0"; + + $posts = DatabaseConnection::i()->getConnection()->query("SELECT `posts`.`id` " . $queryBase . " ORDER BY `created` DESC LIMIT " . $pPage . " OFFSET " . ($page - 1) * $pPage); + $count = DatabaseConnection::i()->getConnection()->query("SELECT COUNT(*) " . $queryBase)->fetch()->{"COUNT(*)"}; $this->template->_template = "Wall/Feed.xml"; $this->template->globalFeed = true; $this->template->paginatorConf = (object) [ - "count" => sizeof($posts), + "count" => $count, "page" => (int) ($_GET["p"] ?? 1), - "amount" => sizeof($posts->page($page, $pPage)), + "amount" => sizeof($posts), "perPage" => $pPage, ]; - foreach($posts->page($page, $pPage) as $post) + foreach($posts as $post) $this->template->posts[] = $this->posts->get($post->id); } diff --git a/Web/Presenters/templates/Group/Edit.xml b/Web/Presenters/templates/Group/Edit.xml index 25c2b3d1..50443954 100644 --- a/Web/Presenters/templates/Group/Edit.xml +++ b/Web/Presenters/templates/Group/Edit.xml @@ -74,7 +74,8 @@ {_wall}: - canPost()}checked{/if}/> {_group_allow_post_for_everyone} + {_group_allow_post_for_everyone}
+ {_group_hide_from_global_feed} diff --git a/install/sqls/00017-allow-to-hide-groups-from-global-feed.sql b/install/sqls/00017-allow-to-hide-groups-from-global-feed.sql new file mode 100644 index 00000000..7359481a --- /dev/null +++ b/install/sqls/00017-allow-to-hide-groups-from-global-feed.sql @@ -0,0 +1 @@ +ALTER TABLE `groups` ADD COLUMN `hide_from_global_feed` boolean DEFAULT 0 NOT NULL AFTER `display_topics_above_wall`; diff --git a/locales/en.strings b/locales/en.strings index 97a0b302..d6def6e6 100644 --- a/locales/en.strings +++ b/locales/en.strings @@ -245,6 +245,7 @@ "hidden_yes" = "Hidden: Yes"; "hidden_no" = "Hidden: No"; "group_allow_post_for_everyone" = "Allow posting for everyone"; +"group_hide_from_global_feed" = "Don't display posts in the global feed"; "statistics" = "Statistics"; "group_administrators_list" = "Admins list"; "group_display_only_creator" = "Display only group creator"; diff --git a/locales/ru.strings b/locales/ru.strings index 6ee52b3e..ead87297 100644 --- a/locales/ru.strings +++ b/locales/ru.strings @@ -255,6 +255,7 @@ "hidden_yes" = "Скрыт: Да"; "hidden_no" = "Скрыт: Нет"; "group_allow_post_for_everyone" = "Разрешить публиковать записи всем"; +"group_hide_from_global_feed" = "Не отображать публикации в глобальной ленте"; "statistics" = "Статистика"; "group_administrators_list" = "Список админов"; "group_display_only_creator" = "Отображать только создателя группы";