diff --git a/ServiceAPI/Wall.php b/ServiceAPI/Wall.php index 9c4b5e0e..e6133497 100644 --- a/ServiceAPI/Wall.php +++ b/ServiceAPI/Wall.php @@ -141,18 +141,16 @@ class Wall implements Handler $flags = 0; $flags |= 0b10000000; - if($sign) { + if($sign) $flags |= 0b01000000; - } - + $post->setSuggested(0); $post->setCreated(time()); $post->setFlags($flags); - if(mb_strlen($content) > 0) { + if(mb_strlen($content) > 0) $post->setContent($content); - } - + $post->save(); if($author->getId() != $this->user->getId()) diff --git a/VKAPI/Handlers/Wall.php b/VKAPI/Handlers/Wall.php index 0762f730..b90ebeac 100644 --- a/VKAPI/Handlers/Wall.php +++ b/VKAPI/Handlers/Wall.php @@ -151,9 +151,9 @@ final class Wall extends VKAPIRequestHandler $postType = "post"; $signerId = NULL; - if($post->getSuggestionType() != 0) { + if($post->getSuggestionType() != 0) $postType = "suggest"; - } + if($post->isSigned()) { $actualAuthor = $post->getOwner(false); @@ -342,9 +342,9 @@ final class Wall extends VKAPIRequestHandler # TODO: $post->getVkApiType() $postType = "post"; $signerId = NULL; - if($post->getSuggestionType() != 0) { + if($post->getSuggestionType() != 0) $postType = "suggest"; - } + if($post->isSigned()) { $actualAuthor = $post->getOwner(false); @@ -470,9 +470,8 @@ final class Wall extends VKAPIRequestHandler if($canPost == false) $this->fail(15, "Access denied"); if($post_id > 0) { - if($owner_id > 0) { + if($owner_id > 0) $this->fail(62, "Suggested posts available only at groups"); - } $post = (new PostsRepo)->getPostById($owner_id, $post_id, true); @@ -539,9 +538,8 @@ final class Wall extends VKAPIRequestHandler $post->setFlags($flags); $post->setApi_Source_Name($this->getPlatform()); - if($owner_id < 0 && !$wallOwner->canBeModifiedBy($this->getUser()) && $wallOwner->getWallType() == 2) { + if($owner_id < 0 && !$wallOwner->canBeModifiedBy($this->getUser()) && $wallOwner->getWallType() == 2) $post->setSuggested(1); - } $post->save(); } catch(\LogicException $ex) { diff --git a/Web/Models/Entities/Club.php b/Web/Models/Entities/Club.php index 88e8e976..9feb29b9 100644 --- a/Web/Models/Entities/Club.php +++ b/Web/Models/Entities/Club.php @@ -313,15 +313,13 @@ class Club extends RowModel { $count = 0; - if(is_null($user)) { + if(is_null($user)) return NULL; - } - if($this->canBeModifiedBy($user)) { + if($this->canBeModifiedBy($user)) $count = (new Posts)->getSuggestedPostsCount($this->getId()); - } else { + else $count = (new Posts)->getSuggestedPostsCountByUser($this->getId(), $user->getId()); - } return $count; } diff --git a/Web/Models/Entities/Poll.php b/Web/Models/Entities/Poll.php index b88ce1a8..3fea3f9d 100644 --- a/Web/Models/Entities/Poll.php +++ b/Web/Models/Entities/Poll.php @@ -300,10 +300,9 @@ class Poll extends Attachable ["attachable_type" => static::class, "attachable_id" => $this->getId()])->fetch(); - if(!is_null($post->target_id)) { + if(!is_null($post->target_id)) return (new Posts)->get($post->target_id); - } else { + else return NULL; - } } } diff --git a/Web/Presenters/GroupPresenter.php b/Web/Presenters/GroupPresenter.php index 12f6ce80..7a196439 100644 --- a/Web/Presenters/GroupPresenter.php +++ b/Web/Presenters/GroupPresenter.php @@ -33,12 +33,11 @@ final class GroupPresenter extends OpenVKPresenter $this->template->topicsCount = (new Topics)->getClubTopicsCount($club); } - if(!is_null($this->user->identity) && !$club->canBeModifiedBy($this->user->identity) && $club->getWallType() == 2) { - $this->template->suggestedPostsCountByUser = (new Posts)->getSuggestedPostsCountByUser($club->getId(), $this->user->id); - } - - if(!is_null($this->user->identity) && $club->canBeModifiedBy($this->user->identity) && $club->getWallType() == 2) { - $this->template->suggestedPostsCountByEveryone = (new Posts)->getSuggestedPostsCount($club->getId()); + if(!is_null($this->user->identity) && $club->getWallType() == 2) { + if(!$club->canBeModifiedBy($this->user->identity)) + $this->template->suggestedPostsCountByUser = (new Posts)->getSuggestedPostsCountByUser($club->getId(), $this->user->id); + else + $this->template->suggestedPostsCountByEveryone = (new Posts)->getSuggestedPostsCount($club->getId()); } $this->template->club = $club; diff --git a/Web/Presenters/WallPresenter.php b/Web/Presenters/WallPresenter.php index 38408654..b8e94298 100644 --- a/Web/Presenters/WallPresenter.php +++ b/Web/Presenters/WallPresenter.php @@ -310,9 +310,8 @@ final class WallPresenter extends OpenVKPresenter $post->setFlags($flags); $post->setNsfw($this->postParam("nsfw") === "on"); - if($wall < 0 && !$wallOwner->canBeModifiedBy($this->user->identity) && $wallOwner->getWallType() == 2) { + if($wall < 0 && !$wallOwner->canBeModifiedBy($this->user->identity) && $wallOwner->getWallType() == 2) $post->setSuggested(1); - } $post->save(); } catch (\LengthException $ex) { @@ -351,16 +350,13 @@ final class WallPresenter extends OpenVKPresenter if($wall < 0 && !$wallOwner->canBeModifiedBy($this->user->identity) && $wallOwner->getWallType() == 2) { $suggsCount = $this->posts->getSuggestedPostsCount($wallOwner->getId()); - # Возможно, это заебёт админов групп, но так они хотя бы про паблик вспомнят - # Мб рандома добавить? if($suggsCount % 10 == 0) { $managers = $wallOwner->getManagers(); $owner = $wallOwner->getOwner(); (new NewSuggestedPostsNotification($owner, $wallOwner))->emit(); - foreach($managers as $manager) { + foreach($managers as $manager) (new NewSuggestedPostsNotification($manager->getUser(), $wallOwner))->emit(); - } } $this->redirect("/club".$wallOwner->getId()."/suggested"); diff --git a/Web/Presenters/templates/Group/Suggested.xml b/Web/Presenters/templates/Group/Suggested.xml index a7c824f6..1c882675 100644 --- a/Web/Presenters/templates/Group/Suggested.xml +++ b/Web/Presenters/templates/Group/Suggested.xml @@ -14,15 +14,13 @@

{if $type == "my"}{tr("suggested_posts_in_group_by_you", $count)}{else}{tr("suggested_posts_in_group", $count)}{/if}

{var $microblog = $thisUser->hasMicroblogEnabled()} - {foreach $posts as $post} -
- {if $microblog} - {include "../components/post/microblogpost.xml", post => $post, commentSection => false, suggestion => true, forceNoCommentsLink => true, forceNoPinLink => true, forceNoLike => true, forceNoShareLink => true, forceNoDeleteLink => false} - {else} - {include "../components/post/oldpost.xml", post => $post, commentSection => false, suggestion => true, forceNoCommentsLink => true, forceNoPinLink => true, forceNoLike => true, forceNoShareLink => true, forceNoDeleteLink => false} - {/if} -
- {/foreach} +
+ {if $microblog} + {include "../components/post/microblogpost.xml", post => $post, commentSection => false, suggestion => true, forceNoCommentsLink => true, forceNoPinLink => true, forceNoLike => true, forceNoShareLink => true, forceNoDeleteLink => false} + {else} + {include "../components/post/oldpost.xml", post => $post, commentSection => false, suggestion => true, forceNoCommentsLink => true, forceNoPinLink => true, forceNoLike => true, forceNoShareLink => true, forceNoDeleteLink => false} + {/if} +
{include "../components/paginator.xml", conf => (object) [ "page" => $page,