@@ -664,8 +664,37 @@ public function add(Request $illuminateRequest): JsonResponse
664
664
: $ submitAsUserGroup ->permitMetadataEdit
665
665
);
666
666
667
+ // Production Editor group has Managerial role but is not assigned to submission stage.
668
+ $ isManager = $ submitAsUserGroup ->roleId === Role::ROLE_ID_MANAGER && !$ request ->getUser ()->hasRole ([Role::ROLE_ID_SITE_ADMIN ], \PKP \core \PKPApplication::SITE_CONTEXT_ID );
669
+ $ stagesAssignedToGroup = $ isManager ? Repo::userGroup ()->getAssignedStagesByUserGroupId ($ context ->getId (), $ submitAsUserGroup ->id ) : collect ();
670
+ $ isSubmittingAsProductionEditor = $ isManager && !$ stagesAssignedToGroup ->contains (WORKFLOW_STAGE_ID_SUBMISSION );
671
+ // Temporary solution for https://github.com/pkp/pkp-lib/issues/10929
672
+ // If submitting as Production Editor, then also assign as Author to allow full access to submission stage
673
+ if ($ isSubmittingAsProductionEditor ) {
674
+ $ authorGroup = Repo::userGroup ()->getByRoleIds ([Role::ROLE_ID_AUTHOR ], $ context ->getId ())->first ();
675
+
676
+ // Assign author role to user if not already assigned
677
+ if (!$ submitterUserGroups ->contains ('roleId ' , Role::ROLE_ID_AUTHOR )) {
678
+ Repo::userGroup ()->assignUserToGroup (
679
+ $ user ->getId (),
680
+ $ authorGroup ->id
681
+ );
682
+ }
683
+
684
+ // Assign Production Editor to submission as an Author to allow access to submission stage operations
685
+ Repo::stageAssignment ()
686
+ ->build (
687
+ $ submission ->getId (),
688
+ $ authorGroup ->id ,
689
+ $ request ->getUser ()->getId (),
690
+ $ authorGroup ->recommendOnly ,
691
+ // Authors can always edit metadata before submitting
692
+ true
693
+ );
694
+ }
695
+
667
696
// Create an author record from the submitter's user account
668
- if ($ submitAsUserGroup ->roleId === Role::ROLE_ID_AUTHOR ) {
697
+ if ($ submitAsUserGroup ->roleId === Role::ROLE_ID_AUTHOR || $ isSubmittingAsProductionEditor ) {
669
698
$ author = Repo::author ()->newAuthorFromUser ($ request ->getUser (), $ submission , $ context );
670
699
$ author ->setData ('publicationId ' , $ publication ->getId ());
671
700
$ author ->setUserGroupId ($ submitAsUserGroup ->id );
0 commit comments