mirror of
https://github.com/standardebooks/web.git
synced 2025-07-07 15:20:32 -04:00
Allow PATCHing of artwork ebook URL to empty string
This commit is contained in:
parent
69dc4580ed
commit
6ff60d8d96
1 changed files with 16 additions and 12 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue