From 6ff60d8d9608b87d7316cb9623c3072d51213c20 Mon Sep 17 00:00:00 2001 From: Alex Cabal Date: Mon, 29 Jan 2024 18:27:56 -0600 Subject: [PATCH] Allow PATCHing of artwork ebook URL to empty string --- www/artworks/post.php | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/www/artworks/post.php b/www/artworks/post.php index 0f449fed..90a1262d 100644 --- a/www/artworks/post.php +++ b/www/artworks/post.php @@ -110,24 +110,28 @@ try{ $exceptionRedirectUrl = $artwork->Url; // We can PATCH the status, the ebook www filesystem path, or both. + if(isset($_POST['artwork-status'])){ + $newStatus = ArtworkStatus::tryFrom(HttpInput::Str(POST, 'artwork-status') ?? ''); + if($newStatus !== null){ + if($artwork->Status != $newStatus && !$artwork->CanStatusBeChangedBy($GLOBALS['User'])){ + throw new Exceptions\InvalidPermissionsException(); + } - $newStatus = ArtworkStatus::tryFrom(HttpInput::Str(POST, 'artwork-status') ?? ''); - if($newStatus !== null){ - if($artwork->Status != $newStatus && !$artwork->CanStatusBeChangedBy($GLOBALS['User'])){ + $artwork->ReviewerUserId = $GLOBALS['User']->UserId; + } + + $artwork->Status = $newStatus; + } + + if(isset($_POST['artwork-ebook-url'])){ + $newEbookUrl = HttpInput::Str(POST, 'artwork-ebook-url'); + if($artwork->EbookUrl != $newEbookUrl && !$artwork->CanEbookUrlBeChangedBy($GLOBALS['User'])){ throw new Exceptions\InvalidPermissionsException(); } - $artwork->ReviewerUserId = $GLOBALS['User']->UserId; + $artwork->EbookUrl = $newEbookUrl; } - $newEbookUrl = HttpInput::Str(POST, 'artwork-ebook-url') ?? null; - if($artwork->EbookUrl != $newEbookUrl && !$artwork->CanEbookUrlBeChangedBy($GLOBALS['User'])){ - throw new Exceptions\InvalidPermissionsException(); - } - - $artwork->Status = $newStatus ?? $artwork->Status; - $artwork->EbookUrl = $newEbookUrl ?? $artwork->EbookUrl; - $artwork->Save(); $_SESSION['artwork'] = $artwork;