FPDF do not support UTF-8 => utf8_decode all data
[platal.git] / modules / survey.php
index 1051117..bf9bb4a 100644 (file)
@@ -92,7 +92,7 @@ class SurveyModule extends PLModule
     // }}}
 
     // {{{ function handler_result() : show the results of the votes to a survey
-    function handler_result($page, $id = -1, $qid = 'all')
+    function handler_result($page, $id = -1, $show = 'all')
     {
         $id = intval($id);
         if ($id == -1) {
@@ -108,8 +108,14 @@ class SurveyModule extends PLModule
         if (!$this->check_surveyPerms($page, $survey)) {
             return;
         }
-        $page->assign('survey_resultmode', true);
-        $this->show_survey($page, $survey);
+        if ($show == 'csv') {
+            header('Content-Type: text/csv; charset="UTF-8"');
+            echo $survey->toCSV();
+            exit;
+        } else {
+            $page->assign('survey_resultmode', true);
+            $this->show_survey($page, $survey);
+        }
     }
     // }}}
 
@@ -125,6 +131,7 @@ class SurveyModule extends PLModule
             $page->assign('survey_old', Survey::retrieveList('o'));
             $page->assign('survey_modes', Survey::getModes(false));
         } else {
+            $id = intval($id);
             $survey = Survey::retrieveSurvey($id); // retrieves all survey object structure
             if ($survey == null) {
                 $this->show_error($page, "Sondage ".$id." introuvable.", 'admin');
@@ -141,6 +148,7 @@ class SurveyModule extends PLModule
         if ($id == -1) {
             return $this->show_error($page, "Un identifiant de sondage doit être précisé.", 'admin');
         }
+        $id = intval($id);
         require_once dirname(__FILE__).'/survey/survey.inc.php';
         $survey = Survey::retrieveSurvey($id); // retrieves the survey in database
         $this->clear_session(); // cleans session (in case there would have been a problem before)
@@ -160,6 +168,7 @@ class SurveyModule extends PLModule
         if ($id == -1) {
             return $this->show_error($page, "Un identifiant de sondage doit être précisé.", 'admin');
         }
+        $id = intval($id);
         require_once dirname(__FILE__).'/survey/survey.inc.php';
         $surveyInfo = Survey::retrieveSurveyInfo($id); // retrieves information about the survey (does not retrieve and unserialize the object structure)
         if ($surveyInfo == null) {
@@ -188,6 +197,7 @@ class SurveyModule extends PLModule
         if ($id == -1) {
             return $this->show_error($page, "Un identifiant de sondage doit être précisé.", 'admin');
         }
+        $id = intval($id);
         require_once dirname(__FILE__).'/survey/survey.inc.php';
         $surveyInfo = Survey::retrieveSurveyInfo($id); // retrieves information about the survey (does not retrieve and unserialize the object structure)
         if ($surveyInfo == null) {