Exemplo n.º 1
0
 function actionparticipants()
 {
     $surveyid = Yii::app()->request->getQuery('surveyid');
     $langcode = Yii::app()->request->getQuery('langcode');
     $token = Yii::app()->request->getQuery('token');
     Yii::app()->loadHelper('database');
     Yii::app()->loadHelper('sanitize');
     $sLanguageCode = $langcode;
     $iSurveyID = $surveyid;
     $sToken = $token;
     $sToken = sanitize_token($sToken);
     if (!$iSurveyID) {
         $this->redirect(Yii::app()->getController()->createUrl('/'));
     }
     $iSurveyID = (int) $iSurveyID;
     //Make sure it's an integer (protect from SQL injects)
     //Check that there is a SID
     // Get passed language from form, so that we dont lose this!
     if (!isset($sLanguageCode) || $sLanguageCode == "" || !$sLanguageCode) {
         $baselang = Survey::model()->findByPk($iSurveyID)->language;
         Yii::import('application.libraries.Limesurvey_lang', true);
         $clang = new Limesurvey_lang($baselang);
     } else {
         $sLanguageCode = sanitize_languagecode($sLanguageCode);
         Yii::import('application.libraries.Limesurvey_lang', true);
         $clang = new Limesurvey_lang($sLanguageCode);
         $baselang = $sLanguageCode;
     }
     Yii::app()->lang = $clang;
     $thissurvey = getSurveyInfo($iSurveyID, $baselang);
     if ($thissurvey == false || !tableExists("{{tokens_{$iSurveyID}}}")) {
         $html = $clang->gT('This survey does not seem to exist.');
     } else {
         $row = Tokens_dynamic::getEmailStatus($iSurveyID, $sToken);
         $datas = Tokens_dynamic::model($iSurveyID)->find('token = :token', array(":token" => $sToken));
         if ($row == false) {
             $html = $clang->gT('You are not a participant in this survey.');
         } else {
             $usresult = $row['emailstatus'];
             if ($usresult == 'OK') {
                 $usresult = Tokens_dynamic::updateEmailStatus($iSurveyID, $sToken, 'OptOut');
                 $html = $clang->gT('You have been successfully removed from this survey.');
             } else {
                 $html = $clang->gT('You have been already removed from this survey.');
             }
             if (!empty($datas->participant_id) && $datas->participant_id != "") {
                 //Participant also exists in central db
                 $cpdb = Participants::model()->find('participant_id = :participant_id', array(":participant_id" => $datas->participant_id));
                 if ($cpdb->blacklisted == "Y") {
                     $html .= "<br />";
                     $html .= $clang->gt("You have already been removed from the central participants list for this site");
                 } else {
                     $cpdb->blacklisted = 'Y';
                     $cpdb->save();
                     $html .= "<br />";
                     $html .= $clang->gT("You have been removed from the central participants list for this site");
                 }
             }
         }
     }
     //PRINT COMPLETED PAGE
     if (!$thissurvey['templatedir']) {
         $thistpl = getTemplatePath(Yii::app()->getConfig("defaulttemplate"));
     } else {
         $thistpl = getTemplatePath($thissurvey['templatedir']);
     }
     $this->_renderHtml($html, $thistpl);
 }
 private function getOldAnswerTable($iQid, $sType, $sLang)
 {
     $sOldLanguage = App()->session['adminlang'];
     App()->setLanguage($sLang);
     $clang = new Limesurvey_lang($sLang, true);
     $this->sLanguage = $sLang;
     $htmlOldAnswersTable = "";
     $oldSchema = $this->oldSchema;
     $oldField = $this->getOldField($oldSchema, $iQid);
     if ($oldField && $oldField->name) {
         $aOldAnswers = $this->getOldAnswersInfo($iQid, $sType, $oldField->name);
         $iTotalValue = 0;
         foreach ($aOldAnswers as $aOldAnswer) {
             if ($aOldAnswer['assessment_value'] != 0) {
                 $iTotalValue += $aOldAnswer['count'];
             }
         }
         if ($iTotalValue > 0) {
             $htmlOldAnswersTable = "<table class='kce-table'><thead><tr><td></td>";
             $htmlOldAnswersTable .= CHtml::tag('th', array(), $clang->gt('Count'));
             $htmlOldAnswersTable .= CHtml::tag('th', array(), '%');
             $htmlOldAnswersTable .= "</tr></thead><tbody>";
             foreach ($aOldAnswers as $aOldAnswer) {
                 if ($aOldAnswer['assessment_value'] != 0) {
                     $htmlOldAnswersTable .= "<tr>";
                     $htmlOldAnswersTable .= CHtml::tag('th', array(), $aOldAnswer['answer']);
                     $htmlOldAnswersTable .= CHtml::tag('td', array(), $aOldAnswer['count']);
                     $sPercentage = $iTotalValue > 0 ? number_format($aOldAnswer['count'] / $iTotalValue * 100) . "%" : "/";
                     $htmlOldAnswersTable .= CHtml::tag('td', array(), $sPercentage);
                     $htmlOldAnswersTable .= "</tr>";
                 }
             }
             $htmlOldAnswersTable .= "<tr>";
             $htmlOldAnswersTable .= CHtml::tag('th', array(), $clang->gt('Total'));
             $htmlOldAnswersTable .= CHtml::tag('td', array(), $iTotalValue);
             $htmlOldAnswersTable .= CHtml::tag('td', array(), "100%");
             $htmlOldAnswersTable .= "</tr>";
             $htmlOldAnswersTable .= "</tbody></table>";
         }
     }
     App()->setLanguage(App()->session['adminlang']);
     $this->setBaseLanguage();
     $clang = new Limesurvey_lang(App()->session['adminlang']);
     return $htmlOldAnswersTable;
 }