Use the artwork from the session when editing

This commit is contained in:
Mike Colagrosso 2024-01-16 21:15:34 -07:00 committed by Alex Cabal
parent 4b2e02950f
commit c80e99a71a

View file

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