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}: