/** * @param $request * @return HTMLText|SS_HTTPResponse|void */ public function RenderSurvey(SS_HTTPRequest $request) { //check if user is logged in try { $step = $request->param('STEP_SLUG'); $current_survey = $this->getCurrentSurveyInstance(); if (empty($step)) { return $this->redirect($this->Link() . $current_survey->currentStep()->template()->title()); } if (!$current_survey->isAllowedStep($step)) { // redirect return $this->redirect($this->Link() . $current_survey->currentStep()->template()->title()); } $this->survey_manager->registerCurrentStep($this->current_survey, $step); if ($current_survey->isLastStep() && !$current_survey->isEmailSent()) { $this->survey_manager->sendFinalStepEmail(new SurveyThankYouEmailSenderService(), $current_survey); } return $this->customise(array('Survey' => $current_survey))->renderWith(array('Surveys_CurrentSurveyContainer', 'Page')); } catch (NotFoundEntityException $ex1) { SS_Log::log($ex1, SS_Log::WARN); return $this->LandingPage(); } catch (Exception $ex) { SS_Log::log($ex, SS_Log::ERR); return $this->httpError(404, "Survey not found!"); } }