File tree 1 file changed +19
-0
lines changed
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -514,6 +514,25 @@ public function canCurrentUserDelete(Submission $submission): bool
514
514
*/
515
515
public function canEditPublication (int $ submissionId , int $ userId ): bool
516
516
{
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
+
517
536
// Replaces StageAssignmentDAO::getBySubmissionAndUserIdAndStageId
518
537
$ stageAssignments = StageAssignment::withSubmissionIds ([$ submissionId ])
519
538
->withUserId ($ userId )
You can’t perform that action at this time.
0 commit comments