controllers/commands/Role.php
public function cmdDeleteRole()
    {
        $id = $this->getParam(0);
        $all = $this->getParam('all');

        if (!isset($id) && empty($all)) {
            $this->errorAndExit($this->text('Invalid command'));
        }

        $result = false;

        if (isset($id)) {

            if (empty($id) || !is_numeric($id)) {
                $this->errorAndExit($this->text('Invalid argument'));
            }

            $result = $this->role->delete($id);

        } else if ($all) {

            $deleted = $count = 0;
            foreach ($this->role->getList() as $item) {
                $count++;
                $deleted += (int) $this->role->delete($item['role_id']);
            }

            $result = $count && $count == $deleted;
        }

        if (empty($result)) {
            $this->errorAndExit($this->text('Unexpected result'));
        }

        $this->output();
    }
public function cmdDeleteRole()
    {
        $id = $this->getParam(0);
        $all = $this->getParam('all');

        if (!isset($id) && empty($all)) {
            $this->errorAndExit($this->text('Invalid command'));
        }

        $result = false;

        if (isset($id)) {

            if (empty($id) || !is_numeric($id)) {
                $this->errorAndExit($this->text('Invalid argument'));
            }

            $result = $this->role->delete($id);

        } else if ($all) {

            $deleted = $count = 0;
            foreach ($this->role->getList() as $item) {
                $count++;
                $deleted += (int) $this->role->delete($item['role_id']);
            }

            $result = $count && $count == $deleted;
        }

        if (empty($result)) {
            $this->errorAndExit($this->text('Unexpected result'));
        }

        $this->output();
    }
public function cmdDeleteRole ( ) { $ id = $ this -> getParam ( 0 ) ; $ all = $ this -> getParam ( 'all' ) ; if ( ! isset ( $ id ) && empty ( $ all ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } $ result = false ; if ( isset ( $ id ) ) { if ( empty ( $ id ) || ! is_numeric ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } $ result = $ this -> role -> delete ( $ id ) ; } else if ( $ all ) { $ deleted = $ count = 0 ; foreach ( $ this -> role -> getList ( ) as $ item ) { $ count ++ ; $ deleted += ( int ) $ this -> role -> delete ( $ item [ 'role_id' ] ) ; } $ result = $ count && $ count == $ deleted ; } if ( empty ( $ result ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> output ( ) ; }
Callback for "role-delete" command
Callback for role - delete command