From 49185c48df7a317fac896647c538e977f14914fd Mon Sep 17 00:00:00 2001 From: Jakub Onderka Date: Tue, 22 Dec 2020 12:54:54 +0100 Subject: [PATCH] chg: [UI] Site admin redirects from role index to admin index --- app/Controller/RolesController.php | 17 +++++++---------- app/View/Roles/admin_index.ctp | 1 + 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/Controller/RolesController.php b/app/Controller/RolesController.php index 1a1e9d4a5..43b5a7596 100644 --- a/app/Controller/RolesController.php +++ b/app/Controller/RolesController.php @@ -9,8 +9,6 @@ App::uses('AppController', 'Controller'); */ class RolesController extends AppController { - public $options = array('0' => 'Read Only', '1' => 'Manage My Own Events', '2' => 'Manage Organization Events', '3' => 'Manage & Publish Organization Events'); // FIXME move this to Role Model - public $components = array( 'Security', 'Session', @@ -41,23 +39,19 @@ class RolesController extends AppController { $this->set('menuData', array('menuList' => 'admin', 'menuItem' => 'addRole')); $params = []; - $selectConditions = []; $this->CRUD->add($params); if ($this->IndexFilter->isRest()) { return $this->restResponsePayload; } $this->set('permFlags', $this->Role->permFlags); $dropdownData = [ - 'options' => $this->options + 'options' => $this->Role->premissionLevelName, ]; $this->set(compact('dropdownData')); } public function admin_edit($id = null) { - if (!$this->_isSiteAdmin()) { - $this->redirect(array('controller' => 'roles', 'action' => 'index', 'admin' => false)); - } $this->Role->id = $id; if (!$this->Role->exists() && !$this->request->is('get')) { throw new NotFoundException(__('Invalid Role')); @@ -94,7 +88,7 @@ class RolesController extends AppController $this->request->data['Role']['id'] = $id; $this->request->data = $this->Role->read(null, $id); } - $this->set('options', $this->options); + $this->set('options', $this->Role->premissionLevelName); $this->set('permFlags', $this->Role->permFlags); $this->set('id', $id); } @@ -132,18 +126,21 @@ class RolesController extends AppController public function index() { - $this->recursive = 0; if ($this->_isRest()) { $roles = $this->Role->find('all', array( 'recursive' => -1 )); return $this->RestResponse->viewData($roles, $this->response->type()); } else { + if ($this->_isSiteAdmin()) { + $this->redirect(array('controller' => 'roles', 'action' => 'admin_index')); + } + $this->recursive = 0; $this->set('list', $this->paginate()); $this->set('permFlags', $this->Role->permFlags); $this->loadModel('AdminSetting'); $this->set('default_role_id', $this->AdminSetting->getSetting('default_role')); - $this->set('options', $this->options); + $this->set('options', $this->Role->premissionLevelName); } } diff --git a/app/View/Roles/admin_index.ctp b/app/View/Roles/admin_index.ctp index d967ee99b..195842308 100644 --- a/app/View/Roles/admin_index.ctp +++ b/app/View/Roles/admin_index.ctp @@ -71,6 +71,7 @@ 'data' => [ 'type' => 'simple', 'text' => __('Add role'), + 'fa-icon' => 'plus', 'class' => 'btn btn-primary', 'onClick' => 'openGenericModal', 'onClickParams' => [