From ce4a28c6750ffc6d301cf6ad055e0438cc88b4c4 Mon Sep 17 00:00:00 2001 From: Mike Colagrosso Date: Mon, 15 Jan 2024 17:14:37 -0700 Subject: [PATCH] Add a common template for Artwork creation and editing to share --- templates/ArtworkCreateEditFields.php | 202 ++++++++++++++++++++++++++ www/artworks/edit.php | 73 ++++++++++ www/artworks/get.php | 4 +- www/artworks/new.php | 202 +------------------------- 4 files changed, 284 insertions(+), 197 deletions(-) create mode 100644 templates/ArtworkCreateEditFields.php create mode 100644 www/artworks/edit.php diff --git a/templates/ArtworkCreateEditFields.php b/templates/ArtworkCreateEditFields.php new file mode 100644 index 00000000..9c0de8c0 --- /dev/null +++ b/templates/ArtworkCreateEditFields.php @@ -0,0 +1,202 @@ + +
+ Artist details + + +
+
+ Artwork details + +
+ + +
+ + +
+
+ Proof of U.S. public domain status +

See the US-PD clearance section of the SEMoS for details on this section.

+

PD proof must take the form of either:

+
+ +
+

or proof that the artwork was reproduced in a book published before , including the following:

+
+ + + + + +
+

or a reason for a special exception:

+
+ +
+
+
+ Other details + +
+ +
+ Editor options + Benefits->CanReviewOwnArtwork){ ?> + + + +
+ + diff --git a/www/artworks/edit.php b/www/artworks/edit.php new file mode 100644 index 00000000..7b1f3d70 --- /dev/null +++ b/www/artworks/edit.php @@ -0,0 +1,73 @@ +Status == ArtworkStatus::Unverified) && ($GLOBALS['User']->Benefits->CanReviewArtwork || ($artwork->SubmitterUserId == $GLOBALS['User']->UserId)); + if(!$isEditingAllowed){ + throw new Exceptions\InvalidPermissionsException(); + } + + $isAdminView = $GLOBALS['User']->Benefits->CanReviewArtwork ?? false; + + // We got here because an artwork update had errors and the user has to try again + if($exception){ + http_response_code(422); + session_unset(); + } +} +catch(Exceptions\ArtworkNotFoundException){ + Template::Emit404(); +} +catch(Exceptions\LoginRequiredException){ + Template::RedirectToLogin(); +} +catch(Exceptions\InvalidPermissionsException){ + Template::Emit403(); // No permissions to submit artwork +} + +?> + 'Edit Artwork', + 'artwork' => true, + 'highlight' => '', + 'description' => 'Edit public domain artwork to the database for use as cover art.' + ] +) ?> +
+
+

Edit Artwork

+ + $exception]) ?> + + + + + + + + +
+ + + $artwork, + 'imageRequired' => false, + 'isAdminView' => $isAdminView + ] + ) ?> +
+
+
+ diff --git a/www/artworks/get.php b/www/artworks/get.php index bf5395e1..d8479d83 100644 --- a/www/artworks/get.php +++ b/www/artworks/get.php @@ -12,8 +12,8 @@ try{ $userId = $GLOBALS['User']->UserId ?? null; $isEditingAllowed = ($artwork->Status == ArtworkStatus::Unverified) && ($isAdminView || ($userId !== null && $userId == $artwork->SubmitterUserId)); - // If the artwork is not approved, and we're not an admin, don't show it. - if($artwork->Status != ArtworkStatus::Approved && $artwork->Status != ArtworkStatus::InUse && !$isAdminView){ + // If the artwork is not approved, and we're not an admin or the submitter when they can edit, don't show it. + if($artwork->Status != ArtworkStatus::Approved && $artwork->Status != ArtworkStatus::InUse && !$isAdminView && !$isEditingAllowed){ throw new Exceptions\ArtworkNotFoundException(); } diff --git a/www/artworks/new.php b/www/artworks/new.php index 4b1990cd..21250f44 100644 --- a/www/artworks/new.php +++ b/www/artworks/new.php @@ -1,5 +1,4 @@
-
- Artist details - - -
-
- Artwork details - -
- - -
- - -
-
- Proof of U.S. public domain status -

See the US-PD clearance section of the SEMoS for details on this section.

-

PD proof must take the form of either:

-
- -
-

or proof that the artwork was reproduced in a book published before , including the following:

-
- - - - - -
-

or a reason for a special exception:

-
- -
-
-
- Other details - -
- -
- Editor options - Benefits->CanReviewOwnArtwork){ ?> - - - -
- - + $artwork, + 'imageRequired' => true, + 'isAdminView' => $isAdminView + ] + ) ?>