Photos: Add changing of update date of album

Resolves #588
This commit is contained in:
Ilya Prokopenko 2022-07-29 16:41:43 +07:00
parent 80e9ec4ba7
commit 74b3bf5e3f
No known key found for this signature in database
GPG key ID: 7736BBBB05F14A56
5 changed files with 19 additions and 6 deletions

View file

@ -544,7 +544,7 @@ final class Wall extends VKAPIRequestHandler
];
}
function deleteComment(int $comment_id) {
function deleteComment(int $comment_id) {
$this->requireUser();
$comment = (new CommentsRepo)->get($comment_id);

View file

@ -243,8 +243,11 @@ class Photo extends Media
$photo->setFile($file);
$photo->save();
if(!is_null($album))
if(!is_null($album)) {
$album->addPhoto($photo);
$album->setEdited(time());
$album->save();
}
return $photo;
}

View file

@ -129,6 +129,7 @@ final class PhotosPresenter extends OpenVKPresenter
$name = $album->getName();
$owner = $album->getOwner();
$album->delete();
$this->flash("succ", "Альбом удалён", "Альбом $name был успешно удалён.");
$this->redirect("/albums" . ($owner instanceof Club ? "-" : "") . $owner->getId());
}
@ -241,7 +242,10 @@ final class PhotosPresenter extends OpenVKPresenter
}
$album->addPhoto($photo);
$this->redirect("/photo" . $photo->getPrettyId(), static::REDIRECT_TEMPORARY);
$album->setEdited(time());
$album->save();
$this->redirect("/photo" . $photo->getPrettyId() . "?from=album" . $album->getId(), static::REDIRECT_TEMPORARY);
} else {
$this->template->album = $album;
}
@ -262,6 +266,8 @@ final class PhotosPresenter extends OpenVKPresenter
if($_SERVER["REQUEST_METHOD"] === "POST") {
$this->assertNoCSRF();
$album->removePhoto($photo);
$album->setEdited(time());
$album->save();
$this->flash("succ", "Фотография удалена", "Эта фотография была успешно удалена.");
$this->redirect("/album" . $album->getPrettyId(), static::REDIRECT_TEMPORARY);

View file

@ -293,7 +293,11 @@ final class UserPresenter extends OpenVKPresenter
$this->flashFail("err", tr("error"), tr("error_upload_failed"));
}
(new Albums)->getUserAvatarAlbum($this->user->identity)->addPhoto($photo);
$album = (new Albums)->getUserAvatarAlbum($this->user->identity);
$album->addPhoto($photo);
$album->setEdited(time());
$album->save();
$this->flashFail("succ", tr("photo_saved"), tr("photo_saved_comment"));
}

View file

@ -59,6 +59,6 @@
{block description}
<span>{$x->getDescription() ?? $x->getName()}</span><br />
<span style="color: grey;">{$x->getPhotosCount()} фотографий</span><br />
<span style="color: grey;">Обновлен {$x->getEditTime() ?? $x->getCreationTime()}</span><br />
<span style="color: grey;">Создан {$x->getCreationTime()}</span><br />
<span style="color: grey;">{tr("updated_at", $x->getEditTime() ?? $x->getCreationTime())}</span><br />
<span style="color: grey;">{_created} {$x->getCreationTime()}</span><br />
{/block}