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();