Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions api/v1/submissions/PKPSubmissionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,8 @@ public function getGroupRoutes(): void
});

Route::post('', $this->add(...))
->name('submission.add')
->middleware([
self::roleAuthorizer(Role::getAllRoles()),
]);
}
->name('submission.add');
}

/**
* @copydoc \PKP\core\PKPBaseController::authorize()
Expand All @@ -362,7 +359,13 @@ public function authorize(PKPRequest $request, array &$args, array $roleAssignme

$this->addPolicy(new UserRolesRequiredPolicy($request), true);

$this->addPolicy(new ContextAccessPolicy($request, $roleAssignments));
if($actionName === 'add') {
// For 'add' endpoint, mark role assignments as checked since the add() method
// will automatically assign the AUTHOR role to users without roles
$this->markRoleAssignmentsChecked();
} else {
$this->addPolicy(new ContextAccessPolicy($request, $roleAssignments));
}

if (in_array($actionName, $this->requiresSubmissionAccess)) {
$this->addPolicy(new SubmissionAccessPolicy($request, $args, $roleAssignments));
Expand Down Expand Up @@ -604,12 +607,20 @@ public function add(Request $illuminateRequest): JsonResponse
}
}
}
$submitterUserGroups = UserGroup::withContextIds($context->getId())
$submitterUserGroupsQuery = UserGroup::withContextIds($context->getId())
->withRoleIds([Role::ROLE_ID_MANAGER, Role::ROLE_ID_AUTHOR])
->whereHas('userUserGroups', function ($query) use ($user) {
$query->withUserId($user->getId());
})
->get();
$query->withUserId($user->getId())->withActive();
});

// For OJS and OMP, also filter by submission stage assignment
// to differentiate between Journal managers, who are not assigned to Submission Stage
// (production editor, journal manager)
if (Application::get()->getName() !== 'ops') {
$submitterUserGroupsQuery->withStageIds([WORKFLOW_STAGE_ID_SUBMISSION]);
}

$submitterUserGroups = $submitterUserGroupsQuery->get();


$userGroupIdPropName = 'userGroupId';
Expand Down
8 changes: 3 additions & 5 deletions pages/submission/PKPSubmissionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -620,17 +620,15 @@ protected function getSubmitUserGroups(Context $context, User $user): Collection
$userGroups = $isAdmin
? $query->withRoleIds([Role::ROLE_ID_MANAGER, Role::ROLE_ID_SITE_ADMIN])->get()
: $query->withStageIds([WORKFLOW_STAGE_ID_SUBMISSION])
->withUserUserGroupStatus(UserUserGroupStatus::STATUS_ACTIVE->value)
->whereHas('userUserGroups', function ($query) use ($user) {
$query->withUserId($user->getId())->withActive();
})
->get(); // For non-admin users, query for the groups tht give them access to the submission stage

// Users without a submitting role or access to submission stage can submit as an
// author role that allows self registration.
// They are also assigned the author role
if ($userGroups->isEmpty()) {
Repo::userGroup()->assignUserToGroup(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, if the code already assigned the author permission in the API, why this part was added here? Is it just a permission aspect to the submission wizard?

Copy link
Contributor Author

@jardakotesovec jardakotesovec Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding how things evolved is that originally (3.3, 3.4) we added Author role when the 'Add' api endpoints was hit. But than this issue came about #10929 , where the issue was with our favourite production editor, which is used only be @Tribunal33 :-D. And that was fixed here (loading create submission page) instead of in the original place.

So we have two places where author role is added in 3.5. This PR is trying to adjust it so its again just in one place, but it handles also production editor and also making it work for users who don't have any role.

$user->getId(),
Repo::userGroup()->getByRoleIds([Role::ROLE_ID_AUTHOR], $context->getId())->first()->id
);
$defaultUserGroup = UserGroup::withContextIds([$context->getId()])
->withRoleIds([Role::ROLE_ID_AUTHOR])
->permitSelfRegistration(true)
Expand Down