public function deleteFiles(Model $model, $id, array $filter = array(), $isDelete = false) {
        $columns = $this->_columns[$model->alias];
        $data = $this->_doFind($model, array($model->alias . '.' . $model->primaryKey => $id));

        if (empty($data[$model->alias])) {
            return false;
        }

        // Set data in case $this->data is used in callbacks
        $model->set($data);

        $save = array();

        foreach ($data[$model->alias] as $column => $value) {
            if (empty($columns[$column]) || empty($value)) {
                continue;
            } else if ($filter && !in_array($column, $filter)) {
                continue;
            }

            if ($this->_deleteFile($model, $columns[$column], $value, $column)) {
                $save[$column] = '';

                // Reset meta data also
                foreach ($this->settings[$model->alias][$columns[$column]]['metaColumns'] as $metaKey => $fieldKey) {
                    $save[$fieldKey] = '';
                }
            }
        }

        // Set the fields to empty
        if ($save && !$isDelete) {
            $model->id = $id;
            $model->save($save, array(
                'validate' => false,
                'callbacks' => false,
                'fieldList' => array_keys($save)
            ));
        }

        return true;
    }
public function deleteFiles(Model $model, $id, array $filter = array(), $isDelete = false) {
        $columns = $this->_columns[$model->alias];
        $data = $this->_doFind($model, array($model->alias . '.' . $model->primaryKey => $id));

        if (empty($data[$model->alias])) {
            return false;
        }

        // Set data in case $this->data is used in callbacks
        $model->set($data);

        $save = array();

        foreach ($data[$model->alias] as $column => $value) {
            if (empty($columns[$column]) || empty($value)) {
                continue;
            } else if ($filter && !in_array($column, $filter)) {
                continue;
            }

            if ($this->_deleteFile($model, $columns[$column], $value, $column)) {
                $save[$column] = '';

                // Reset meta data also
                foreach ($this->settings[$model->alias][$columns[$column]]['metaColumns'] as $metaKey => $fieldKey) {
                    $save[$fieldKey] = '';
                }
            }
        }

        // Set the fields to empty
        if ($save && !$isDelete) {
            $model->id = $id;
            $model->save($save, array(
                'validate' => false,
                'callbacks' => false,
                'fieldList' => array_keys($save)
            ));
        }

        return true;
    }
public function deleteFiles ( Model $ model , $ id , array $ filter = array ( ) , $ isDelete = false ) { $ columns = $ this -> _columns [ $ model -> alias ] ; $ data = $ this -> _doFind ( $ model , array ( $ model -> alias . '.' . $ model -> primaryKey => $ id ) ) ; if ( empty ( $ data [ $ model -> alias ] ) ) { return false ; } // Set data in case $this->data is used in callbacks $ model -> set ( $ data ) ; $ save = array ( ) ; foreach ( $ data [ $ model -> alias ] as $ column => $ value ) { if ( empty ( $ columns [ $ column ] ) || empty ( $ value ) ) { continue ; } else if ( $ filter && ! in_array ( $ column , $ filter ) ) { continue ; } if ( $ this -> _deleteFile ( $ model , $ columns [ $ column ] , $ value , $ column ) ) { $ save [ $ column ] = '' ; // Reset meta data also foreach ( $ this -> settings [ $ model -> alias ] [ $ columns [ $ column ] ] [ 'metaColumns' ] as $ metaKey => $ fieldKey ) { $ save [ $ fieldKey ] = '' ; } } } // Set the fields to empty if ( $ save && ! $ isDelete ) { $ model -> id = $ id ; $ model -> save ( $ save , array ( 'validate' => false , 'callbacks' => false , 'fieldList' => array_keys ( $ save ) ) ) ; } return true ; }
Delete all files associated with a record but do not delete the record.

@param Model $model
@param int $id
@param array $filter
@param bool $isDelete
@return bool
Delete all files associated with a record but do not delete the record .