fix: [permissionlimitation:getLimitations] Mirror the permission limit if only one scope (global or org) is defined

pull/121/head
Sami Mokaddem 2022-12-08 15:38:04 +01:00
parent 31ce0feed8
commit 9a2e94989f
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
1 changed files with 8 additions and 0 deletions

View File

@ -45,6 +45,14 @@ class PermissionLimitationsTable extends AppTable
'limit' => $entry['max_occurrence']
];
}
foreach ($limitations as $i => $permissions) { // Make sure global and organisations permission are mirror in the case where one of the two is not defined
if (!isset($permissions['global']['limit'])) {
$limitations[$i]['global']['limit'] = $permissions['organisation']['limit'];
}
if (!isset($permissions['organisation']['limit'])) {
$limitations[$i]['organisation']['limit'] = $permissions['global']['limit'];
}
}
foreach ($limitations as $field => $data) {
if (isset($data['global'])) {
$limitations[$field]['global']['current'] = $MetaFields->find('all', [