src/Controller/UserGroupPermissionController.php
public function getPermission()
    {
        $this->request->allowMethod(['ajax']);

        $group_or_user = isset($this->request->data['group_or_user']) ? $this->request->data['group_or_user'] : null;
        $group_or_user_id = isset($this->request->data['group_or_user_id']) ? $this->request->data['group_or_user_id'] : null;

        $ugp = $this->UserGroupPermission->find()
            ->select(['permission_id','allow'])
            ->where(
                [
                    'group_or_user_id' => $group_or_user_id,
                    'group_or_user' => $group_or_user
                ])->toArray();

        $response = (!empty($ugp) && !is_null($ugp)) ? $ugp : 'fail';

        $this->set(compact('response'));
        $this->set('_serialize', ['response']);
        $this->render('Acl.Ajax/ajax_response', false);
    }
public function getPermission()
    {
        $this->request->allowMethod(['ajax']);

        $group_or_user = isset($this->request->data['group_or_user']) ? $this->request->data['group_or_user'] : null;
        $group_or_user_id = isset($this->request->data['group_or_user_id']) ? $this->request->data['group_or_user_id'] : null;

        $ugp = $this->UserGroupPermission->find()
            ->select(['permission_id','allow'])
            ->where(
                [
                    'group_or_user_id' => $group_or_user_id,
                    'group_or_user' => $group_or_user
                ])->toArray();

        $response = (!empty($ugp) && !is_null($ugp)) ? $ugp : 'fail';

        $this->set(compact('response'));
        $this->set('_serialize', ['response']);
        $this->render('Acl.Ajax/ajax_response', false);
    }
public function getPermission ( ) { $ this -> request -> allowMethod ( [ 'ajax' ] ) ; $ group_or_user = isset ( $ this -> request -> data [ 'group_or_user' ] ) ? $ this -> request -> data [ 'group_or_user' ] : null ; $ group_or_user_id = isset ( $ this -> request -> data [ 'group_or_user_id' ] ) ? $ this -> request -> data [ 'group_or_user_id' ] : null ; $ ugp = $ this -> UserGroupPermission -> find ( ) -> select ( [ 'permission_id' , 'allow' ] ) -> where ( [ 'group_or_user_id' => $ group_or_user_id , 'group_or_user' => $ group_or_user ] ) -> toArray ( ) ; $ response = ( ! empty ( $ ugp ) && ! is_null ( $ ugp ) ) ? $ ugp : 'fail' ; $ this -> set ( compact ( 'response' ) ) ; $ this -> set ( '_serialize' , [ 'response' ] ) ; $ this -> render ( 'Acl.Ajax/ajax_response' , false ) ; }
Get all permissions by ajax
Get all permissions by ajax