new: [administration] allow group/org admins to edit individuals aligned to their managed orgs

- based on alignment
develop
iglocska 2024-08-22 15:22:58 +02:00
parent 64ba8e4955
commit db8ec4499b
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
1 changed files with 16 additions and 1 deletions

View File

@ -143,12 +143,27 @@ class IndividualsTable extends AppTable
]; ];
if ($isGroupAdmin) { if ($isGroupAdmin) {
$OrgGroups = \Cake\ORM\TableRegistry::getTableLocator()->get('OrgGroups'); $OrgGroups = \Cake\ORM\TableRegistry::getTableLocator()->get('OrgGroups');
$conditions['organisation_id IN'] = $OrgGroups->getGroupOrgIdsForUser($currentUser); $orgGroupIds = $OrgGroups->getGroupOrgIdsForUser($currentUser);
$conditions['organisation_id IN'] = $orgGroupIds;
} else { } else {
$conditions['organisation_id'] = $currentUser['organisation_id']; $conditions['organisation_id'] = $currentUser['organisation_id'];
} }
} }
$validIndividualIds = $this->Users->find()->select(['individual_id'])->where($conditions)->all()->extract('individual_id')->toArray(); $validIndividualIds = $this->Users->find()->select(['individual_id'])->where($conditions)->all()->extract('individual_id')->toArray();
if (!$isCommunityAdmin) {
$conditions = [];
if ($isGroupAdmin) {
$conditions = ['organisation_id IN' => $orgGroupIds];
} else {
$conditions['organisation_id'] = $currentUser['organisation_id'];
}
$alignmentBasedIndividualIds = $this->Alignments->find('list', [
'keyField' => 'id',
'valueField' => 'individual_id'
])->where($conditions)->all()->toList();
$validIndividualIds = array_merge($validIndividualIds, $alignmentBasedIndividualIds);
$validIndividualIds = array_unique($validIndividualIds);
}
return $validIndividualIds; return $validIndividualIds;
} }