From cb8dd4d12db93a54192e5bdefafb4aa15c7bfdee Mon Sep 17 00:00:00 2001 From: lalka2016 <99399973+lalka2016@users.noreply.github.com> Date: Fri, 4 Aug 2023 19:09:06 +0300 Subject: [PATCH] =?UTF-8?q?=D0=AD=D0=B4=D0=B4=20=D0=B0=D0=BF=D0=B8=20?= =?UTF-8?q?=D0=BC=D0=B5=D1=82=D1=85=D0=BE=D0=B4=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Методы нестандартные немного --- VKAPI/Handlers/Wall.php | 79 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 78 insertions(+), 1 deletion(-) diff --git a/VKAPI/Handlers/Wall.php b/VKAPI/Handlers/Wall.php index 74eacb8e..0f5fa2c3 100644 --- a/VKAPI/Handlers/Wall.php +++ b/VKAPI/Handlers/Wall.php @@ -1,7 +1,7 @@ getWallType() != 2) + $this->fail(125, "Group's wall type is open or closed"); + if($wallOnwer->canBeModifiedBy($this->getUser())) { $iteratorv = $posts->getSuggestedPosts($owner_id * -1, 1, $count, $offset); $cnt = $posts->getSuggestedPostsCount($owner_id * -1); @@ -834,6 +837,80 @@ final class Wall extends VKAPIRequestHandler return 1; } + # !!! Нестандартный метод + function acceptPost(int $club, int $post_id, string $new_message = "", bool $sign = true) + { + $this->requireUser(); + $this->willExecuteWriteAction(); + + if($club < 0) { + $this->fail(62, "Club's id is negative"); + } + + $post = (new PostsRepo)->getPostById($club * -1, $post_id, true); + if(!$post || $post->isDeleted()) + $this->fail(32, "Invald post"); + + if($post->getSuggestionType() == 0) + $this->fail(20, "Post is not suggested"); + + if($post->getSuggestionType() == 2) + $this->fail(16, "Post is declined"); + + if(!$post->canBePinnedBy($this->getUser())) + $this->fail(51, "Access denied"); + + $author = $post->getOwner(); + $flags = 0; + $flags |= 0b10000000; + + if($sign) + $flags |= 0b01000000; + + $post->setSuggested(0); + $post->setCreated(time()); + $post->setFlags($flags); + + if(!empty($new_message) && iconv_strlen($new_message) > 0) + $post->setContent($new_message); + + $post->save(); + (new PostAcceptedNotification($author, $post, $post->getWallOwner()))->emit(); + + return 1; + } + + # !!! Нестандартный метод + function declinePost(int $club, int $post_id) + { + $this->requireUser(); + $this->willExecuteWriteAction(); + + if($club < 0) { + $this->fail(62, "Club's id is negative"); + } + + $post = (new PostsRepo)->getPostById($club * -1, $post_id, true); + + if(!$post || $post->isDeleted()) + $this->fail(32, "Invald post"); + + if($post->getSuggestionType() == 0) + $this->fail(20, "Post is not suggested"); + + if($post->getSuggestionType() == 2) + $this->fail(16, "Post is already declined"); + + if(!$post->canBePinnedBy($this->getUser())) + $this->fail(51, "Access denied"); + + $post->setSuggested(2); + $post->setDeleted(1); + $post->save(); + + return 1; + } + private function getApiPhoto($attachment) { return [ "type" => "photo",