Skip to content

Commit

Permalink
Fixed issue #13420: Wrong file downloaded from "View Response ID" page
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Feb 27, 2018
1 parent e6d1151 commit 9e19a28
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion application/controllers/admin/responses.php
Expand Up @@ -281,6 +281,7 @@ public function view($iSurveyID, $iId, $sBrowseLang = '')
$answervalue = "Y";
}
} else {
// File upload question type.
if (isset($fnames[$i]['type']) && $fnames[$i]['type'] == "|") {
$index = $fnames[$i]['index'];
$metadata = $fnames[$i]['metadata'];
Expand All @@ -302,7 +303,7 @@ public function view($iSurveyID, $iId, $sBrowseLang = '')
}
$aData['bHasFile'] = true;
} else {
$answervalue = "";
$answervalue = "";
}
} else {
$answervalue = htmlspecialchars(strip_tags(stripJavaScript(getExtendedAnswer($iSurveyID, $fnames[$i][0], $iIdrow[$fnames[$i][0]], $sBrowseLanguage))), ENT_QUOTES);
Expand Down
13 changes: 11 additions & 2 deletions application/models/Response.php
Expand Up @@ -39,12 +39,21 @@ public static function create($surveyId, $scenario = 'insert')
/**
* Get all files related to this response and (optionally) question ID.
*
* @param int $qid
* @return array
*/
public function getFiles()
public function getFiles($qid = null)
{
$survey = Survey::model()->findByPk($this->dynamicId);
$questions = Question::model()->findAllByAttributes(array('sid' => $this->dynamicId, 'type' => '|', 'language'=>$survey->language));
$conditions = [
'sid' => $this->dynamicId,
'type' => '|',
'language'=>$survey->language
];
if ($qid !== null) {
$conditions['qid'] = $qid;
}
$questions = Question::model()->findAllByAttributes($conditions);
$files = array();
foreach ($questions as $question) {
$field = $question->sid.'X'.$question->gid.'X'.$question->qid;
Expand Down

0 comments on commit 9e19a28

Please sign in to comment.