true]]; public $containFields = ['Users' => ['fields' => ['id', 'username']]]; public function index() { $currentUser = $this->ACL->getUser(); $conditions = []; if (empty($currentUser['role']['perm_admin'])) { $conditions['Users.organisation_id'] = $currentUser['organisation_id']; if (empty($currentUser['role']['perm_org_admin'])) { $conditions['Users.id'] = $currentUser['id']; } } $this->CRUD->index([ 'filters' => $this->filterFields, 'quickFilters' => $this->quickFilterFields, 'contain' => $this->containFields, 'exclude_fields' => ['authkey'], 'conditions' => $conditions, 'hidden' => [] ]); $responsePayload = $this->CRUD->getResponsePayload(); if (!empty($responsePayload)) { return $responsePayload; } $this->set('metaGroup', $this->isAdmin ? 'Administration' : 'Cerebrate'); } public function delete($id) { $currentUser = $this->ACL->getUser(); $conditions = []; if (empty($currentUser['role']['perm_admin'])) { $conditions['Users.organisation_id'] = $currentUser['organisation_id']; if (empty($currentUser['role']['perm_org_admin'])) { $conditions['Users.id'] = $currentUser['id']; } } $this->CRUD->delete($id, ['conditions' => $conditions, 'contain' => 'Users']); $responsePayload = $this->CRUD->getResponsePayload(); if (!empty($responsePayload)) { return $responsePayload; } $this->set('metaGroup', $this->isAdmin ? 'Administration' : 'Cerebrate'); } public function add() { $this->set('metaGroup', $this->isAdmin ? 'Administration' : 'Cerebrate'); $this->CRUD->add([ 'displayOnSuccess' => 'authkey_display' ]); $responsePayload = $this->CRUD->getResponsePayload([ 'displayOnSuccess' => 'authkey_display' ]); if (!empty($responsePayload)) { return $responsePayload; } $this->loadModel('Users'); $dropdownData = [ 'user' => $this->Users->find('list', [ 'sort' => ['username' => 'asc'] ]) ]; $this->set(compact('dropdownData')); } }