chg: [instance:searchAll] Sharinggroup filter on org membership in addition to owner
parent
bc04fd0336
commit
ad6362eed4
|
@ -35,14 +35,23 @@ class InstanceTable extends AppTable
|
|||
'Individuals' => ['conditions' => false, 'afterFind' => false],
|
||||
'Organisations' => ['conditions' => false, 'afterFind' => false],
|
||||
'SharingGroups' => [
|
||||
'conditions' => function($user) {
|
||||
$conditions = [];
|
||||
if (empty($user['role']['perm_admin'])) {
|
||||
$conditions['SharingGroups.organisation_id'] = $user['organisation_id'];
|
||||
}
|
||||
return $conditions;
|
||||
},
|
||||
'conditions' => false,
|
||||
'afterFind' => function($result, $user) {
|
||||
foreach ($result as $i => $row) {
|
||||
if (empty($user['role']['perm_admin'])) {
|
||||
$orgFound = false;
|
||||
if (!empty($row['sharing_group_orgs'])) {
|
||||
foreach ($row['sharing_group_orgs'] as $org) {
|
||||
if ($org['id'] === $user['organisation_id']) {
|
||||
$orgFound = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($row['organisation_id'] !== $user['organisation_id'] && !$orgFound) {
|
||||
unset($result[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
},
|
||||
],
|
||||
|
|
Loading…
Reference in New Issue