Skip to content

Commit

Permalink
Fixed #7075: browse results bug with upload type question (display fe…
Browse files Browse the repository at this point in the history
…w answer and no download)
  • Loading branch information
mennodekker committed Jan 11, 2013
1 parent c98b760 commit 5a95552
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
16 changes: 7 additions & 9 deletions application/controllers/admin/responses.php
Expand Up @@ -259,7 +259,7 @@ public function view($iSurveyID, $iId, $sBrowseLang = '')
if ($metadata === "size")
$answervalue = rawurldecode(((int) ($phparray[$index][$metadata])) . " KB");
else if ($metadata === "name")
$answervalue = CHtml::link(rawurldecode($phparray[$index][$metadata]), $this->getController()->createUrl("/admin/responses/sa/index/downloadindividualfile/{$phparray[$index][$metadata]}/fieldname/{$fn[0]}/id/{$iId}/surveyid/{$iSurveyID}"));
$answervalue = CHtml::link(rawurldecode($phparray[$index][$metadata]), $this->getController()->createUrl("/admin/responses/sa/browse/downloadindividualfile/{$phparray[$index][$metadata]}/fieldname/{$fn[0]}/id/{$iId}/surveyid/{$iSurveyID}"));
else
$answervalue = rawurldecode($phparray[$index][$metadata]);
}
Expand Down Expand Up @@ -376,11 +376,11 @@ function browse($iSurveyID)
$zipfilename = "Files_for_responses_" . Yii::app()->request->getPost('downloadfile') . ".zip";
$this->_zipFiles($iSurveyID, Yii::app()->request->getPost('downloadfile'), $zipfilename,$aData['language']);
}
else if (Yii::app()->request->getPost('downloadindividualfile') != '')
else if (Yii::app()->request->getParam('downloadindividualfile') != '')
{
$iId = (int) Yii::app()->request->getPost('id');
$downloadindividualfile = Yii::app()->request->getPost('downloadindividualfile');
$fieldname = Yii::app()->request->getPost('fieldname');
$iId = (int) Yii::app()->request->getParam('id');
$downloadindividualfile = Yii::app()->request->getParam('downloadindividualfile');
$fieldname = Yii::app()->request->getParam('fieldname');

$oRow = Survey_dynamic::model($iSurveyID)->findByAttributes(array('id' => $iId));
$phparray = json_decode_ls($oRow->$fieldname);
Expand All @@ -393,6 +393,7 @@ function browse($iSurveyID)

if (file_exists($file))
{
@ob_clean();
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . rawurldecode($php->name) . '"');
Expand All @@ -401,8 +402,6 @@ function browse($iSurveyID)
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
Expand Down Expand Up @@ -849,6 +848,7 @@ private function _zipFiles($iSurveyID, $responseIds, $zipfilename,$language)

if (file_exists($tmpdir . '/' . $zipfilename))
{
@ob_clean();
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . basename($zipfilename));
Expand All @@ -857,8 +857,6 @@ private function _zipFiles($iSurveyID, $responseIds, $zipfilename,$language)
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($tmpdir . "/" . $zipfilename));
ob_clean();
flush();
readfile($tmpdir . '/' . $zipfilename);
unlink($tmpdir . '/' . $zipfilename);
exit;
Expand Down
11 changes: 6 additions & 5 deletions application/helpers/common_helper.php
Expand Up @@ -6449,12 +6449,13 @@ function json_decode_ls($jsonString)
{
$decoded = json_decode($jsonString, true);

if (json_last_error() === JSON_ERROR_SYNTAX) {
// probably we need stipslahes
$decoded = json_decode(stripslashes($jsonString), true);
}
if (is_null($decoded) && !empty($jsonString))
{
// probably we need stipslahes
$decoded = json_decode(stripslashes($jsonString), true);
}

return $decoded;
return $decoded;
}

/**
Expand Down

0 comments on commit 5a95552

Please sign in to comment.