Skip to content

Commit d1b8c15

Browse files
committed
pkp#10263 Relax editing metadata on published/posted materials
1 parent a3d060c commit d1b8c15

File tree

2 files changed

+9
-34
lines changed

2 files changed

+9
-34
lines changed

api/v1/submissions/PKPSubmissionController.php

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
use PKP\submission\PKPSubmission;
5757
use PKP\submission\reviewAssignment\ReviewAssignment;
5858
use PKP\userGroup\UserGroup;
59+
use PKP\observers\events\MetadataChanged;
60+
5961

6062
class PKPSubmissionController extends PKPBaseController
6163
{
@@ -1100,13 +1102,6 @@ public function editPublication(Request $illuminateRequest): JsonResponse
11001102
], Response::HTTP_FORBIDDEN);
11011103
}
11021104

1103-
// Publications can not be edited when they are published
1104-
if ($publication->getData('status') === PKPSubmission::STATUS_PUBLISHED) {
1105-
return response()->json([
1106-
'error' => __('api.publication.403.cantEditPublished'),
1107-
], Response::HTTP_FORBIDDEN);
1108-
}
1109-
11101105
// Prevent users from editing publications if they do not have permission. Except for admins.
11111106
$userRoles = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_USER_ROLES);
11121107
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
11391134

11401135
Repo::publication()->edit($publication, $params);
11411136
$publication = Repo::publication()->get($publication->getId());
1137+
event(new MetadataChanged($submission));
1138+
11421139

11431140
$userGroups = Repo::userGroup()->getCollector()
11441141
->filterByContextIds([$submission->getData('contextId')])
@@ -1400,13 +1397,6 @@ public function addContributor(Request $illuminateRequest): JsonResponse
14001397
], Response::HTTP_FORBIDDEN);
14011398
}
14021399

1403-
// Publications can not be edited when they are published
1404-
if ($publication->getData('status') === PKPSubmission::STATUS_PUBLISHED) {
1405-
return response()->json([
1406-
'error' => __('api.publication.403.cantEditPublished'),
1407-
], Response::HTTP_FORBIDDEN);
1408-
}
1409-
14101400
$params = $this->convertStringsToSchema(PKPSchemaService::SCHEMA_AUTHOR, $illuminateRequest->input());
14111401
$params['publicationId'] = $publication->getId();
14121402

@@ -1449,12 +1439,6 @@ public function deleteContributor(Request $illuminateRequest): JsonResponse
14491439
], Response::HTTP_NOT_FOUND);
14501440
}
14511441

1452-
// Publications can not be edited when they are published
1453-
if ($publication->getData('status') === PKPSubmission::STATUS_PUBLISHED) {
1454-
return response()->json([
1455-
'error' => __('api.publication.403.cantEditPublished'),
1456-
], Response::HTTP_FORBIDDEN);
1457-
}
14581442

14591443
if ($submission->getId() !== $publication->getData('submissionId')) {
14601444
return response()->json([
@@ -1511,13 +1495,6 @@ public function editContributor(Request $illuminateRequest): JsonResponse
15111495
], Response::HTTP_FORBIDDEN);
15121496
}
15131497

1514-
// Publications can not be edited when they are published
1515-
if ($publication->getData('status') === PKPSubmission::STATUS_PUBLISHED) {
1516-
return response()->json([
1517-
'error' => __('api.publication.403.cantEditPublished'),
1518-
], Response::HTTP_FORBIDDEN);
1519-
}
1520-
15211498
$params = $this->convertStringsToSchema(PKPSchemaService::SCHEMA_AUTHOR, $illuminateRequest->input());
15221499
$params['id'] = $author->getId();
15231500

@@ -1580,13 +1557,6 @@ public function saveContributorsOrder(Request $illuminateRequest): JsonResponse
15801557
], Response::HTTP_FORBIDDEN);
15811558
}
15821559

1583-
// Publications can not be edited when they are published
1584-
if ($publication->getData('status') === PKPSubmission::STATUS_PUBLISHED) {
1585-
return response()->json([
1586-
'error' => __('api.publication.403.cantEditPublished'),
1587-
], Response::HTTP_FORBIDDEN);
1588-
}
1589-
15901560
if (!empty($params['sortedAuthors'])) {
15911561
$authors = [];
15921562
foreach ($params['sortedAuthors'] as $author) {

classes/task/PublishSubmissions.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
use APP\submission\Submission;
2121
use PKP\core\Core;
2222
use PKP\scheduledTask\ScheduledTask;
23+
use PKP\observers\events\MetadataChanged;
24+
2325

2426
class PublishSubmissions extends ScheduledTask
2527
{
@@ -50,6 +52,9 @@ public function executeActions(): bool
5052
$datePublished = $submission->getCurrentPublication()->getData('datePublished');
5153
if ($datePublished && strtotime($datePublished) <= strtotime(Core::getCurrentDate())) {
5254
Repo::publication()->publish($submission->getCurrentPublication());
55+
56+
// dispatch the MetadataChanged event after publishing
57+
event(new MetadataChanged($submission));
5358
}
5459
}
5560
}

0 commit comments

Comments
 (0)