Skip to content

Commit d26aa0f

Browse files
committed
#10263 Prevent authors from editing publication metadata even if granted permission by editor
1 parent a50f6ef commit d26aa0f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

classes/submission/Repository.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,25 @@ public function canCurrentUserDelete(Submission $submission): bool
514514
*/
515515
public function canEditPublication(int $submissionId, int $userId): bool
516516
{
517+
// block authors can never edit a published publication even if an editor granted them canChangeMetadata
518+
$submission = $this->get($submissionId);
519+
if ($submission) {
520+
$currentPub = $submission->getCurrentPublication();
521+
if (
522+
$currentPub
523+
&& $currentPub->getData('status') === Submission::STATUS_PUBLISHED
524+
) {
525+
// fetch this user’s stage assignments
526+
$assignments = StageAssignment::withSubmissionIds([$submissionId])->withUserId($userId)->get();
527+
528+
// if all of their assignments are to an author group then block them
529+
$hasNonAuthor = $assignments->contains(fn($sa) => $sa->userGroup && $sa->userGroup->roleId !== Role::ROLE_ID_AUTHOR);
530+
if (!$hasNonAuthor) {
531+
return false;
532+
}
533+
}
534+
}
535+
517536
// Replaces StageAssignmentDAO::getBySubmissionAndUserIdAndStageId
518537
$stageAssignments = StageAssignment::withSubmissionIds([$submissionId])
519538
->withUserId($userId)

0 commit comments

Comments
 (0)