/** * Roll back a form to a previous version. * * @param string|int Version to roll back to */ public function doRollbackTo($version) { parent::doRollbackTo($version); /* Not implemented yet // get the older version $reverted = Versioned::get_version($this->ClassName, $this->ID, $version); if($reverted) { // using the lastedited date of the reverted object we can work out which // form fields to revert back to if($this->Fields()) { foreach($this->Fields() as $field) { // query to see when the version of the page was pumped $editedDate = DB::query(" SELECT LastEdited FROM \"SiteTree_versions\" WHERE \"RecordID\" = '$this->ID' AND \"Version\" = $version ")->value(); // find a the latest version which has been edited $versionToGet = DB::query(" SELECT * FROM \"EditableFormField_versions\" WHERE \"RecordID\" = '$field->ID' AND \"LastEdited\" <= '$editedDate' ORDER BY Version DESC LIMIT 1 ")->record(); if($versionToGet) { Debug::show('publishing field'. $field->Name); Debug::show($versionToGet); $field->publish($versionToGet, "Stage", true); $field->writeWithoutVersion(); } else { Debug::show('deleting field'. $field->Name); $this->Fields()->remove($field); $field->delete(); $field->destroy(); } } } // @todo Emails } */ }
/** * Roll back a form to a previous version * * @param String|int Version to roll back to */ public function doRollbackTo($version) { if ($this->Fields()) { foreach ($this->Fields() as $field) { $field->publish($version, "Stage", true); $field->writeWithoutVersion(); } } parent::doRollbackTo($version); }