+ // {{{ function handler_result() : show the results of the votes to a survey
+ function handler_result($page, $id = -1, $show = 'all')
+ {
+ $id = intval($id);
+ if ($id == -1) {
+ return $this->show_error($page, "Un identifiant de sondage doit être précisé.", 'survey');
+ }
+ $this->load('survey.inc.php');
+ $survey = Survey::retrieveSurvey($id); // retrieves the survey object structure
+ if ($survey == null || !$survey->isValid()) {
+ return $this->show_error($page, "Sondage ".$id." introuvable.", 'survey');
+ } elseif (!$survey->isEnded()) {
+ return $this->show_error($page, "Le sondage ".$survey->getTitle()." n'est pas encore terminé.", 'survey');
+ }
+ if (!$this->check_surveyPerms($page, $survey)) {
+ return PL_DO_AUTH;
+ }
+ if ($show == 'csv') {
+ pl_content_headers("text/csv");
+ header('Content-Disposition: attachment; filename="'.addslashes($survey->getTitle()).'.csv"');
+ echo $survey->toCSV();
+ exit;
+ } else {
+ $page->assign('survey_resultmode', true);
+ $this->show_survey($page, $survey);
+ }
+ }
+ // }}}
+