diff --git a/api/v1/submissions/PKPSubmissionController.php b/api/v1/submissions/PKPSubmissionController.php index 132e8800c11..10d4af46a9d 100644 --- a/api/v1/submissions/PKPSubmissionController.php +++ b/api/v1/submissions/PKPSubmissionController.php @@ -56,6 +56,8 @@ use PKP\submission\PKPSubmission; use PKP\submission\reviewAssignment\ReviewAssignment; use PKP\userGroup\UserGroup; +use PKP\observers\events\MetadataChanged; + class PKPSubmissionController extends PKPBaseController { @@ -1100,13 +1102,6 @@ public function editPublication(Request $illuminateRequest): JsonResponse ], Response::HTTP_FORBIDDEN); } - // Publications can not be edited when they are published - if ($publication->getData('status') === PKPSubmission::STATUS_PUBLISHED) { - return response()->json([ - 'error' => __('api.publication.403.cantEditPublished'), - ], Response::HTTP_FORBIDDEN); - } - // Prevent users from editing publications if they do not have permission. Except for admins. $userRoles = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_USER_ROLES); if (!in_array(Role::ROLE_ID_SITE_ADMIN, $userRoles) && !Repo::submission()->canEditPublication($submission->getId(), $currentUser->getId())) { @@ -1139,6 +1134,8 @@ public function editPublication(Request $illuminateRequest): JsonResponse Repo::publication()->edit($publication, $params); $publication = Repo::publication()->get($publication->getId()); + event(new MetadataChanged($submission)); + $userGroups = Repo::userGroup()->getCollector() ->filterByContextIds([$submission->getData('contextId')]) @@ -1400,13 +1397,6 @@ public function addContributor(Request $illuminateRequest): JsonResponse ], Response::HTTP_FORBIDDEN); } - // Publications can not be edited when they are published - if ($publication->getData('status') === PKPSubmission::STATUS_PUBLISHED) { - return response()->json([ - 'error' => __('api.publication.403.cantEditPublished'), - ], Response::HTTP_FORBIDDEN); - } - $params = $this->convertStringsToSchema(PKPSchemaService::SCHEMA_AUTHOR, $illuminateRequest->input()); $params['publicationId'] = $publication->getId(); @@ -1449,12 +1439,6 @@ public function deleteContributor(Request $illuminateRequest): JsonResponse ], Response::HTTP_NOT_FOUND); } - // Publications can not be edited when they are published - if ($publication->getData('status') === PKPSubmission::STATUS_PUBLISHED) { - return response()->json([ - 'error' => __('api.publication.403.cantEditPublished'), - ], Response::HTTP_FORBIDDEN); - } if ($submission->getId() !== $publication->getData('submissionId')) { return response()->json([ @@ -1511,13 +1495,6 @@ public function editContributor(Request $illuminateRequest): JsonResponse ], Response::HTTP_FORBIDDEN); } - // Publications can not be edited when they are published - if ($publication->getData('status') === PKPSubmission::STATUS_PUBLISHED) { - return response()->json([ - 'error' => __('api.publication.403.cantEditPublished'), - ], Response::HTTP_FORBIDDEN); - } - $params = $this->convertStringsToSchema(PKPSchemaService::SCHEMA_AUTHOR, $illuminateRequest->input()); $params['id'] = $author->getId(); @@ -1580,13 +1557,6 @@ public function saveContributorsOrder(Request $illuminateRequest): JsonResponse ], Response::HTTP_FORBIDDEN); } - // Publications can not be edited when they are published - if ($publication->getData('status') === PKPSubmission::STATUS_PUBLISHED) { - return response()->json([ - 'error' => __('api.publication.403.cantEditPublished'), - ], Response::HTTP_FORBIDDEN); - } - if (!empty($params['sortedAuthors'])) { $authors = []; foreach ($params['sortedAuthors'] as $author) { diff --git a/classes/task/PublishSubmissions.php b/classes/task/PublishSubmissions.php index f392794463b..716dbb0660a 100644 --- a/classes/task/PublishSubmissions.php +++ b/classes/task/PublishSubmissions.php @@ -20,6 +20,8 @@ use APP\submission\Submission; use PKP\core\Core; use PKP\scheduledTask\ScheduledTask; +use PKP\observers\events\MetadataChanged; + class PublishSubmissions extends ScheduledTask { @@ -50,6 +52,9 @@ public function executeActions(): bool $datePublished = $submission->getCurrentPublication()->getData('datePublished'); if ($datePublished && strtotime($datePublished) <= strtotime(Core::getCurrentDate())) { Repo::publication()->publish($submission->getCurrentPublication()); + + // dispatch the MetadataChanged event after publishing + event(new MetadataChanged($submission)); } } }