/** * Attempts to set the given step as current. Before doing that, checks * if current step can be reached, ie. * - if it is a valid wizard step * - if all previous steps have been marked as reached. * * If step is not a valid step it will redirect to first wizard step. * * If step is valid, but is not reachable yet, it will redirect to * first unreached step. * * @param OX_Admin_UI_Install_Wizard $oWizard */ protected function setCurrentStepIfReachable($oWizard, $stepId) { //check if given step is valid, if not, direct user to index if (!$oWizard->isStep($stepId)) { $this->redirect($oWizard->getFirstStep()); } $oWizard->setCurrentStep($stepId); $reachable = $oWizard->checkStepReachable(); //reachable is fine, check if not secured if ($reachable) { $aMeta = $oWizard->getStepMeta(); if ($aMeta['secured'] == true && !OA_Upgrade_Login::checkLogin()) { $this->redirect('login'); } return true; } else { //if step is not reachable check the last one marked as completed //and redirect user to the next one $lastCompleted = $oWizard->getLastCompletedStep(); if ($lastCompleted != null) { $forwardStep = $oWizard->getNextStep($lastCompleted); } if ($forwardStep == null) { $forwardStep = $oWizard->getFirstStep(); } $this->redirect($forwardStep); } }