public function call() { try { $pw = $this->getArgument('pw'); if (!$pw || $pw != 'thedoor') { return new Answer('error', "Access denied"); } $survey_code = $this->getArgument('survey'); $survey_manager = new SurveyManager(); if (!$survey_manager->isSurvey($survey_code)) { return new Answer('error', "Survey not found"); } $survey_result_mng = new SurveyResultManager(); $a_result = $survey_result_mng->getReport($survey_code); $answer = new Answer('ok', $a_result, 'csv', 'results_' . $survey_code . '.csv'); return $answer; } catch (Exception $e) { return new Answer('error', $e->getMessage()); } }
public function call() { try { $survey_code = strtoupper($this->getArgument('survey')); $survey_manager = new SurveyManager(); if (!session_id()) { session_start(); } $hex_data = $this->getArgument('h'); if ($hex_data) { $_SESSION['h'] = $hex_data; } if ($survey_manager->isSurvey($survey_code, true)) { $survey = $survey_manager->getSurvey($survey_code); $_SESSION['survey_code'] = strtolower($survey_code); $_SESSION['start_time'] = time(); unset($_SESSION['result_id']); unset($_SESSION['user_data_id']); $survey_tpl = new Template('widget/survey_body.php'); return new Answer('ok', $survey_tpl->process(array('survey' => $survey, 'not_welcome' => true)), 'html'); } else { $survey_tpl = new Template('widget/not_found.php'); return new Answer('ok', $survey_tpl->process(array()), 'html'); } } catch (Exception $e) { return new Answer('error', $e->getMessage(), 'html'); } }