mirror of
https://github.com/openvk/openvk
synced 2025-07-07 08:19:49 +03:00
Репост в группу где ты не создатель
Добавил репост в группу, где ты не создатель, а так же исправил стиль кода
This commit is contained in:
parent
b0ec86edbc
commit
07a1b33722
3 changed files with 34 additions and 24 deletions
|
@ -466,19 +466,20 @@ final class Wall extends VKAPIRequestHandler
|
|||
|
||||
$nPost = new Post;
|
||||
$nPost->setOwner($this->user->getId());
|
||||
if($group_id > 0)
|
||||
{
|
||||
$club = (new ClubsRepo)->get($group_id);
|
||||
if(!$club || !$club->canBeModifiedBy($this->user))
|
||||
{
|
||||
|
||||
if($group_id > 0) {
|
||||
$club = (new ClubsRepo)->get($group_id);
|
||||
if(!$club)
|
||||
$this->fail(42, "Invalid group");
|
||||
}
|
||||
|
||||
if(!$club->canBeModifiedBy($this->user))
|
||||
$this->fail(16, "Access to group denied");
|
||||
|
||||
$nPost->setWall($group_id*-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$nPost->setWall($this->user->getId());
|
||||
}
|
||||
|
||||
$nPost->setContent($message);
|
||||
$nPost->setApi_Source_Name($this->getPlatform());
|
||||
$nPost->save();
|
||||
|
|
|
@ -73,11 +73,17 @@ class Clubs
|
|||
|
||||
function getOwnedClubs(int $id): \Traversable
|
||||
{
|
||||
# infoapp
|
||||
$result = DatabaseConnection::i()->getConnection()->query("SELECT * FROM `groups` WHERE `owner` = $id ORDER BY `id`");
|
||||
|
||||
$result = DatabaseConnection::i()->getConnection()->query("SELECT * FROM `groups` WHERE `owner` = $id ORDER BY `id`;");
|
||||
$coadmins = DatabaseConnection::i()->getConnection()->query("SELECT * FROM `group_coadmins` WHERE `user` = $id ORDER BY `user`;");
|
||||
|
||||
foreach($result as $entry)
|
||||
yield $this->get($entry->id);
|
||||
|
||||
foreach($coadmins as $coadmin)
|
||||
yield $this->get($coadmin->club);
|
||||
|
||||
}
|
||||
|
||||
use \Nette\SmartObject;
|
||||
}
|
||||
|
|
|
@ -710,20 +710,23 @@ final class UserPresenter extends OpenVKPresenter
|
|||
|
||||
function renderOwnedClubs(int $id)
|
||||
{
|
||||
if($this->user->id == $id)
|
||||
{
|
||||
$this->assertUserLoggedIn();
|
||||
$clubs = iterator_to_array((new Clubs)->getOwnedClubs($id));
|
||||
$json = array();
|
||||
foreach($clubs as $club)
|
||||
{
|
||||
$json[]=array("name"=>$club->getName(),"id"=>$club->getId());
|
||||
}
|
||||
$this->returnJson($json);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if($this->user->id == $id) {
|
||||
$clubs = iterator_to_array((new Clubs)->getOwnedClubs($id));
|
||||
$json = [];
|
||||
|
||||
foreach($clubs as $club)
|
||||
$json[] = [
|
||||
"name" => $club->getName(),
|
||||
"id" => $club->getId()
|
||||
];
|
||||
|
||||
$this->returnJson($json);
|
||||
} else {
|
||||
|
||||
$this->returnJson(["You are not allowed to see user-created groups"]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue