public function postDeleteRole()
    {
        $response = (object)array(
            'method'        => 'deleterole',
            'success'       => false,
            'status'        => 200,
            'error_code'    => 0,
            'error_message' => ''
        );
        // decode json data
        $data = json_decode(file_get_contents("php://input"));
        if( empty($data)) {
            $data = (object) $_POST;
        }
        $requiredParams = array('id');
        try {
            AuthorizerHelper::can(RoleValidator::ROLE_CAN_DELETE);

            $data = (array) $data;
            foreach ($requiredParams as $param){
                if (empty($data[$param])) {
                    throw new \Exception(ucfirst($param) .' is required.');
                }
            }

            $roleModel    = new \erdiko\users\models\Role();
            $roleId = $roleModel->delete($data['id']);
            $responseRoleId = array('id' => $roleId);
            $response->success = true;
            $response->role = $responseRoleId;
            unset($response->error_code);
            unset($response->error_message);
        } catch (\Exception $e) {
            $response->success = false;
            $response->error_code = $e->getCode();
            $response->error_message = $e->getMessage();
        }
        $this->setContent($response);
    }
public function postDeleteRole()
    {
        $response = (object)array(
            'method'        => 'deleterole',
            'success'       => false,
            'status'        => 200,
            'error_code'    => 0,
            'error_message' => ''
        );
        // decode json data
        $data = json_decode(file_get_contents("php://input"));
        if( empty($data)) {
            $data = (object) $_POST;
        }
        $requiredParams = array('id');
        try {
            AuthorizerHelper::can(RoleValidator::ROLE_CAN_DELETE);

            $data = (array) $data;
            foreach ($requiredParams as $param){
                if (empty($data[$param])) {
                    throw new \Exception(ucfirst($param) .' is required.');
                }
            }

            $roleModel    = new \erdiko\users\models\Role();
            $roleId = $roleModel->delete($data['id']);
            $responseRoleId = array('id' => $roleId);
            $response->success = true;
            $response->role = $responseRoleId;
            unset($response->error_code);
            unset($response->error_message);
        } catch (\Exception $e) {
            $response->success = false;
            $response->error_code = $e->getCode();
            $response->error_message = $e->getMessage();
        }
        $this->setContent($response);
    }
public function postDeleteRole ( ) { $ response = ( object ) array ( 'method' => 'deleterole' , 'success' => false , 'status' => 200 , 'error_code' => 0 , 'error_message' => '' ) ; // decode json data $ data = json_decode ( file_get_contents ( "php://input" ) ) ; if ( empty ( $ data ) ) { $ data = ( object ) $ _POST ; } $ requiredParams = array ( 'id' ) ; try { AuthorizerHelper :: can ( RoleValidator :: ROLE_CAN_DELETE ) ; $ data = ( array ) $ data ; foreach ( $ requiredParams as $ param ) { if ( empty ( $ data [ $ param ] ) ) { throw new \ Exception ( ucfirst ( $ param ) . ' is required.' ) ; } } $ roleModel = new \ erdiko \ users \ models \ Role ( ) ; $ roleId = $ roleModel -> delete ( $ data [ 'id' ] ) ; $ responseRoleId = array ( 'id' => $ roleId ) ; $ response -> success = true ; $ response -> role = $ responseRoleId ; unset ( $ response -> error_code ) ; unset ( $ response -> error_message ) ; } catch ( \ Exception $ e ) { $ response -> success = false ; $ response -> error_code = $ e -> getCode ( ) ; $ response -> error_message = $ e -> getMessage ( ) ; } $ this -> setContent ( $ response ) ; }
delete a given role
delete a given role