mirror of
https://github.com/openvk/openvk
synced 2024-11-11 01:19:53 +03:00
Groups: Add ability to hide posts from the global feed
This commit is contained in:
parent
f820707070
commit
cca9151661
7 changed files with 22 additions and 13 deletions
|
@ -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;
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,8 @@
|
|||
<span class="nobold">{_wall}: </span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="checkbox" name="wall" value="1" {if $club->canPost()}checked{/if}/> {_group_allow_post_for_everyone}
|
||||
<input type="checkbox" name="wall" value="1" n:attr="checked => $club->canPost()" /> {_group_allow_post_for_everyone}<br>
|
||||
<input type="checkbox" name="hide_from_global_feed" value="1" n:attr="checked => $club->isHideFromGlobalFeedEnabled()" /> {_group_hide_from_global_feed}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE `groups` ADD COLUMN `hide_from_global_feed` boolean DEFAULT 0 NOT NULL AFTER `display_topics_above_wall`;
|
|
@ -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";
|
||||
|
|
|
@ -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" = "Отображать только создателя группы";
|
||||
|
|
Loading…
Reference in a new issue