Model/Behavior/RevisionBehavior.php
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);
	}
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);
	}
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 ) ; }
Update to previous revision

@example $this->Post->id = 2; $this->Post->undo();
@param object $Model
@return bool Success
Update to previous revision