-
Notifications
You must be signed in to change notification settings - Fork 444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
currentUserAssignedRoles not accurate in submission API #10411
Comments
Reason is that in https://github.com/pkp/pkp-lib/blame/main/classes/submission/maps/Schema.php#L390 So first it finds stage assignments without stageId, and second time with stageId and its using both results. Therefore result of this is not stage specific, which I would suspect is by mistake, because currentUserAssignedRoles is created per stage. I think just deleting the first part would solve this. Additionally I would use it as excuse to sneak in the recommendOnly and canChangeMetadata booleans, since the stage assignments are already loaded there. Instead of just returning boolean. $currentUserAssignedRoles = [];
if ($currentUser) {
// Replaces StageAssignmentDAO::getBySubmissionAndUserIdAndStageId
$stageAssignments = StageAssignment::withSubmissionIds([$submission->getId()])
->withUserId($currentUser->getId() ?? 0)
->get();
foreach ($stageAssignments as $stageAssignment) {
$userGroup = $this->getUserGroup($stageAssignment->userGroupId);
if ($userGroup) {
$currentUserAssignedRoles[] = $userGroup->getRoleId();
}
}
// Replaces StageAssignmentDAO::getBySubmissionAndUserIdAndStageId
$stageAssignments = StageAssignment::withSubmissionIds([$submission->getId()])
->withUserId($currentUser->getId())
->withStageIds([$stageId])
->get();
foreach ($stageAssignments as $stageAssignment) {
$userGroup = Repo::userGroup()->get($stageAssignment->userGroupId);
$currentUserAssignedRoles[] = (int) $userGroup->getRoleId();
}
}
$stage['currentUserAssignedRoles'] = array_values(array_unique($currentUserAssignedRoles)); |
@jardakotesovec, this sounds reasonable! |
@Vitaliy-1 Before jumping on PR. I think it make sense to solve this along with the #10360 , can you provide your thought on the suggestions there? |
Closing this one in favour of #10480 |
Describe the bug
In response from API
.../api/v1/submissions/20
,there is field
currentUserAssignedRoles
, which is present in every stage (other fields deducted) as follows:In this case it telling me that for this submission I do have ROLE_ID_ASSISTANT permission on every stage. But thats not accurate as in User&Roles -> Roles settings I selected only to be assigned to Submission&Copyediting stage.
The behaviour is same in 3.4, but I don't think its impactful - as 3.4 listing cares about assignment to any stage - https://github.com/pkp/ui-library/blob/main/src/components/ListPanel/submissions/SubmissionsListItem.vue#L574, not individual ones.
But for 3.5 I would like to use this information to decide which stages user has access to, similarly like we do in 3.4
What application are you using?
OJS, OMP or OPS version 3.4, 3.5
The text was updated successfully, but these errors were encountered: