loadHelper("frontend");
Yii::import('application.libraries.admin.pdf');
$surveyid = (int)($surveyid);
Yii::app()->loadHelper('database');
if (isset($_SESSION['survey_'.$surveyid]['sid']))
{
$surveyid = $_SESSION['survey_'.$surveyid]['sid'];
}
else
{
//die('Invalid survey/session');
}
// Get the survey inforamtion
// Set the language for dispay
if (isset($_SESSION['survey_'.$surveyid]['s_lang']))
{
$language = $_SESSION['survey_'.$surveyid]['s_lang'];
}
elseif(Survey::model()->findByPk($surveyid))// survey exist
{
$language = Survey::model()->findByPk($surveyid)->language;
}
else
{
$surveyid=0;
$language = Yii::app()->getConfig("defaultlang");
}
$clang = SetSurveyLanguage($surveyid, $language);
$thissurvey = getSurveyInfo($surveyid,$language);
//SET THE TEMPLATE DIRECTORY
if (!isset($thissurvey['templatedir']) || !$thissurvey['templatedir'])
{
$thissurvey['templatedir']=Yii::app()->getConfig('defaulttemplate');
}
$thistpl = validateTemplateDir($thissurvey['templatedir']);
//Survey is not finished or don't exist
if (!isset($_SESSION['survey_'.$surveyid]['finished']) || !isset($_SESSION['survey_'.$surveyid]['srid']))
//display "sorry but your session has expired"
{
sendCacheHeaders();
doHeader();
echo templatereplace(file_get_contents(getTemplatePath($thistpl).'/startpage.pstpl'),array(),$redata);
echo "
\n"
."\t".$clang->gT("Error")." \n"
."\t".$clang->gT("We are sorry but your session has expired.")." ".$clang->gT("Either you have been inactive for too long, you have cookies disabled for your browser, or there were problems with your connection.")." \n"
."\t".sprintf($clang->gT("Please contact %s ( %s ) for further assistance."),$siteadminname,$siteadminemail)."\n"
."
\n";
echo templatereplace(file_get_contents(getTemplatePath($thistpl).'/endpage.pstpl'),array(),$redata);
doFooter();
exit;
}
//Fin session time out
$id = $_SESSION['survey_'.$surveyid]['srid']; //I want to see the answers with this id
//Ensure script is not run directly, avoid path disclosure
//if (!isset($rootdir) || isset($_REQUEST['$rootdir'])) {die( "browse - Cannot run this script directly");}
if ($thissurvey['printanswers'] == 'N')
{
die(); //Die quietly if print answers is not permitted
}
//CHECK IF SURVEY IS ACTIVATED AND EXISTS
$surveytable = "{{survey_{$surveyid}}}";
$surveyname = $thissurvey['surveyls_title'];
$anonymized = $thissurvey['anonymized'];
//OK. IF WE GOT THIS FAR, THEN THE SURVEY EXISTS AND IT IS ACTIVE, SO LETS GET TO WORK.
//SHOW HEADER
$printoutput = CHtml::form(array("printanswers/view/surveyid/{$surveyid}/printableexport/pdf"), 'post')
."
".$clang->gT("Survey name (ID):")." $surveyname ($surveyid)
\n";
LimeExpressionManager::StartProcessingPage(true); // means that all variables are on the same page
// Since all data are loaded, and don't need JavaScript, pretend all from Group 1
LimeExpressionManager::StartProcessingGroup(1,($thissurvey['anonymized']!="N"),$surveyid);
$printanswershonorsconditions = Yii::app()->getConfig('printanswershonorsconditions');
$aFullResponseTable = getFullResponseTable($surveyid,$id,$language,$printanswershonorsconditions);
//Get the fieldmap @TODO: do we need to filter out some fields?
unset ($aFullResponseTable['id']);
unset ($aFullResponseTable['token']);
unset ($aFullResponseTable['lastpage']);
unset ($aFullResponseTable['startlanguage']);
unset ($aFullResponseTable['datestamp']);
unset ($aFullResponseTable['startdate']);
$printoutput .= "