mirror of
https://github.com/openvk/openvk
synced 2025-07-06 15:59:56 +03:00
Compare commits
11 commits
7a15e6da03
...
a6ce85aa6c
Author | SHA1 | Date | |
---|---|---|---|
|
a6ce85aa6c | ||
|
bf3f7ac3cb | ||
|
4d8370f322 | ||
|
6ffbc0ed29 | ||
|
abf43c7ab5 | ||
|
5416090407 | ||
|
b43fe8b016 | ||
|
ff61ba5e24 | ||
|
9bd59d2b89 | ||
|
88125a7195 | ||
|
51e640ce42 |
8 changed files with 37 additions and 22 deletions
|
@ -1104,13 +1104,18 @@ final class Wall extends VKAPIRequestHandler
|
|||
|
||||
$post = (new PostsRepo())->getPostById($owner_id, $post_id, true);
|
||||
if (!$post || $post->isDeleted()) {
|
||||
$this->fail(583, "Invalid post");
|
||||
$this->fail(15, "Not found");
|
||||
}
|
||||
|
||||
$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(12, "Access denied: you can't delete your accepted post.");
|
||||
$this->fail(15, "Access denied");
|
||||
}
|
||||
|
||||
if ($post->getOwnerPost() == $this->getUser()->getId() || $post->getTargetWall() == $this->getUser()->getId() || $owner_id < 0 && $wallOwner->canBeModifiedBy($this->getUser())) {
|
||||
|
|
|
@ -260,6 +260,7 @@ 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,21 +272,25 @@ final class PhotosPresenter extends OpenVKPresenter
|
|||
$this->assertUserLoggedIn();
|
||||
$this->willExecuteWriteAction(true);
|
||||
|
||||
$upload_context = $this->queryParam("upload_context");
|
||||
|
||||
if (is_null($this->queryParam("album"))) {
|
||||
$album = $this->albums->getUserWallAlbum($this->user->identity);
|
||||
if ((int) $upload_context == $this->user->id) {
|
||||
$album = $this->albums->getUserWallAlbum($this->user->identity);
|
||||
}
|
||||
} else {
|
||||
[$owner, $id] = explode("_", $this->queryParam("album"));
|
||||
$album = $this->albums->get((int) $id);
|
||||
}
|
||||
|
||||
if (!$album) {
|
||||
$this->flashFail("err", tr("error"), tr("error_adding_to_deleted"), 500, true);
|
||||
if ($_SERVER["REQUEST_METHOD"] == "GET" || $this->queryParam("act") == "finish") {
|
||||
if (!$album) {
|
||||
$this->flashFail("err", tr("error"), tr("error_adding_to_deleted"));
|
||||
}
|
||||
}
|
||||
|
||||
# Для быстрой загрузки фоток из пикера фотографий нужен альбом, но юзер не может загружать фото
|
||||
# в системные альбомы, так что так.
|
||||
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 ($album && !$album->canBeModifiedBy($this->user->identity)) {
|
||||
$this->flashFail("err", tr("error_access_denied_short"), tr("error_access_denied"));
|
||||
}
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
|
@ -306,8 +310,6 @@ final class PhotosPresenter extends OpenVKPresenter
|
|||
|
||||
$phot->setDescription($description);
|
||||
$phot->save();
|
||||
|
||||
$album = $phot->getAlbum();
|
||||
}
|
||||
|
||||
$this->returnJson(["success" => true,
|
||||
|
@ -346,9 +348,11 @@ final class PhotosPresenter extends OpenVKPresenter
|
|||
$this->flashFail("err", "Неизвестная ошибка", "Не удалось сохранить фотографию в $name.", 500, true);
|
||||
}
|
||||
|
||||
$album->addPhoto($photo);
|
||||
$album->setEdited(time());
|
||||
$album->save();
|
||||
if ($album != null) {
|
||||
$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->getId()}
|
||||
{if isset($thisUser) && $thisUser->getId() == $owner->getRealId()}
|
||||
{_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->getId() === $thisUser->getId()}
|
||||
{if !is_null($thisUser) && $owner->getRealId() === $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->overridesTemplates()" rel="stylesheet" href="/themepack/{$theme->getId()}/{$theme->getVersion()}/stylesheet/styles.css" />
|
||||
<link n:if="$theme->getId() != 'mobile_ovk'" 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;">
|
||||
<div id="write" class='model_content_textarea' style="padding: 5px 0;" data-id="{is_null($owner) || gettype($owner) == 'integer' ? $owner : $owner->getId()}">
|
||||
<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`, {
|
||||
const res = await fetch(`/photos/upload?upload_context=${textareaNode.nodes[0].dataset.id}`, {
|
||||
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': 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': 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})
|
||||
}
|
||||
} catch(e) {
|
||||
u("#attachment_insert_count h4").html(tr("is_x_photos", -1))
|
||||
|
@ -2572,7 +2572,12 @@ u(document).on('mouseover mousemove mouseout', `div[data-tip='simple']`, (e) =>
|
|||
})
|
||||
|
||||
function setStatusEditorShown(shown) {
|
||||
document.getElementById("status_editor").style.display = shown ? "block" : "none";
|
||||
if(shown) {
|
||||
document.getElementById("status_editor").style.display = "block"
|
||||
document.querySelector("#status_editor input").focus()
|
||||
} else {
|
||||
document.getElementById("status_editor").style.display = "none"
|
||||
}
|
||||
}
|
||||
|
||||
u(document).on('click', (event) => {
|
||||
|
|
Loading…
Reference in a new issue