public function setStatusUser($status)
    {
        $options = $id = $result = null;

        if ($this->getParam('all')) {
            $options = array();
        } else {

            $id = $this->getParam(0);

            if (!is_numeric($id)) { // Allow 0 for roleless users
                $this->errorAndExit($this->text('Invalid argument'));
            }

            if ($this->getParam('role')) {
                $options = array('role_id' => $id);
            } else if ($this->getParam('store')) {
                $options = array('store_id' => $id);
            }
        }

        if (isset($options)) {

            $updated = $count = 0;
            foreach ($this->user->getList($options) as $item) {
                $count++;
                $updated += (int) $this->user->update($item['user_id'], array('status' => (bool) $status));
            }

            $result = $count && $count == $updated;

        } else if (isset($id)) {
            $result = $this->user->update($id, array('status' => (bool) $status));
        }

        if (empty($result)) {
            $this->errorAndExit($this->text('Unexpected result'));
        }
    }
public function setStatusUser($status)
    {
        $options = $id = $result = null;

        if ($this->getParam('all')) {
            $options = array();
        } else {

            $id = $this->getParam(0);

            if (!is_numeric($id)) { // Allow 0 for roleless users
                $this->errorAndExit($this->text('Invalid argument'));
            }

            if ($this->getParam('role')) {
                $options = array('role_id' => $id);
            } else if ($this->getParam('store')) {
                $options = array('store_id' => $id);
            }
        }

        if (isset($options)) {

            $updated = $count = 0;
            foreach ($this->user->getList($options) as $item) {
                $count++;
                $updated += (int) $this->user->update($item['user_id'], array('status' => (bool) $status));
            }

            $result = $count && $count == $updated;

        } else if (isset($id)) {
            $result = $this->user->update($id, array('status' => (bool) $status));
        }

        if (empty($result)) {
            $this->errorAndExit($this->text('Unexpected result'));
        }
    }
public function setStatusUser ( $ status ) { $ options = $ id = $ result = null ; if ( $ this -> getParam ( 'all' ) ) { $ options = array ( ) ; } else { $ id = $ this -> getParam ( 0 ) ; if ( ! is_numeric ( $ id ) ) { // Allow 0 for roleless users $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } if ( $ this -> getParam ( 'role' ) ) { $ options = array ( 'role_id' => $ id ) ; } else if ( $ this -> getParam ( 'store' ) ) { $ options = array ( 'store_id' => $ id ) ; } } if ( isset ( $ options ) ) { $ updated = $ count = 0 ; foreach ( $ this -> user -> getList ( $ options ) as $ item ) { $ count ++ ; $ updated += ( int ) $ this -> user -> update ( $ item [ 'user_id' ] , array ( 'status' => ( bool ) $ status ) ) ; } $ result = $ count && $ count == $ updated ; } else if ( isset ( $ id ) ) { $ result = $ this -> user -> update ( $ id , array ( 'status' => ( bool ) $ status ) ) ; } if ( empty ( $ result ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } }
Sets a user status
@param $status
Sets a user status