|
71 | 71 | use PKP\submission\reviewAssignment\ReviewAssignment;
|
72 | 72 | use PKP\submissionFile\SubmissionFile;
|
73 | 73 | use PKP\userGroup\UserGroup;
|
| 74 | +use PKP\observers\events\MetadataChanged; |
| 75 | +use PKP\stageAssignment\StageAssignment; |
| 76 | + |
74 | 77 |
|
75 | 78 | class PKPSubmissionController extends PKPBaseController
|
76 | 79 | {
|
@@ -1237,16 +1240,12 @@ public function editPublication(Request $illuminateRequest): JsonResponse
|
1237 | 1240 | ], Response::HTTP_FORBIDDEN);
|
1238 | 1241 | }
|
1239 | 1242 |
|
1240 |
| - // Publications can not be edited when they are published |
1241 |
| - if ($publication->getData('status') === PKPSubmission::STATUS_PUBLISHED) { |
1242 |
| - return response()->json([ |
1243 |
| - 'error' => __('api.publication.403.cantEditPublished'), |
1244 |
| - ], Response::HTTP_FORBIDDEN); |
1245 |
| - } |
1246 |
| - |
1247 |
| - // Prevent users from editing publications if they do not have permission. Except for admins. |
| 1243 | + // only proceed if user is allowed to edit publications |
1248 | 1244 | $userRoles = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_USER_ROLES);
|
1249 |
| - if (!in_array(Role::ROLE_ID_SITE_ADMIN, $userRoles) && !Repo::submission()->canEditPublication($submission->getId(), $currentUser->getId())) { |
| 1245 | + if ( |
| 1246 | + !in_array(Role::ROLE_ID_SITE_ADMIN, $userRoles) && |
| 1247 | + !Repo::submission()->canEditPublication($submission->getId(), $currentUser->getId()) |
| 1248 | + ) { |
1250 | 1249 | return response()->json([
|
1251 | 1250 | 'error' => __('api.submissions.403.userCantEdit'),
|
1252 | 1251 | ], Response::HTTP_FORBIDDEN);
|
@@ -1276,6 +1275,8 @@ public function editPublication(Request $illuminateRequest): JsonResponse
|
1276 | 1275 |
|
1277 | 1276 | Repo::publication()->edit($publication, $params);
|
1278 | 1277 | $publication = Repo::publication()->get($publication->getId());
|
| 1278 | + event(new MetadataChanged($submission)); |
| 1279 | + |
1279 | 1280 |
|
1280 | 1281 | $userGroups = UserGroup::withContextIds($submission->getData('contextId'))->cursor();
|
1281 | 1282 |
|
@@ -1335,6 +1336,17 @@ public function publishPublication(Request $illuminateRequest): JsonResponse
|
1335 | 1336 |
|
1336 | 1337 | Repo::publication()->publish($publication);
|
1337 | 1338 |
|
| 1339 | + $stageAssignments = StageAssignment::withSubmissionIds([$submission->getId()]) |
| 1340 | + ->get(); |
| 1341 | + |
| 1342 | + foreach ($stageAssignments as $stageAssignment) { |
| 1343 | + $userGroup = $stageAssignment->userGroup; |
| 1344 | + if ($userGroup->getRoleId() === Role::ROLE_ID_AUTHOR) { |
| 1345 | + $stageAssignment->canChangeMetadata = 0; |
| 1346 | + $stageAssignment->save(); |
| 1347 | + } |
| 1348 | + } |
| 1349 | + |
1338 | 1350 | $publication = Repo::publication()->get($publication->getId());
|
1339 | 1351 |
|
1340 | 1352 | $userGroups = UserGroup::withContextIds($submission->getData('contextId'))->cursor();
|
@@ -1531,13 +1543,6 @@ public function addContributor(Request $illuminateRequest): JsonResponse
|
1531 | 1543 | ], Response::HTTP_FORBIDDEN);
|
1532 | 1544 | }
|
1533 | 1545 |
|
1534 |
| - // Publications can not be edited when they are published |
1535 |
| - if ($publication->getData('status') === PKPSubmission::STATUS_PUBLISHED) { |
1536 |
| - return response()->json([ |
1537 |
| - 'error' => __('api.publication.403.cantEditPublished'), |
1538 |
| - ], Response::HTTP_FORBIDDEN); |
1539 |
| - } |
1540 |
| - |
1541 | 1546 | $params = $this->convertStringsToSchema(PKPSchemaService::SCHEMA_AUTHOR, $illuminateRequest->input());
|
1542 | 1547 | $params['publicationId'] = $publication->getId();
|
1543 | 1548 |
|
@@ -1603,12 +1608,6 @@ public function deleteContributor(Request $illuminateRequest): JsonResponse
|
1603 | 1608 | ], Response::HTTP_NOT_FOUND);
|
1604 | 1609 | }
|
1605 | 1610 |
|
1606 |
| - // Publications can not be edited when they are published |
1607 |
| - if ($publication->getData('status') === PKPSubmission::STATUS_PUBLISHED) { |
1608 |
| - return response()->json([ |
1609 |
| - 'error' => __('api.publication.403.cantEditPublished'), |
1610 |
| - ], Response::HTTP_FORBIDDEN); |
1611 |
| - } |
1612 | 1611 |
|
1613 | 1612 | if ($submission->getId() !== $publication->getData('submissionId')) {
|
1614 | 1613 | return response()->json([
|
@@ -1665,13 +1664,6 @@ public function editContributor(Request $illuminateRequest): JsonResponse
|
1665 | 1664 | ], Response::HTTP_FORBIDDEN);
|
1666 | 1665 | }
|
1667 | 1666 |
|
1668 |
| - // Publications can not be edited when they are published |
1669 |
| - if ($publication->getData('status') === PKPSubmission::STATUS_PUBLISHED) { |
1670 |
| - return response()->json([ |
1671 |
| - 'error' => __('api.publication.403.cantEditPublished'), |
1672 |
| - ], Response::HTTP_FORBIDDEN); |
1673 |
| - } |
1674 |
| - |
1675 | 1667 | $params = $this->convertStringsToSchema(PKPSchemaService::SCHEMA_AUTHOR, $illuminateRequest->input());
|
1676 | 1668 | $params['id'] = $author->getId();
|
1677 | 1669 |
|
@@ -1758,13 +1750,6 @@ public function saveContributorsOrder(Request $illuminateRequest): JsonResponse
|
1758 | 1750 | ], Response::HTTP_FORBIDDEN);
|
1759 | 1751 | }
|
1760 | 1752 |
|
1761 |
| - // Publications can not be edited when they are published |
1762 |
| - if ($publication->getData('status') === PKPSubmission::STATUS_PUBLISHED) { |
1763 |
| - return response()->json([ |
1764 |
| - 'error' => __('api.publication.403.cantEditPublished'), |
1765 |
| - ], Response::HTTP_FORBIDDEN); |
1766 |
| - } |
1767 |
| - |
1768 | 1753 | if (!empty($params['sortedAuthors'])) {
|
1769 | 1754 | $authors = [];
|
1770 | 1755 | foreach ($params['sortedAuthors'] as $author) {
|
|
0 commit comments