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

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

View file

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

View file

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