Made use of MultiFormStep::getNextStepFromDatabase() instead of direct DO::get() call, and check for SessionID before attempting a DO::get()

This commit is contained in:
Sean Harvey 2008-04-20 00:39:01 +00:00
parent facf2e3833
commit 0d3196607a
2 changed files with 11 additions and 13 deletions

View File

@ -398,8 +398,7 @@ abstract class MultiForm extends Form {
if(!$step->isFinalStep()) {
if($step->getNextStep()) {
// Is this step in the DB? If it is, we use that
if($nextSteps = DataObject::get($step->getNextStep(), "SessionID = {$this->session->ID}", "LastEdited DESC")) {
$nextStep = $nextSteps->First();
if($nextStep = $step->getNextStepFromDatabase()) {
$templateData = array(
'ID' => $nextStep->ID,
'ClassName' => $nextStep->class,

View File

@ -152,21 +152,20 @@ class MultiFormStep extends DataObject {
* Returns the next step to the current step in the database.
*
* This will only return something if you've previously visited
* the step ahead of the current step, so if you've gone to the
* step ahead, and then gone back a step.
* the step ahead of the current step, and then gone back a step.
*
* @return MultiFormStep|boolean
*/
public function getNextStepFromDatabase() {
$nextSteps = $this->stat('next_steps');
if(is_string($nextSteps)) {
$step = DataObject::get_one($nextSteps, "SessionID = {$this->SessionID}");
if($step) return $step;
} elseif(is_array($nextSteps)) {
$step = DataObject::get_one($nextSteps[0], "SessionID = {$this->SessionID}");
if($step) return $step;
} else {
return false;
if($this->SessionID) {
$nextSteps = $this->stat('next_steps');
if(is_string($nextSteps)) {
return DataObject::get_one($nextSteps, "SessionID = {$this->SessionID}");
} elseif(is_array($nextSteps)) {
return DataObject::get_one($nextSteps[0], "SessionID = {$this->SessionID}");
} else {
return false;
}
}
}