mirror of
https://github.com/openvk/openvk
synced 2025-01-09 09:19:43 +03:00
parent
c10b8274a6
commit
413e2ac6f0
2 changed files with 10 additions and 6 deletions
|
@ -70,9 +70,9 @@ final class PhotosPresenter extends OpenVKPresenter
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_SERVER["REQUEST_METHOD"] === "POST") {
|
if($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||||
if(empty($this->postParam("name"))) {
|
if(empty($this->postParam("name")))
|
||||||
$this->flashFail("err", tr("error"), tr("error_segmentation"));
|
$this->flashFail("err", tr("error"), tr("error_segmentation"));
|
||||||
}
|
|
||||||
$album = new Album;
|
$album = new Album;
|
||||||
$album->setOwner(isset($club) ? $club->getId() * -1 : $this->user->id);
|
$album->setOwner(isset($club) ? $club->getId() * -1 : $this->user->id);
|
||||||
$album->setName($this->postParam("name"));
|
$album->setName($this->postParam("name"));
|
||||||
|
@ -80,7 +80,10 @@ final class PhotosPresenter extends OpenVKPresenter
|
||||||
$album->setCreated(time());
|
$album->setCreated(time());
|
||||||
$album->save();
|
$album->save();
|
||||||
|
|
||||||
$this->redirect("/album" . $album->getOwner()->getId() . "_" . $album->getId(), static::REDIRECT_TEMPORARY);
|
if(isset($club))
|
||||||
|
$this->redirect("/album-" . $album->getOwner()->getId() . "_" . $album->getId(), static::REDIRECT_TEMPORARY);
|
||||||
|
else
|
||||||
|
$this->redirect("/album" . $album->getOwner()->getId() . "_" . $album->getId(), static::REDIRECT_TEMPORARY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,10 +121,11 @@ final class PhotosPresenter extends OpenVKPresenter
|
||||||
if(is_null($this->user) || !$album->canBeModifiedBy($this->user->identity))
|
if(is_null($this->user) || !$album->canBeModifiedBy($this->user->identity))
|
||||||
$this->flashFail("err", "Ошибка доступа", "Недостаточно прав для модификации данного ресурса.");
|
$this->flashFail("err", "Ошибка доступа", "Недостаточно прав для модификации данного ресурса.");
|
||||||
|
|
||||||
$name = $album->getName();
|
$name = $album->getName();
|
||||||
|
$owner = $album->getOwner();
|
||||||
$album->delete();
|
$album->delete();
|
||||||
$this->flash("succ", "Альбом удалён", "Альбом $name был успешно удалён.");
|
$this->flash("succ", "Альбом удалён", "Альбом $name был успешно удалён.");
|
||||||
$this->redirect("/albums" . $this->user->id);
|
$this->redirect("/albums" . ($owner instanceof Club ? "-" : "") . $owner->getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderAlbum(int $owner, int $id): void
|
function renderAlbum(int $owner, int $id): void
|
||||||
|
|
|
@ -39,6 +39,6 @@
|
||||||
</form>
|
</form>
|
||||||
<hr/>
|
<hr/>
|
||||||
<center>
|
<center>
|
||||||
{_"you_can_also"} <a href="/album{$album->getOwner()->getId()}_{$album->getId()}/delete?hash={rawurlencode($csrfToken)}">{_"delete_album"}</a>.
|
{_"you_can_also"} <a href="/album{$album->getOwner() instanceof openvk\Web\Models\Entities\Club ? '-' : ''}{$album->getOwner()->getId()}_{$album->getId()}/delete.pl?hash={rawurlencode($csrfToken)}">{_"delete_album"}</a>.
|
||||||
</center>
|
</center>
|
||||||
{/block}
|
{/block}
|
||||||
|
|
Loading…
Reference in a new issue