openvk.uk

Возможно, приведение кода к кодстайлу (удаление скобочек то есть)
This commit is contained in:
lalka2016 2023-08-19 22:29:47 +03:00
parent 5f51881a5d
commit 6bd475a6ac
7 changed files with 29 additions and 43 deletions

View file

@ -141,17 +141,15 @@ class Wall implements Handler
$flags = 0; $flags = 0;
$flags |= 0b10000000; $flags |= 0b10000000;
if($sign) { if($sign)
$flags |= 0b01000000; $flags |= 0b01000000;
}
$post->setSuggested(0); $post->setSuggested(0);
$post->setCreated(time()); $post->setCreated(time());
$post->setFlags($flags); $post->setFlags($flags);
if(mb_strlen($content) > 0) { if(mb_strlen($content) > 0)
$post->setContent($content); $post->setContent($content);
}
$post->save(); $post->save();

View file

@ -151,9 +151,9 @@ final class Wall extends VKAPIRequestHandler
$postType = "post"; $postType = "post";
$signerId = NULL; $signerId = NULL;
if($post->getSuggestionType() != 0) { if($post->getSuggestionType() != 0)
$postType = "suggest"; $postType = "suggest";
}
if($post->isSigned()) { if($post->isSigned()) {
$actualAuthor = $post->getOwner(false); $actualAuthor = $post->getOwner(false);
@ -342,9 +342,9 @@ final class Wall extends VKAPIRequestHandler
# TODO: $post->getVkApiType() # TODO: $post->getVkApiType()
$postType = "post"; $postType = "post";
$signerId = NULL; $signerId = NULL;
if($post->getSuggestionType() != 0) { if($post->getSuggestionType() != 0)
$postType = "suggest"; $postType = "suggest";
}
if($post->isSigned()) { if($post->isSigned()) {
$actualAuthor = $post->getOwner(false); $actualAuthor = $post->getOwner(false);
@ -470,9 +470,8 @@ final class Wall extends VKAPIRequestHandler
if($canPost == false) $this->fail(15, "Access denied"); if($canPost == false) $this->fail(15, "Access denied");
if($post_id > 0) { if($post_id > 0) {
if($owner_id > 0) { if($owner_id > 0)
$this->fail(62, "Suggested posts available only at groups"); $this->fail(62, "Suggested posts available only at groups");
}
$post = (new PostsRepo)->getPostById($owner_id, $post_id, true); $post = (new PostsRepo)->getPostById($owner_id, $post_id, true);
@ -539,9 +538,8 @@ final class Wall extends VKAPIRequestHandler
$post->setFlags($flags); $post->setFlags($flags);
$post->setApi_Source_Name($this->getPlatform()); $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->setSuggested(1);
}
$post->save(); $post->save();
} catch(\LogicException $ex) { } catch(\LogicException $ex) {

View file

@ -313,15 +313,13 @@ class Club extends RowModel
{ {
$count = 0; $count = 0;
if(is_null($user)) { if(is_null($user))
return NULL; return NULL;
}
if($this->canBeModifiedBy($user)) { if($this->canBeModifiedBy($user))
$count = (new Posts)->getSuggestedPostsCount($this->getId()); $count = (new Posts)->getSuggestedPostsCount($this->getId());
} else { else
$count = (new Posts)->getSuggestedPostsCountByUser($this->getId(), $user->getId()); $count = (new Posts)->getSuggestedPostsCountByUser($this->getId(), $user->getId());
}
return $count; return $count;
} }

View file

@ -300,10 +300,9 @@ class Poll extends Attachable
["attachable_type" => static::class, ["attachable_type" => static::class,
"attachable_id" => $this->getId()])->fetch(); "attachable_id" => $this->getId()])->fetch();
if(!is_null($post->target_id)) { if(!is_null($post->target_id))
return (new Posts)->get($post->target_id); return (new Posts)->get($post->target_id);
} else { else
return NULL; return NULL;
} }
}
} }

View file

@ -33,11 +33,10 @@ final class GroupPresenter extends OpenVKPresenter
$this->template->topicsCount = (new Topics)->getClubTopicsCount($club); $this->template->topicsCount = (new Topics)->getClubTopicsCount($club);
} }
if(!is_null($this->user->identity) && !$club->canBeModifiedBy($this->user->identity) && $club->getWallType() == 2) { 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); $this->template->suggestedPostsCountByUser = (new Posts)->getSuggestedPostsCountByUser($club->getId(), $this->user->id);
} else
if(!is_null($this->user->identity) && $club->canBeModifiedBy($this->user->identity) && $club->getWallType() == 2) {
$this->template->suggestedPostsCountByEveryone = (new Posts)->getSuggestedPostsCount($club->getId()); $this->template->suggestedPostsCountByEveryone = (new Posts)->getSuggestedPostsCount($club->getId());
} }

View file

@ -310,9 +310,8 @@ final class WallPresenter extends OpenVKPresenter
$post->setFlags($flags); $post->setFlags($flags);
$post->setNsfw($this->postParam("nsfw") === "on"); $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->setSuggested(1);
}
$post->save(); $post->save();
} catch (\LengthException $ex) { } catch (\LengthException $ex) {
@ -351,17 +350,14 @@ final class WallPresenter extends OpenVKPresenter
if($wall < 0 && !$wallOwner->canBeModifiedBy($this->user->identity) && $wallOwner->getWallType() == 2) { if($wall < 0 && !$wallOwner->canBeModifiedBy($this->user->identity) && $wallOwner->getWallType() == 2) {
$suggsCount = $this->posts->getSuggestedPostsCount($wallOwner->getId()); $suggsCount = $this->posts->getSuggestedPostsCount($wallOwner->getId());
# Возможно, это заебёт админов групп, но так они хотя бы про паблик вспомнят
# Мб рандома добавить?
if($suggsCount % 10 == 0) { if($suggsCount % 10 == 0) {
$managers = $wallOwner->getManagers(); $managers = $wallOwner->getManagers();
$owner = $wallOwner->getOwner(); $owner = $wallOwner->getOwner();
(new NewSuggestedPostsNotification($owner, $wallOwner))->emit(); (new NewSuggestedPostsNotification($owner, $wallOwner))->emit();
foreach($managers as $manager) { foreach($managers as $manager)
(new NewSuggestedPostsNotification($manager->getUser(), $wallOwner))->emit(); (new NewSuggestedPostsNotification($manager->getUser(), $wallOwner))->emit();
} }
}
$this->redirect("/club".$wallOwner->getId()."/suggested"); $this->redirect("/club".$wallOwner->getId()."/suggested");
} else { } else {

View file

@ -14,15 +14,13 @@
<h4 id="cound">{if $type == "my"}{tr("suggested_posts_in_group_by_you", $count)}{else}{tr("suggested_posts_in_group", $count)}{/if}</h4> <h4 id="cound">{if $type == "my"}{tr("suggested_posts_in_group_by_you", $count)}{else}{tr("suggested_posts_in_group", $count)}{/if}</h4>
<div id="postz" class="infContainer"> <div id="postz" class="infContainer">
{var $microblog = $thisUser->hasMicroblogEnabled()} {var $microblog = $thisUser->hasMicroblogEnabled()}
{foreach $posts as $post} <div class="infObj" n:foreach="$posts as $post">
<div class="infObj">
{if $microblog} {if $microblog}
{include "../components/post/microblogpost.xml", post => $post, commentSection => false, suggestion => true, forceNoCommentsLink => true, forceNoPinLink => true, forceNoLike => true, forceNoShareLink => true, forceNoDeleteLink => false} {include "../components/post/microblogpost.xml", post => $post, commentSection => false, suggestion => true, forceNoCommentsLink => true, forceNoPinLink => true, forceNoLike => true, forceNoShareLink => true, forceNoDeleteLink => false}
{else} {else}
{include "../components/post/oldpost.xml", post => $post, commentSection => false, suggestion => true, forceNoCommentsLink => true, forceNoPinLink => true, forceNoLike => true, forceNoShareLink => true, forceNoDeleteLink => false} {include "../components/post/oldpost.xml", post => $post, commentSection => false, suggestion => true, forceNoCommentsLink => true, forceNoPinLink => true, forceNoLike => true, forceNoShareLink => true, forceNoDeleteLink => false}
{/if} {/if}
</div> </div>
{/foreach}
{include "../components/paginator.xml", conf => (object) [ {include "../components/paginator.xml", conf => (object) [
"page" => $page, "page" => $page,