protected function setStatusReview($status)
    {
        $id = $this->getParam(0);
        $all = $this->getParam('all');

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

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

        $options = null;

        if (isset($id)) {

            if ($this->getParam('user')) {
                $options = array('user_id' => $id);
            } else if ($this->getParam('product')) {
                $options = array('product_id' => $id);
            }

        } else if (!empty($all)) {
            $options = array();
        }

        if (isset($options)) {

            $deleted = $count = 0;
            foreach ($this->review->getList($options) as $item) {
                $count++;
                $deleted += (int) $this->review->update($item['review_id'], array('status' => $status));
            }

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

        } else if (!empty($id)) {
            $result = $this->review->update($id, array('status' => $status));
        }

        if (empty($result)) {
            $this->errorAndExit($this->text('Unexpected result'));
        }
    }
protected function setStatusReview($status)
    {
        $id = $this->getParam(0);
        $all = $this->getParam('all');

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

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

        $options = null;

        if (isset($id)) {

            if ($this->getParam('user')) {
                $options = array('user_id' => $id);
            } else if ($this->getParam('product')) {
                $options = array('product_id' => $id);
            }

        } else if (!empty($all)) {
            $options = array();
        }

        if (isset($options)) {

            $deleted = $count = 0;
            foreach ($this->review->getList($options) as $item) {
                $count++;
                $deleted += (int) $this->review->update($item['review_id'], array('status' => $status));
            }

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

        } else if (!empty($id)) {
            $result = $this->review->update($id, array('status' => $status));
        }

        if (empty($result)) {
            $this->errorAndExit($this->text('Unexpected result'));
        }
    }
protected function setStatusReview ( $ status ) { $ id = $ this -> getParam ( 0 ) ; $ all = $ this -> getParam ( 'all' ) ; if ( ! isset ( $ id ) && empty ( $ all ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } if ( isset ( $ id ) && ( empty ( $ id ) || ! is_numeric ( $ id ) ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } $ options = null ; if ( isset ( $ id ) ) { if ( $ this -> getParam ( 'user' ) ) { $ options = array ( 'user_id' => $ id ) ; } else if ( $ this -> getParam ( 'product' ) ) { $ options = array ( 'product_id' => $ id ) ; } } else if ( ! empty ( $ all ) ) { $ options = array ( ) ; } if ( isset ( $ options ) ) { $ deleted = $ count = 0 ; foreach ( $ this -> review -> getList ( $ options ) as $ item ) { $ count ++ ; $ deleted += ( int ) $ this -> review -> update ( $ item [ 'review_id' ] , array ( 'status' => $ status ) ) ; } $ result = $ count && $ count == $ deleted ; } else if ( ! empty ( $ id ) ) { $ result = $ this -> review -> update ( $ id , array ( 'status' => $ status ) ) ; } if ( empty ( $ result ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } }
Sets status for one or several reviews
@param bool $status
Sets status for one or several reviews