mirror of
https://github.com/openvk/openvk
synced 2025-07-07 00:09:48 +03:00
Compare commits
1 commit
a6ce85aa6c
...
7a15e6da03
Author | SHA1 | Date | |
---|---|---|---|
|
7a15e6da03 |
8 changed files with 22 additions and 37 deletions
|
@ -1104,18 +1104,13 @@ final class Wall extends VKAPIRequestHandler
|
|||
|
||||
$post = (new PostsRepo())->getPostById($owner_id, $post_id, true);
|
||||
if (!$post || $post->isDeleted()) {
|
||||
$this->fail(15, "Not found");
|
||||
$this->fail(583, "Invalid post");
|
||||
}
|
||||
|
||||
$wallOwner = $post->getWallOwner();
|
||||
|
||||
# trying to solve the condition below.
|
||||
# $post->getTargetWall() < 0 - if post on wall of club
|
||||
# !$post->getWallOwner()->canBeModifiedBy($this->getUser()) - group is cannot be modifiet by %user%
|
||||
# $post->getWallOwner()->getWallType() != 1 - wall is not open
|
||||
# $post->getSuggestionType() == 0 - post is not suggested
|
||||
if ($post->getTargetWall() < 0 && !$post->getWallOwner()->canBeModifiedBy($this->getUser()) && $post->getWallOwner()->getWallType() != 1 && $post->getSuggestionType() == 0) {
|
||||
$this->fail(15, "Access denied");
|
||||
$this->fail(12, "Access denied: you can't delete your accepted post.");
|
||||
}
|
||||
|
||||
if ($post->getOwnerPost() == $this->getUser()->getId() || $post->getTargetWall() == $this->getUser()->getId() || $owner_id < 0 && $wallOwner->canBeModifiedBy($this->getUser())) {
|
||||
|
|
|
@ -260,7 +260,6 @@ class Playlist extends MediaCollection
|
|||
$cover->setDescription("Playlist cover image");
|
||||
$cover->setFile($file);
|
||||
$cover->setCreated(time());
|
||||
$cover->setSystem(true);
|
||||
$cover->save();
|
||||
|
||||
$this->setCover_photo_id($cover->getId());
|
||||
|
|
|
@ -135,7 +135,7 @@ final class GroupPresenter extends OpenVKPresenter
|
|||
|
||||
$this->template->paginatorConf = (object) [
|
||||
"count" => $this->template->count,
|
||||
"page" => (int) ($this->queryParam("p") ?? 1),
|
||||
"page" => (int)($this->queryParam("p") ?? 1),
|
||||
"amount" => 10,
|
||||
"perPage" => OPENVK_DEFAULT_PER_PAGE,
|
||||
];
|
||||
|
|
|
@ -272,25 +272,21 @@ final class PhotosPresenter extends OpenVKPresenter
|
|||
$this->assertUserLoggedIn();
|
||||
$this->willExecuteWriteAction(true);
|
||||
|
||||
$upload_context = $this->queryParam("upload_context");
|
||||
|
||||
if (is_null($this->queryParam("album"))) {
|
||||
if ((int) $upload_context == $this->user->id) {
|
||||
$album = $this->albums->getUserWallAlbum($this->user->identity);
|
||||
}
|
||||
$album = $this->albums->getUserWallAlbum($this->user->identity);
|
||||
} else {
|
||||
[$owner, $id] = explode("_", $this->queryParam("album"));
|
||||
$album = $this->albums->get((int) $id);
|
||||
}
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "GET" || $this->queryParam("act") == "finish") {
|
||||
if (!$album) {
|
||||
$this->flashFail("err", tr("error"), tr("error_adding_to_deleted"));
|
||||
}
|
||||
if (!$album) {
|
||||
$this->flashFail("err", tr("error"), tr("error_adding_to_deleted"), 500, true);
|
||||
}
|
||||
|
||||
if ($album && !$album->canBeModifiedBy($this->user->identity)) {
|
||||
$this->flashFail("err", tr("error_access_denied_short"), tr("error_access_denied"));
|
||||
# Для быстрой загрузки фоток из пикера фотографий нужен альбом, но юзер не может загружать фото
|
||||
# в системные альбомы, так что так.
|
||||
if (is_null($this->user) || !is_null($this->queryParam("album")) && !$album->canBeModifiedBy($this->user->identity)) {
|
||||
$this->flashFail("err", tr("error_access_denied_short"), tr("error_access_denied"), 500, true);
|
||||
}
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
|
@ -310,6 +306,8 @@ final class PhotosPresenter extends OpenVKPresenter
|
|||
|
||||
$phot->setDescription($description);
|
||||
$phot->save();
|
||||
|
||||
$album = $phot->getAlbum();
|
||||
}
|
||||
|
||||
$this->returnJson(["success" => true,
|
||||
|
@ -348,11 +346,9 @@ final class PhotosPresenter extends OpenVKPresenter
|
|||
$this->flashFail("err", "Неизвестная ошибка", "Не удалось сохранить фотографию в $name.", 500, true);
|
||||
}
|
||||
|
||||
if ($album != null) {
|
||||
$album->addPhoto($photo);
|
||||
$album->setEdited(time());
|
||||
$album->save();
|
||||
}
|
||||
$album->addPhoto($photo);
|
||||
$album->setEdited(time());
|
||||
$album->save();
|
||||
}
|
||||
|
||||
$this->returnJson(["success" => true,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
{block title}{_albums} {$owner->getCanonicalName()}{/block}
|
||||
|
||||
{block header}
|
||||
{if isset($thisUser) && $thisUser->getId() == $owner->getRealId()}
|
||||
{if isset($thisUser) && $thisUser->getId() == $owner->getId()}
|
||||
{_my_photos}
|
||||
{else}
|
||||
<a href="{$owner->getURL()}">
|
||||
|
@ -18,7 +18,7 @@
|
|||
{block size}
|
||||
<div style="padding-bottom: 0px; padding-top: 0;" class="summaryBar">
|
||||
<div class="summary">
|
||||
{if !is_null($thisUser) && $owner->getRealId() === $thisUser->getId()}
|
||||
{if !is_null($thisUser) && $owner->getId() === $thisUser->getId()}
|
||||
{tr("albums_list", $count)}
|
||||
{else}
|
||||
{tr("albums", $count)}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
{* remove the "n:if" if you having issues with your theme *}
|
||||
|
||||
<link n:if="$theme->getId() != 'mobile_ovk'" rel="stylesheet" href="/themepack/{$theme->getId()}/{$theme->getVersion()}/stylesheet/styles.css" />
|
||||
<link n:if="!$theme->overridesTemplates()" rel="stylesheet" href="/themepack/{$theme->getId()}/{$theme->getVersion()}/stylesheet/styles.css" />
|
||||
|
||||
{if $isXmas}
|
||||
<link rel="stylesheet" href="/themepack/{$theme->getId()}/{$theme->getVersion()}/resource/xmas.css" />
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
{var $textAreaId = ($post ?? NULL) === NULL ? (++$GLOBALS["textAreaCtr"]) : $post->getId()}
|
||||
{var $textAreaId = ($custom_id ?? NULL) === NULL ? $textAreaId : $custom_id}
|
||||
|
||||
<div id="write" class='model_content_textarea' style="padding: 5px 0;" data-id="{is_null($owner) || gettype($owner) == 'integer' ? $owner : $owner->getId()}">
|
||||
<div id="write" class='model_content_textarea' style="padding: 5px 0;">
|
||||
<form action="{$route}" method="post" enctype="multipart/form-data" style="margin:0;">
|
||||
<textarea id="wall-post-input{$textAreaId}" placeholder="{_write}" name="text" style="width: 100%;resize: none;" class="small-textarea"></textarea>
|
||||
<div>
|
||||
|
|
|
@ -1198,7 +1198,7 @@ async function __uploadToTextarea(file, textareaNode) {
|
|||
const rand = random_int(0, 1000)
|
||||
textareaNode.find('.post-horizontal').append(`<a id='temp_filler${rand}' class="upload-item lagged"><img src='${temp_url}'></a>`)
|
||||
|
||||
const res = await fetch(`/photos/upload?upload_context=${textareaNode.nodes[0].dataset.id}`, {
|
||||
const res = await fetch(`/photos/upload`, {
|
||||
method: 'POST',
|
||||
body: form_data
|
||||
})
|
||||
|
@ -1366,7 +1366,7 @@ u(document).on("click", "#__photoAttachment", async (e) => {
|
|||
if(album == 0) {
|
||||
photos = await window.OVKAPI.call('photos.getAll', {'owner_id': window.openvk.current_id, 'photo_sizes': 1, 'count': photos_per_page, 'offset': page * photos_per_page})
|
||||
} else {
|
||||
photos = await window.OVKAPI.call('photos.get', {'owner_id': club != 0 ? Math.abs(club) * -1 : window.openvk.current_id, 'album_id': album, 'photo_sizes': 1, 'count': photos_per_page, 'offset': page * photos_per_page})
|
||||
photos = await window.OVKAPI.call('photos.get', {'owner_id': window.openvk.current_id, 'album_id': album, 'photo_sizes': 1, 'count': photos_per_page, 'offset': page * photos_per_page})
|
||||
}
|
||||
} catch(e) {
|
||||
u("#attachment_insert_count h4").html(tr("is_x_photos", -1))
|
||||
|
@ -2572,12 +2572,7 @@ u(document).on('mouseover mousemove mouseout', `div[data-tip='simple']`, (e) =>
|
|||
})
|
||||
|
||||
function setStatusEditorShown(shown) {
|
||||
if(shown) {
|
||||
document.getElementById("status_editor").style.display = "block"
|
||||
document.querySelector("#status_editor input").focus()
|
||||
} else {
|
||||
document.getElementById("status_editor").style.display = "none"
|
||||
}
|
||||
document.getElementById("status_editor").style.display = shown ? "block" : "none";
|
||||
}
|
||||
|
||||
u(document).on('click', (event) => {
|
||||
|
|
Loading…
Reference in a new issue