diff --git a/ServiceAPI/Groups.php b/ServiceAPI/Groups.php
new file mode 100644
index 00000000..9eed0e8d
--- /dev/null
+++ b/ServiceAPI/Groups.php
@@ -0,0 +1,39 @@
+user = $user;
+ $this->groups = new Clubs;
+ }
+
+ function getWriteableClubs(callable $resolve, callable $reject)
+ {
+ $clubs = [];
+ $wclubs = $this->groups->getWriteableClubs($this->user->getId());
+ $count = $this->groups->getWriteableClubsCount($this->user->getId());
+
+ if(!$count) {
+ $reject("You don't have any groups with write access");
+
+ return;
+ }
+
+ foreach($wclubs as $club) {
+ $clubs[] = [
+ "name" => $club->getName(),
+ "id" => $club->getId(),
+ "avatar" => $club->getAvatarUrl() # если в овк когда-нибудь появится крутой список с аватарками, то можно использовать это поле
+ ];
+ }
+
+ $resolve($clubs);
+ }
+}
diff --git a/VKAPI/Handlers/Wall.php b/VKAPI/Handlers/Wall.php
index 85cccdbf..657dac62 100644
--- a/VKAPI/Handlers/Wall.php
+++ b/VKAPI/Handlers/Wall.php
@@ -476,25 +476,38 @@ final class Wall extends VKAPIRequestHandler
return (object)["post_id" => $post->getVirtualId()];
}
- function repost(string $object, string $message = "") {
+ function repost(string $object, string $message = "", int $group_id = 0) {
$this->requireUser();
$this->willExecuteWriteAction();
$postArray;
if(preg_match('/wall((?:-?)[0-9]+)_([0-9]+)/', $object, $postArray) == 0)
$this->fail(100, "One of the parameters specified was missing or invalid: object is incorrect");
-
+
$post = (new PostsRepo)->getPostById((int) $postArray[1], (int) $postArray[2]);
if(!$post || $post->isDeleted()) $this->fail(100, "One of the parameters specified was missing or invalid");
-
+
$nPost = new Post;
$nPost->setOwner($this->user->getId());
- $nPost->setWall($this->user->getId());
+
+ 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 {
+ $nPost->setWall($this->user->getId());
+ }
+
$nPost->setContent($message);
$nPost->setApi_Source_Name($this->getPlatform());
$nPost->save();
$nPost->attach($post);
-
+
if($post->getOwner(false)->getId() !== $this->user->getId() && !($post->getOwner() instanceof Club))
(new RepostNotification($post->getOwner(false), $post, $this->user->identity))->emit();
@@ -506,6 +519,7 @@ final class Wall extends VKAPIRequestHandler
];
}
+
function getComments(int $owner_id, int $post_id, bool $need_likes = true, int $offset = 0, int $count = 10, string $fields = "sex,screen_name,photo_50,photo_100,online_info,online", string $sort = "asc", bool $extended = false) {
$this->requireUser();
diff --git a/Web/Models/Entities/Video.php b/Web/Models/Entities/Video.php
index ee53b378..bddb00a4 100644
--- a/Web/Models/Entities/Video.php
+++ b/Web/Models/Entities/Video.php
@@ -195,11 +195,11 @@ class Video extends Media
$this->save();
}
- static function fastMake(int $owner, string $description = "", array $file, bool $unlisted = true, bool $anon = false): Video
+ static function fastMake(int $owner, string $name = "Unnamed Video.ogv", string $description = "", array $file, bool $unlisted = true, bool $anon = false): Video
{
$video = new Video;
$video->setOwner($owner);
- $video->setName("Unnamed Video.ogv");
+ $video->setName(ovk_proc_strtr($name, 61));
$video->setDescription(ovk_proc_strtr($description, 300));
$video->setAnonymous($anon);
$video->setCreated(time());
diff --git a/Web/Models/Repositories/Clubs.php b/Web/Models/Repositories/Clubs.php
index edbe75c6..8e97f3eb 100644
--- a/Web/Models/Repositories/Clubs.php
+++ b/Web/Models/Repositories/Clubs.php
@@ -1,7 +1,7 @@
context = DatabaseConnection::i()->getContext();
- $this->clubs = $this->context->table("groups");
+ $this->context = DatabaseConnection::i()->getContext();
+ $this->clubs = $this->context->table("groups");
+ $this->coadmins = $this->context->table("group_coadmins");
}
private function toClub(?ActiveRow $ar): ?Club
@@ -70,6 +72,26 @@ class Clubs
];
*/
}
-
+
+ function getWriteableClubs(int $id): \Traversable
+ {
+ $result = $this->clubs->where("owner", $id);
+ $coadmins = $this->coadmins->where("user", $id);
+
+ foreach($result as $entry) {
+ yield new Club($entry);
+ }
+
+ foreach($coadmins as $coadmin) {
+ $cl = new Manager($coadmin);
+ yield $cl->getClub();
+ }
+ }
+
+ function getWriteableClubsCount(int $id): int
+ {
+ return sizeof($this->clubs->where("owner", $id)) + sizeof($this->coadmins->where("user", $id));
+ }
+
use \Nette\SmartObject;
}
diff --git a/Web/Presenters/CommentPresenter.php b/Web/Presenters/CommentPresenter.php
index 50c72248..93d2a816 100644
--- a/Web/Presenters/CommentPresenter.php
+++ b/Web/Presenters/CommentPresenter.php
@@ -74,7 +74,7 @@ final class CommentPresenter extends OpenVKPresenter
}
if($_FILES["_vid_attachment"]["error"] === UPLOAD_ERR_OK) {
- $video = Video::fastMake($this->user->id, $this->postParam("text"), $_FILES["_vid_attachment"]);
+ $video = Video::fastMake($this->user->id, $_FILES["_vid_attachment"]["name"], $this->postParam("text"), $_FILES["_vid_attachment"]);
}
} catch(ISE $ex) {
$this->flashFail("err", "Не удалось опубликовать комментарий", "Файл медиаконтента повреждён или слишком велик.");
diff --git a/Web/Presenters/TopicsPresenter.php b/Web/Presenters/TopicsPresenter.php
index 528b51ad..e081382a 100644
--- a/Web/Presenters/TopicsPresenter.php
+++ b/Web/Presenters/TopicsPresenter.php
@@ -105,7 +105,7 @@ final class TopicsPresenter extends OpenVKPresenter
}
if($_FILES["_vid_attachment"]["error"] === UPLOAD_ERR_OK) {
- $video = Video::fastMake($this->user->id, $this->postParam("text"), $_FILES["_vid_attachment"]);
+ $video = Video::fastMake($this->user->id, $_FILES["_vid_attachment"]["name"], $this->postParam("text"), $_FILES["_vid_attachment"]);
}
} catch(ISE $ex) {
$this->flash("err", "Не удалось опубликовать комментарий", "Файл медиаконтента повреждён или слишком велик.");
diff --git a/Web/Presenters/WallPresenter.php b/Web/Presenters/WallPresenter.php
index ffcec2a7..5c9326db 100644
--- a/Web/Presenters/WallPresenter.php
+++ b/Web/Presenters/WallPresenter.php
@@ -258,7 +258,7 @@ final class WallPresenter extends OpenVKPresenter
}
if($_FILES["_vid_attachment"]["error"] === UPLOAD_ERR_OK)
- $video = Video::fastMake($this->user->id, $this->postParam("text"), $_FILES["_vid_attachment"], $anon);
+ $video = Video::fastMake($this->user->id, $_FILES["_vid_attachment"]["name"], $this->postParam("text"), $_FILES["_vid_attachment"], $anon);
} catch(\DomainException $ex) {
$this->flashFail("err", tr("failed_to_publish_post"), tr("media_file_corrupted"));
} catch(ISE $ex) {
@@ -363,21 +363,52 @@ final class WallPresenter extends OpenVKPresenter
$this->assertNoCSRF();
$post = $this->posts->getPostById($wall, $post_id);
- if(!$post || $post->isDeleted()) $this->notFound();
+
+ if(!$post || $post->isDeleted())
+ $this->notFound();
+ $where = $this->postParam("type") ?? "wall";
+ $groupId = NULL;
+ $flags = 0;
+
+ if($where == "group")
+ $groupId = $this->postParam("groupId");
+
if(!is_null($this->user)) {
$nPost = new Post;
- $nPost->setOwner($this->user->id);
- $nPost->setWall($this->user->id);
+
+ if($where == "wall") {
+ $nPost->setOwner($this->user->id);
+ $nPost->setWall($this->user->id);
+ } elseif($where == "group") {
+ $nPost->setOwner($this->user->id);
+ $club = (new Clubs)->get((int)$groupId);
+
+ if(!$club || !$club->canBeModifiedBy($this->user->identity))
+ $this->notFound();
+
+ if($this->postParam("asGroup") == 1)
+ $flags |= 0b10000000;
+
+ if($this->postParam("signed") == 1)
+ $flags |= 0b01000000;
+
+ $nPost->setWall($groupId * -1);
+ }
+
$nPost->setContent($this->postParam("text"));
+ $nPost->setFlags($flags);
$nPost->save();
+
$nPost->attach($post);
if($post->getOwner(false)->getId() !== $this->user->identity->getId() && !($post->getOwner() instanceof Club))
(new RepostNotification($post->getOwner(false), $post, $this->user->identity))->emit();
};
-
- $this->returnJson(["wall_owner" => $this->user->identity->getId()]);
+
+ $this->returnJson([
+ "wall_owner" => $where == "wall" ? $this->user->identity->getId() : $groupId * -1
+ ]);
}
function renderDelete(int $wall, int $post_id): void
diff --git a/Web/Presenters/templates/About/Version.xml b/Web/Presenters/templates/About/Version.xml
index 36fbbb64..4d89a93d 100644
--- a/Web/Presenters/templates/About/Version.xml
+++ b/Web/Presenters/templates/About/Version.xml
@@ -458,7 +458,7 @@
Initial hosting
-
Ilya Prokopenko (dsrev) and Celestora
+
Lumaeris and Celestora
Initial bug-tracker hosting
@@ -492,7 +492,7 @@
kovaltim, Vladimir Lapskiy (0x7d5), Alexander Minkin (WerySkok), Polina Katunina (RousPhaul), veth,
Egor Shevchenko, Vadim Korovin (yuni), Ash Defenders,
- Pavel Silaev, Dmitriy Daemon, Ilya Prokopenko (dsrev),
+ Pavel Silaev, Dmitriy Daemon, Lumaeris,
cmed404 and unknown tester, who disappeared shortly after trying to upload post with cat.