public function cmdDeleteFieldValue()
    {
        $id = $this->getParam(0);

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

        if ($this->getParam('field')) {
            $deleted = $count = 0;
            foreach ($this->field_value->getList(array('field_id' => $id)) as $item) {
                $count++;
                $deleted += (int) $this->field_value->delete($item['field_value_id']);
            }

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

        } else {
            $result = $this->field_value->delete($id);
        }

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

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

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

        if ($this->getParam('field')) {
            $deleted = $count = 0;
            foreach ($this->field_value->getList(array('field_id' => $id)) as $item) {
                $count++;
                $deleted += (int) $this->field_value->delete($item['field_value_id']);
            }

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

        } else {
            $result = $this->field_value->delete($id);
        }

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

        $this->output();
    }
public function cmdDeleteFieldValue ( ) { $ id = $ this -> getParam ( 0 ) ; if ( empty ( $ id ) || ! is_numeric ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } if ( $ this -> getParam ( 'field' ) ) { $ deleted = $ count = 0 ; foreach ( $ this -> field_value -> getList ( array ( 'field_id' => $ id ) ) as $ item ) { $ count ++ ; $ deleted += ( int ) $ this -> field_value -> delete ( $ item [ 'field_value_id' ] ) ; } $ result = $ count && $ count == $ deleted ; } else { $ result = $ this -> field_value -> delete ( $ id ) ; } if ( empty ( $ result ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> output ( ) ; }
Callback for "field-value-delete" command
Callback for field - value - delete command