web/www/admin/artworks/post.php
Mike Colagrosso 6a5c05511a Add cover art database
Co-authored-by: Job Curtis <job.curtis@gmail.com>
Co-authored-by: Alex Cabal <alex@standardebooks.org>
2024-01-03 19:14:04 -06:00

45 lines
1.1 KiB
PHP

<?
try{
session_start();
if(HttpInput::RequestMethod() != HTTP_PATCH){
throw new Exceptions\InvalidRequestException();
}
if($GLOBALS['User'] === null){
throw new Exceptions\LoginRequiredException();
}
if(!$GLOBALS['User']->Benefits->CanReviewArtwork){
throw new Exceptions\InvalidPermissionsException();
}
$artwork = Artwork::Get(HttpInput::Int(GET, 'artworkid'));
$artwork->Status = HttpInput::Str(POST, 'status', false);
$artwork->ReviewerUserId = $GLOBALS['User']->UserId;
$artwork->Save();
$_SESSION['artwork-id'] = $artwork->ArtworkId;
$_SESSION['status'] = $artwork->Status;
http_response_code(303);
header('Location: /admin/artworks');
}
catch(Exceptions\InvalidRequestException){
http_response_code(405);
}
catch(Exceptions\LoginRequiredException){
Template::RedirectToLogin();
}
catch(Exceptions\InvalidPermissionsException){
Template::Emit403(); // No permissions to submit artwork
}
catch(Exceptions\ArtworkNotFoundException){
Template::Emit404();
}
catch(Exceptions\AppException $exception){
$_SESSION['exception'] = $exception;
http_response_code(303);
header('Location: /admin/artworks/' . $artwork->ArtworkId);
}