Checks whether $model is a memory-only dummy that must not be saved

@param \Tx_Oelib_Model $model the model to check

@return bool TRUE if $model is a memory-only dummy, FALSE otherwise
199416
private function isModelAMemoryOnlyDummy(\Tx_Oelib_Model $model)
    {
        if (!$model->hasUid()) {
            return false;
        }

        return isset($this->uidsOfMemoryOnlyDummyModels[$model->getUid()]);
    }
1341454
public function afterSave(Model $Model, $created, $options = array()) {
		if ($this->settings[$Model->alias]['auto'] === false) {
			return true;
		}
		if (!$Model->ShadowModel) {
			return true;
		}
		if ($created) {
			$Model->ShadowModel->create($Model->data, true);
			$Model->ShadowModel->set($Model->primaryKey, $Model->id);
			$Model->ShadowModel->set('version_created', date('Y-m-d H:i:s'));
			foreach ($Model->data as $alias => $aliasData) {
				if (isset($Model->ShadowModel->_schema[$alias])) {
					if (isset($aliasData[$alias]) && !empty($aliasData[$alias])) {
						$Model->ShadowModel->set($alias, implode(',', $aliasData[$alias]));
					}
				}
			}
			$success = (bool)$Model->ShadowModel->save();
			$Model->versionId = $Model->ShadowModel->id;
			return $success;
		}

		$habtm = array();
		foreach ($Model->getAssociated('hasAndBelongsToMany') as $assocAlias) {
			if (isset($Model->ShadowModel->_schema[$assocAlias])) {
				$habtm[] = $assocAlias;
			}
		}
		$data = $Model->find('first', array('contain' => $habtm, 'conditions' => array($Model->alias . '.' . $Model->primaryKey =>
					$Model->id)));

		$changeDetected = false;
		foreach ($data[$Model->alias] as $key => $value) {
			if (isset($data[$Model->alias][$Model->primaryKey]) && !empty($this->_oldData[$Model->alias]) && isset($this->_oldData[$Model->
				alias][$Model->alias][$key])) {

				$oldValue = $this->_oldData[$Model->alias][$Model->alias][$key];
			} else {
				$oldValue = '';
			}
			if ($value != $oldValue && !in_array($key, $this->settings[$Model->alias]['ignore'])) {
				$changeDetected = true;
			}
		}
		$Model->ShadowModel->create($data);
		if (!empty($habtm)) {
			foreach ($habtm as $assocAlias) {
				if (in_array($assocAlias, $this->settings[$Model->alias]['ignore'])) {
					continue;
				}
				$oldIds = Hash::extract($this->_oldData[$Model->alias], $assocAlias . '.{n}.id');
				if (!isset($Model->data[$assocAlias])) {
					$Model->ShadowModel->set($assocAlias, implode(',', $oldIds));
					continue;
				}
				$currentIds = Hash::extract($data, $assocAlias . '.{n}.id');
				$idChanges = array_diff($currentIds, $oldIds);
				if (!empty($idChanges)) {
					$Model->ShadowModel->set($assocAlias, implode(',', $currentIds));
					$changeDetected = true;
				} else {
					$Model->ShadowModel->set($assocAlias, implode(',', $oldIds));
				}
			}
		}
		unset($this->_oldData[$Model->alias]);
		if (!$changeDetected) {
			return true;
		}
		$Model->ShadowModel->set('version_created', date('Y-m-d H:i:s'));
		$Model->ShadowModel->save();
		$Model->versionId = $Model->ShadowModel->id;
		if (is_numeric($this->settings[$Model->alias]['limit'])) {
			$conditions = array('conditions' => array($Model->alias . '.' . $Model->primaryKey => $Model->id));
			$count = $Model->ShadowModel->find('count', $conditions);
			if ($count > $this->settings[$Model->alias]['limit']) {
				$conditions['order'] = $Model->alias . '.version_created ASC, ' . $Model->alias . '.version_id ASC';
				$oldest = $Model->ShadowModel->find('first', $conditions);
				$Model->ShadowModel->id = null;
				$Model->ShadowModel->delete($oldest[$Model->alias][$Model->ShadowModel->primaryKey]);
			}
		}
		return true;
	}
644724
public function beforeDelete(Model $Model, $cascade = true) {
		if ($this->settings[$Model->alias]['auto'] === false) {
			return true;
		}
		if (!$Model->ShadowModel) {
			return true;
		}
		foreach ($Model->hasAndBelongsToMany as $assocAlias => $a) {
			if (isset($Model->{$assocAlias}->ShadowModel->_schema[$Model->alias])) {
				$joins = $Model->{$a['with']}->find('all', array('recursive' => -1, 'conditions' => array($a['foreignKey'] => $Model->
							id)));
				$this->deleteUpdates[$Model->alias][$assocAlias] = Hash::extract($joins, '{n}.' . $a['with'] . '.' . $a['associationForeignKey']);
			}
		}
		return true;
	}
1236909
public function add(\Tx_Oelib_Model $model)
    {
        if (!$model->hasUid()) {
            throw new \InvalidArgumentException('Add() requires a model that has a UID.', 1331488748);
        }

        $this->items[$model->getUid()] = $model;
        $this->highestUid = max($this->highestUid, $model->getUid());
    }
904326
protected function isAutoGenerated(Model $model, $key)
    {
        if ($key == $model->getKeyName() && $model->getIncrementing()) {
            return true;
        }

        $constants = (new ReflectionClass($model))->getConstants();

        if (in_array($key, [$constants['CREATED_AT'], $constants['UPDATED_AT']]) && $model->usesTimestamps()) {
            return true;
        }

        if (!method_exists($model, 'getDeletedAtColumn')) {
            return false;
        }

        return $key == $model->getDeletedAtColumn();
    }
188783
public function save(Model $model)
    {
        $this->setForeignAttributesForCreate($model);

        return $model->save() ? $model : false;
    }
946959
public function undo(Model $Model) {
		if (!$Model->id) {
			trigger_error('RevisionBehavior: Model::id must be set', E_USER_WARNING);
			return null;
		}
		if (!$Model->ShadowModel) {
			trigger_error('RevisionBehavior: ShadowModel doesnt exist.', E_USER_WARNING);
			return false;
		}
		$data = $this->previous($Model);
		if (!$data) {
			$Model->logableAction['Revision'] = 'undo add';
			$Model->delete($Model->id);
			return false;
		}
		foreach ($Model->getAssociated('hasAndBelongsToMany') as $assocAlias) {
			if (isset($Model->ShadowModel->_schema[$assocAlias])) {
				$data[$assocAlias][$assocAlias] = explode(',', $data[$Model->alias][$assocAlias]);
			}
		}
		$Model->logableAction['Revision'] = 'undo changes';
		return (bool)$Model->save($data);
	}
1345434
public function save(Model $model)
    {
        if ($this->fieldId) {
            $model->setAttribute($this->fieldKey, $this->fieldId);
        }

        return parent::save($model);
    }
793767
public function isOwner(Model $Model) {
		if (!$Model->exists()) {
			return false;
		}

		if (!$owner = Hash::get($Model->data, $Model->alias . '.' . $this->settings[$Model->alias]['owner']['path'])) {
			$requireAuth = $Model->requireAuth;
			$Model->requireAuth = false;
			$owner = $Model->field(
				$this->settings[$Model->alias]['owner']['path'],
				array($Model->alias . '.' . $Model->primaryKey => $Model->getID())
			);
			$Model->requireAuth = $requireAuth;
		}

		return $this->getCurrentUser($Model, $this->settings[$Model->alias]['owner']['auth']) == $owner;
	}
848554
public function saved(Model $model)
    {
        $tags = $this->processTags(request('tags'));
        $this->syncTags($model, $tags);
    }
1179656
public function created(Model $model)
    {
        $langs = app('languages')->langs();
        DB::beginTransaction();
        try {
            foreach ($langs as $lang) {
                $this->saveTranslatedMessage($model, $lang);
            }
        } catch (Exception $ex) {
            DB::rollback();
            throw $ex;
        }
        DB::commit();
        return true;
    }
439569
public function setHabtmData(Model $model) {
        foreach ($model->hasAndBelongsToMany as $assoc) {
            if (!$assoc['showInForm']) {
                continue;
            }

            $object = Admin::introspectModel($assoc['className']);
            $variable = Inflector::variable(Inflector::pluralize(preg_replace('/(?:_id)$/', '', $assoc['associationForeignKey'])));

            $this->Controller->set($variable, $this->getRecordList($object));
        }
    }
824966
public function save(Model $model)
    {
        $saved = $model->save();

        if ($saved) {
            app('cache')->flush();
        }

        return $saved;
    }
598028
protected function shouldMaintainIndex(Model $model = null)
    {
        if ((bool) $this->config('maintain_index', true) === false) {
            return false;
        }

        if ($model !== null) {
            return $this->option($model, 'maintain_index', true);
        }
    }
831153
public function detailsSaveSections(Model $Model, $sections = array()) {
		$DetailModel = ClassRegistry::init($this->settings[$Model->alias]['alias']);

		if (empty($Model->data[$DetailModel->alias])) {
			return true;
		} else if (!$this->detailsValidateSections($Model, $sections)) {
			return false;
		}

		if (empty($sections)) {
			$sections = array_keys($Model->data[$DetailModel->alias]);
		}

		foreach ($Model->data[$DetailModel->alias] as $section => $details) {

			if (!in_array($section, $sections)) {
				continue;
			}

			foreach ($details as $key => $val) {
				$field = $section . '.' . $key;
				$data = array(
					'foreign_model' => $Model->className(),
					'foreign_key' => $Model->id,
					'field' => $field,
				);

				$detail = $DetailModel->find('first', array(
					'conditions' => $data,
					'fields' => array('id', 'field'),
					'recursive' => -1
				));

				if (empty($detail)) {
					$DetailModel->create();
					if (!empty($Model->detailsSchema[$section][$key])) {
						$data += $Model->detailsSchema[$section][$key];
					}
				} else if (!empty($detail)) {
					$data[$DetailModel->primaryKey] = $detail[$DetailModel->alias][$DetailModel->primaryKey];
				}

				$data += array('value' => $val);
				if (!$DetailModel->save($data, array('validate' => false, 'bypass' => false))) {
					return false;
				}
			}

		}

		return true;
	}
34704
public static function clearCache($model = null)
    {
        if (is_null($model)) {
            static::$_cache = [];
        } elseif (isset(static::$_cache[$model])) {
            static::$_cache[$model] = [];
        }

        return true;
    }
485273
public function save(Model $model)
    {
        $model->setAttribute($this->getForeignKeyName(), $this->getParentKey());

        return $model->save() ? $model : false;
    }