diff --git a/ServiceAPI/Photos.php b/ServiceAPI/Photos.php deleted file mode 100644 index 16d602f2..00000000 --- a/ServiceAPI/Photos.php +++ /dev/null @@ -1,92 +0,0 @@ -user = $user; - $this->photos = new PhotosRepo; - } - - function getPhotos(int $page = 1, int $album = 0, callable $resolve, callable $reject) - { - if($album == 0) { - $photos = $this->photos->getEveryUserPhoto($this->user, $page, 24); - $count = $this->photos->getUserPhotosCount($this->user); - } else { - $album = (new Albums)->get($album); - - if(!$album || $album->isDeleted()) - $reject(55, "Invalid ."); - - if($album->getOwner() instanceof User) { - if($album->getOwner()->getId() != $this->user->getId()) - $reject(555, "Access to album denied"); - } else { - if(!$album->getOwner()->canBeModifiedBy($this->user)) - $reject(555, "Access to album denied"); - } - - $photos = $album->getPhotos($page, 24); - $count = $album->size(); - } - - $arr = [ - "count" => $count, - "items" => [], - ]; - - foreach($photos as $photo) { - $res = json_decode(json_encode($photo->toVkApiStruct()), true); - - $arr["items"][] = $res; - } - - $resolve($arr); - } - - function getAlbums(int $club, callable $resolve, callable $reject) - { - $albumsRepo = (new Albums); - - $count = $albumsRepo->getUserAlbumsCount($this->user); - $albums = $albumsRepo->getUserAlbums($this->user, 1, $count); - - $arr = [ - "count" => $count, - "items" => [], - ]; - - foreach($albums as $album) { - $res = ["id" => $album->getId(), "name" => $album->getName()]; - - $arr["items"][] = $res; - } - - if($club > 0) { - $cluber = (new Clubs)->get($club); - - if(!$cluber || !$cluber->canBeModifiedBy($this->user)) - $reject(1337, "Invalid (club), or you can't modify him"); - - $clubCount = (new Albums)->getClubAlbumsCount($cluber); - $clubAlbums = (new Albums)->getClubAlbums($cluber, 1, $clubCount); - - foreach($clubAlbums as $albumr) { - $res = ["id" => $albumr->getId(), "name" => $albumr->getName()]; - - $arr["items"][] = $res; - } - - $arr["count"] = $arr["count"] + $clubCount; - } - - $resolve($arr); - } -} diff --git a/VKAPI/Handlers/Groups.php b/VKAPI/Handlers/Groups.php index f8706191..bd546c3d 100644 --- a/VKAPI/Handlers/Groups.php +++ b/VKAPI/Handlers/Groups.php @@ -11,6 +11,12 @@ final class Groups extends VKAPIRequestHandler { $this->requireUser(); + # InfoApp fix + if($filter == "admin" && ($user_id != 0 && $user_id != $this->getUser()->getId())) { + $this->fail(15, 'Access denied: filter admin is available only for current user'); + } + + $clbs = []; if($user_id == 0) { foreach($this->getUser()->getClubs($offset, $filter == "admin", $count, true) as $club) $clbs[] = $club; diff --git a/VKAPI/Handlers/Photos.php b/VKAPI/Handlers/Photos.php index d06ecde3..319ce070 100644 --- a/VKAPI/Handlers/Photos.php +++ b/VKAPI/Handlers/Photos.php @@ -427,7 +427,7 @@ final class Photos extends VKAPIRequestHandler $this->fail(15, "Access denied"); $photos = array_slice(iterator_to_array($album->getPhotos(1, $count + $offset)), $offset); - $res["count"] = sizeof($photos); + $res["count"] = $album->size(); foreach($photos as $photo) { if(!$photo || $photo->isDeleted()) continue; @@ -638,15 +638,15 @@ final class Photos extends VKAPIRequestHandler $this->fail(4, "This method doesn't works with clubs"); $user = (new UsersRepo)->get($owner_id); - if(!$user) $this->fail(4, "Invalid user"); if(!$user->getPrivacyPermission('photos.read', $this->getUser())) $this->fail(21, "This user chose to hide his albums."); - $photos = array_slice(iterator_to_array((new PhotosRepo)->getEveryUserPhoto($user, 1, $count + $offset)), $offset); + $photos = (new PhotosRepo)->getEveryUserPhoto($user, $offset, $count); $res = [ + "count" => (new PhotosRepo)->getUserPhotosCount($user), "items" => [], ]; diff --git a/Web/Models/Entities/Album.php b/Web/Models/Entities/Album.php index dccd4e63..cc96cc0b 100644 --- a/Web/Models/Entities/Album.php +++ b/Web/Models/Entities/Album.php @@ -87,6 +87,7 @@ class Album extends MediaCollection $res = (object) []; $res->id = $this->getPrettyId(); + $res->vid = $this->getId(); $res->thumb_id = !is_null($this->getCoverPhoto()) ? $this->getCoverPhoto()->getPrettyId() : 0; $res->owner_id = $this->getOwner()->getId(); $res->title = $this->getName(); diff --git a/Web/Models/Entities/Photo.php b/Web/Models/Entities/Photo.php index 3ea46939..90c532b2 100644 --- a/Web/Models/Entities/Photo.php +++ b/Web/Models/Entities/Photo.php @@ -308,7 +308,7 @@ class Photo extends Media $res->date = $res->created = $this->getPublicationTime()->timestamp(); if($photo_sizes) { - $res->sizes = $this->getVkApiSizes(); + $res->sizes = array_values($this->getVkApiSizes()); $res->src_small = $res->photo_75 = $this->getURLBySizeId("miniscule"); $res->src = $res->photo_130 = $this->getURLBySizeId("tiny"); $res->src_big = $res->photo_604 = $this->getURLBySizeId("normal"); diff --git a/Web/Models/Repositories/Photos.php b/Web/Models/Repositories/Photos.php index 0698c914..a024747c 100644 --- a/Web/Models/Repositories/Photos.php +++ b/Web/Models/Repositories/Photos.php @@ -33,7 +33,7 @@ class Photos return new Photo($photo); } - function getEveryUserPhoto(User $user, int $page = 1, ?int $perPage = NULL): \Traversable + function getEveryUserPhoto(User $user, int $offset = 0, int $limit = 10): \Traversable { $perPage = $perPage ?? OPENVK_DEFAULT_PER_PAGE; $photos = $this->photos->where([ @@ -41,7 +41,7 @@ class Photos "deleted" => 0 ])->order("id DESC"); - foreach($photos->page($page, $perPage) as $photo) { + foreach($photos->limit($limit, $offset) as $photo) { yield new Photo($photo); } } diff --git a/Web/Presenters/AudioPresenter.php b/Web/Presenters/AudioPresenter.php index 7e2825c1..ae38d1d0 100644 --- a/Web/Presenters/AudioPresenter.php +++ b/Web/Presenters/AudioPresenter.php @@ -33,6 +33,7 @@ final class AudioPresenter extends OpenVKPresenter function renderList(?int $owner = NULL, ?string $mode = "list"): void { + $this->assertUserLoggedIn(); $this->template->_template = "Audio/List.xml"; $page = (int)($this->queryParam("p") ?? 1); $audios = []; @@ -501,6 +502,7 @@ final class AudioPresenter extends OpenVKPresenter function renderPlaylist(int $owner_id, int $virtual_id): void { + $this->assertUserLoggedIn(); $playlist = $this->audios->getPlaylistByOwnerAndVID($owner_id, $virtual_id); $page = (int)($this->queryParam("p") ?? 1); if (!$playlist || $playlist->isDeleted()) diff --git a/Web/Presenters/CommentPresenter.php b/Web/Presenters/CommentPresenter.php index 68a386bb..741a03e6 100644 --- a/Web/Presenters/CommentPresenter.php +++ b/Web/Presenters/CommentPresenter.php @@ -27,7 +27,12 @@ final class CommentPresenter extends OpenVKPresenter $this->flashFail("err", tr("error"), tr("forbidden")); if(!is_null($this->user)) $comment->toggleLike($this->user->identity); - + if($_SERVER["REQUEST_METHOD"] === "POST") { + $this->returnJson([ + 'success' => true, + ]); + } + $this->redirect($_SERVER["HTTP_REFERER"]); } @@ -108,7 +113,7 @@ final class CommentPresenter extends OpenVKPresenter continue; } - $post->attach($horizontal_attachment); + $comment->attach($horizontal_attachment); } foreach($vertical_attachments as $vertical_attachment) { @@ -116,7 +121,7 @@ final class CommentPresenter extends OpenVKPresenter continue; } - $post->attach($vertical_attachment); + $comment->attach($vertical_attachment); } if($entity->getOwner()->getId() !== $this->user->identity->getId()) diff --git a/Web/Presenters/PhotosPresenter.php b/Web/Presenters/PhotosPresenter.php index 09130c60..1bcd50da 100644 --- a/Web/Presenters/PhotosPresenter.php +++ b/Web/Presenters/PhotosPresenter.php @@ -287,7 +287,8 @@ final class PhotosPresenter extends OpenVKPresenter "id" => $photo->getId(), "vid" => $photo->getVirtualId(), "owner" => $photo->getOwner()->getId(), - "link" => $photo->getURL() + "link" => $photo->getURL(), + "pretty_id" => $photo->getPrettyId(), ]; } catch(ISE $ex) { $name = $album->getName(); diff --git a/Web/Presenters/WallPresenter.php b/Web/Presenters/WallPresenter.php index a9d08258..8a68d427 100644 --- a/Web/Presenters/WallPresenter.php +++ b/Web/Presenters/WallPresenter.php @@ -412,6 +412,12 @@ final class WallPresenter extends OpenVKPresenter if(!is_null($this->user)) { $post->toggleLike($this->user->identity); } + + if($_SERVER["REQUEST_METHOD"] === "POST") { + $this->returnJson([ + 'success' => true, + ]); + } $this->redirect("$_SERVER[HTTP_REFERER]#postGarter=" . $post->getId()); } diff --git a/Web/Presenters/templates/@layout.xml b/Web/Presenters/templates/@layout.xml index 632bb96f..3b23952b 100644 --- a/Web/Presenters/templates/@layout.xml +++ b/Web/Presenters/templates/@layout.xml @@ -427,6 +427,9 @@ window.openvk = { "audio_genres": {\openvk\Web\Models\Entities\Audio::genres}, "at_search": {$atSearch ?? false}, + "max_attachments": {\OPENVK_ROOT_CONF["openvk"]["preferences"]["wall"]["postSizes"]["maxAttachments"]}, + "max_filesize_mb": 5, + "current_id": {$thisUser ? $thisUser->getId() : 0}, } diff --git a/Web/Presenters/templates/components/post/oldpost.xml b/Web/Presenters/templates/components/post/oldpost.xml index 9730fb25..48063747 100644 --- a/Web/Presenters/templates/components/post/oldpost.xml +++ b/Web/Presenters/templates/components/post/oldpost.xml @@ -148,7 +148,7 @@  |  {/if} - + {_share} {if $repostsCount > 0} ({$repostsCount}) diff --git a/Web/Presenters/templates/components/textArea.xml b/Web/Presenters/templates/components/textArea.xml index e53c1d88..a3b7bfa0 100644 --- a/Web/Presenters/templates/components/textArea.xml +++ b/Web/Presenters/templates/components/textArea.xml @@ -2,26 +2,18 @@ {var $textAreaId = ($post ?? NULL) === NULL ? (++$GLOBALS["textAreaCtr"]) : $post->getId()} {var $textAreaId = ($custom_id ?? NULL) === NULL ? $textAreaId : $custom_id} -
+
-