chg: [ui] Improved reflection of ACL logic in the UI for OrgGroups, Organisations and individuals.

refacto/CRUDComponent
Sami Mokaddem 2023-09-12 14:11:15 +02:00
parent 4d58b94d58
commit d2cb072ce6
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
6 changed files with 48 additions and 3 deletions

View File

@ -0,0 +1,25 @@
<?php
namespace BreadcrumbNavigation;
require_once(APP . 'Controller' . DS . 'Component' . DS . 'Navigation' . DS . 'base.php');
class OrgGroupsNavigation extends BaseNavigation
{
public function addLinks()
{
$controller = 'OrgGroups';
if (empty($this->viewVars['canEdit'])) {
$this->bcf->removeLink($controller, 'view', $controller, 'edit');
$this->bcf->removeLink($controller, 'edit', $controller, 'edit');
}
}
public function addActions()
{
$controller = 'OrgGroups';
if (empty($this->viewVars['canEdit'])) {
$this->bcf->removeAction($controller, 'view', $controller, 'delete');
$this->bcf->removeAction($controller, 'edit', $controller, 'delete');
}
}
}

View File

@ -5,4 +5,21 @@ require_once(APP . 'Controller' . DS . 'Component' . DS . 'Navigation' . DS . 'b
class OrganisationsNavigation extends BaseNavigation
{
public function addLinks()
{
$controller = 'Organisations';
if (empty($this->viewVars['canEdit'])) {
$this->bcf->removeLink($controller, 'view', $controller, 'edit');
$this->bcf->removeLink($controller, 'edit', $controller, 'edit');
}
}
public function addActions()
{
$controller = 'Organisations';
if (empty($this->viewVars['canEdit'])) {
$this->bcf->removeAction($controller, 'view', $controller, 'delete');
$this->bcf->removeAction($controller, 'edit', $controller, 'delete');
}
}
}

View File

@ -156,6 +156,7 @@ class NavigationComponent extends Component
$CRUDControllers = [
'Individuals',
'Organisations',
'OrgGroups',
'EncryptionKeys',
'SharingGroups',
'Broods',

View File

@ -39,7 +39,7 @@ class IndividualsController extends AppController
if (!empty($responsePayload)) {
return $responsePayload;
}
$editableIds = null;
$editableIds = [];
if ($orgAdmin) {
$editableIds = $this->Individuals->getValidIndividualsToEdit($currentUser);
}

View File

@ -11,7 +11,8 @@ echo $this->element('genericElements/IndexTable/index_table', [
'type' => 'simple',
'text' => __('Add group'),
'class' => 'btn btn-primary',
'popover_url' => '/orgGroups/add'
'popover_url' => '/orgGroups/add',
'requirement' => !empty($loggedUser['role']['perm_admin']),
]
]
],

View File

@ -11,7 +11,8 @@ echo $this->element('genericElements/IndexTable/index_table', [
'type' => 'simple',
'text' => __('Add organisation'),
'class' => 'btn btn-primary',
'popover_url' => '/organisations/add'
'popover_url' => '/organisations/add',
'requirement' => !empty($loggedUser['role']['perm_admin']),
]
]
],