From e408f29a0552e0f2fbda7d84e8253b941a512bc2 Mon Sep 17 00:00:00 2001 From: iglocska Date: Wed, 1 Dec 2021 14:23:27 +0100 Subject: [PATCH] chg: [appcontroller] minor changes - getRoleAccess now returns array format - moved setting of view variables behind a rest check, to avoid additional unused actions for API queries - current user's role access matrix passed to view via "roleAccess" --- src/Controller/AppController.php | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/Controller/AppController.php b/src/Controller/AppController.php index 2b0102a..4d41bac 100644 --- a/src/Controller/AppController.php +++ b/src/Controller/AppController.php @@ -116,6 +116,7 @@ class AppController extends Controller if (!$this->ParamHandler->isRest()) { $this->set('menu', $this->ACL->getMenu()); $this->set('loggedUser', $this->ACL->getUser()); + $this->set('roleAccess', $this->ACL->getRoleAccess(false, false)); } } else if ($this->ParamHandler->isRest()) { throw new MethodNotAllowedException(__('Invalid user credentials.')); @@ -131,18 +132,20 @@ class AppController extends Controller } $this->ACL->checkAccess(); - $this->set('breadcrumb', $this->Navigation->getBreadcrumb()); - $this->set('ajax', $this->request->is('ajax')); - $this->request->getParam('prefix'); - $this->set('baseurl', Configure::read('App.fullBaseUrl')); - if (!empty($user) && !empty($user->user_settings_by_name['ui.bsTheme']['value'])) { - $this->set('bsTheme', $user->user_settings_by_name['ui.bsTheme']['value']); - } else { - $this->set('bsTheme', Configure::check('ui.bsTheme') ? Configure::read('ui.bsTheme') : 'default'); - } + if (!$this->ParamHandler->isRest()) { + $this->set('breadcrumb', $this->Navigation->getBreadcrumb()); + $this->set('ajax', $this->request->is('ajax')); + $this->request->getParam('prefix'); + $this->set('baseurl', Configure::read('App.fullBaseUrl')); + if (!empty($user) && !empty($user->user_settings_by_name['ui.bsTheme']['value'])) { + $this->set('bsTheme', $user->user_settings_by_name['ui.bsTheme']['value']); + } else { + $this->set('bsTheme', Configure::check('ui.bsTheme') ? Configure::read('ui.bsTheme') : 'default'); + } - if ($this->modelClass == 'Tags.Tags') { - $this->set('metaGroup', !empty($this->isAdmin) ? 'Administration' : 'Cerebrate'); + if ($this->modelClass == 'Tags.Tags') { + $this->set('metaGroup', !empty($this->isAdmin) ? 'Administration' : 'Cerebrate'); + } } } @@ -191,6 +194,6 @@ class AppController extends Controller public function getRoleAccess() { - return $this->RestResponse->viewData($this->ACL->getRoleAccess()); + return $this->RestResponse->viewData($this->ACL->getRoleAccess(false, false)); } }