From c80e99a71aa676e9ce30011b2a72991d737e4b9f Mon Sep 17 00:00:00 2001 From: Mike Colagrosso Date: Tue, 16 Jan 2024 21:15:34 -0700 Subject: [PATCH] Use the artwork from the session when editing --- www/artworks/edit.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/www/artworks/edit.php b/www/artworks/edit.php index 7b1f3d70..b3312709 100644 --- a/www/artworks/edit.php +++ b/www/artworks/edit.php @@ -4,14 +4,18 @@ use function Safe\session_unset; session_start(); $exception = $_SESSION['exception'] ?? null; +/** @var Artwork $artwork */ +$artwork = $_SESSION['artwork'] ?? null; try{ - $artwork = Artwork::GetByUrl(HttpInput::Str(GET, 'artist-url-name') ?? '', HttpInput::Str(GET, 'artwork-url-name') ?? ''); - if($GLOBALS['User'] === null){ throw new Exceptions\LoginRequiredException(); } + if($artwork === null){ + $artwork = Artwork::GetByUrl(HttpInput::Str(GET, 'artist-url-name') ?? '', HttpInput::Str(GET, 'artwork-url-name') ?? ''); + } + $isEditingAllowed = ($artwork->Status == ArtworkStatus::Unverified) && ($GLOBALS['User']->Benefits->CanReviewArtwork || ($artwork->SubmitterUserId == $GLOBALS['User']->UserId)); if(!$isEditingAllowed){ throw new Exceptions\InvalidPermissionsException();