Model/Behavior/SoftDeleteBehavior.php
protected function _softDeleteAssociations($model, $active) {
		if (empty($model->belongsTo)) {
			return;
		}

		$fields = array_keys($this->_normalizeFields($model));
		$parentModels = array_keys($model->belongsTo);

		foreach ($parentModels as $parentModel) {
			foreach (array('hasOne', 'hasMany') as $assocType) {
				if (empty($model->{$parentModel}->{$assocType})) {
					continue;
				}

				foreach ($model->{$parentModel}->{$assocType} as $assoc => $assocConfig) {
					$modelName = empty($assocConfig['className']) ? $assoc : @$assocConfig['className'];
					if ((!empty($model->plugin) && strstr($model->plugin . '.', $model->alias) === false ? $model->plugin . '.' : '') . $model->alias !== $modelName) {
						continue;
					}

					$conditions =& $model->{$parentModel}->{$assocType}[$assoc]['conditions'];
					if (!is_array($conditions)) {
						$model->{$parentModel}->{$assocType}[$assoc]['conditions'] = array();
					}

					$multiFields = 1 < count($fields);
					foreach ($fields as $field) {
						if ($active) {
							if (!isset($conditions[$field]) && !isset($conditions[$assoc . '.' . $field])) {
								if (is_string($active)) {
									if ($field == $active) {
										$conditions[$assoc . '.' . $field] = false;
									} elseif (isset($conditions[$assoc . '.' . $field])) {
										unset($conditions[$assoc . '.' . $field]);
									}
								} elseif (!$multiFields) {
									$conditions[$assoc . '.' . $field] = false;
								}
							}
						} elseif (isset($conditions[$assoc . '.' . $field])) {
							unset($conditions[$assoc . '.' . $field]);
						}
					}
				}
			}
		}
	}
protected function _softDeleteAssociations($model, $active) {
		if (empty($model->belongsTo)) {
			return;
		}

		$fields = array_keys($this->_normalizeFields($model));
		$parentModels = array_keys($model->belongsTo);

		foreach ($parentModels as $parentModel) {
			foreach (array('hasOne', 'hasMany') as $assocType) {
				if (empty($model->{$parentModel}->{$assocType})) {
					continue;
				}

				foreach ($model->{$parentModel}->{$assocType} as $assoc => $assocConfig) {
					$modelName = empty($assocConfig['className']) ? $assoc : @$assocConfig['className'];
					if ((!empty($model->plugin) && strstr($model->plugin . '.', $model->alias) === false ? $model->plugin . '.' : '') . $model->alias !== $modelName) {
						continue;
					}

					$conditions =& $model->{$parentModel}->{$assocType}[$assoc]['conditions'];
					if (!is_array($conditions)) {
						$model->{$parentModel}->{$assocType}[$assoc]['conditions'] = array();
					}

					$multiFields = 1 < count($fields);
					foreach ($fields as $field) {
						if ($active) {
							if (!isset($conditions[$field]) && !isset($conditions[$assoc . '.' . $field])) {
								if (is_string($active)) {
									if ($field == $active) {
										$conditions[$assoc . '.' . $field] = false;
									} elseif (isset($conditions[$assoc . '.' . $field])) {
										unset($conditions[$assoc . '.' . $field]);
									}
								} elseif (!$multiFields) {
									$conditions[$assoc . '.' . $field] = false;
								}
							}
						} elseif (isset($conditions[$assoc . '.' . $field])) {
							unset($conditions[$assoc . '.' . $field]);
						}
					}
				}
			}
		}
	}
protected function _softDeleteAssociations ( $ model , $ active ) { if ( empty ( $ model -> belongsTo ) ) { return ; } $ fields = array_keys ( $ this -> _normalizeFields ( $ model ) ) ; $ parentModels = array_keys ( $ model -> belongsTo ) ; foreach ( $ parentModels as $ parentModel ) { foreach ( array ( 'hasOne' , 'hasMany' ) as $ assocType ) { if ( empty ( $ model -> { $ parentModel } -> { $ assocType } ) ) { continue ; } foreach ( $ model -> { $ parentModel } -> { $ assocType } as $ assoc => $ assocConfig ) { $ modelName = empty ( $ assocConfig [ 'className' ] ) ? $ assoc : @ $ assocConfig [ 'className' ] ; if ( ( ! empty ( $ model -> plugin ) && strstr ( $ model -> plugin . '.' , $ model -> alias ) === false ? $ model -> plugin . '.' : '' ) . $ model -> alias !== $ modelName ) { continue ; } $ conditions = & $ model -> { $ parentModel } -> { $ assocType } [ $ assoc ] [ 'conditions' ] ; if ( ! is_array ( $ conditions ) ) { $ model -> { $ parentModel } -> { $ assocType } [ $ assoc ] [ 'conditions' ] = array ( ) ; } $ multiFields = 1 < count ( $ fields ) ; foreach ( $ fields as $ field ) { if ( $ active ) { if ( ! isset ( $ conditions [ $ field ] ) && ! isset ( $ conditions [ $ assoc . '.' . $ field ] ) ) { if ( is_string ( $ active ) ) { if ( $ field == $ active ) { $ conditions [ $ assoc . '.' . $ field ] = false ; } elseif ( isset ( $ conditions [ $ assoc . '.' . $ field ] ) ) { unset ( $ conditions [ $ assoc . '.' . $ field ] ) ; } } elseif ( ! $ multiFields ) { $ conditions [ $ assoc . '.' . $ field ] = false ; } } } elseif ( isset ( $ conditions [ $ assoc . '.' . $ field ] ) ) { unset ( $ conditions [ $ assoc . '.' . $ field ] ) ; } } } } } }
Modifies conditions of hasOne and hasMany associations

If multiple delete flags are configured for model, then $active=true doesn't
do anything - you have to alter conditions in association definition

@param object $model
@param mixed $active
Modifies conditions of hasOne and hasMany associations