Skip to content

Commit

Permalink
Fixed issue #6393: Multilingual attributes are lost when copying or i…
Browse files Browse the repository at this point in the history
…mporting survey
  • Loading branch information
c-schmitz committed Jul 26, 2012
1 parent e31ce9a commit 90b60d6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 32 deletions.
51 changes: 20 additions & 31 deletions application/helpers/export_helper.php
Expand Up @@ -619,14 +619,14 @@ function surveyGetXMLStructure($iSurveyID, $xmlwriter, $exclude=array())
$platform = Yii::app()->db->getDriverName();
if ($platform == 'mssql' || $platform =='sqlsrv')
{
$query="SELECT qa.qid, qa.attribute, cast(qa.value as varchar(4000)) as value
$query="SELECT qa.qid, qa.attribute, cast(qa.value as varchar(4000)) as value, qa.language
FROM {{question_attributes}} qa JOIN {{questions}} q ON q.qid = qa.qid AND q.sid={$iSurveyID}
where q.language='{$sBaseLanguage}' group by qa.qid, qa.attribute, cast(qa.value as varchar(4000))";
where q.language='{$sBaseLanguage}' group by qa.qid, qa.attribute, cast(qa.value as varchar(4000)), qa.language";
}
else {
$query="SELECT qa.qid, qa.attribute, qa.value
$query="SELECT qa.qid, qa.attribute, qa.value, qa.language
FROM {{question_attributes}} qa JOIN {{questions}} q ON q.qid = qa.qid AND q.sid={$iSurveyID}
where q.language='{$sBaseLanguage}' group by qa.qid, qa.attribute, qa.value";
where q.language='{$sBaseLanguage}' group by qa.qid, qa.attribute, qa.value, qa.language";
}

buildXMLFromQuery($xmlwriter,$query,'question_attributes');
Expand Down Expand Up @@ -1671,14 +1671,14 @@ function groupGetXMLStructure($xml,$gid)
$platform = Yii::app()->db->getDriverName();
if ($platform == 'mssql' || $platform =='sqlsrv')
{
$query="SELECT qa.qid, qa.attribute, cast(qa.value as varchar(4000)) as value
$query="SELECT qa.qid, qa.attribute, cast(qa.value as varchar(4000)) as value, qa.language
FROM {{question_attributes}} qa JOIN {{questions}} q ON q.qid = qa.qid AND q.sid={$iSurveyID} and q.gid={$gid}
where q.language='{$sBaseLanguage}' group by qa.qid, qa.attribute, cast(qa.value as varchar(4000))";
where q.language='{$sBaseLanguage}' group by qa.qid, qa.attribute, cast(qa.value as varchar(4000)), qa.language";
}
else {
$query="SELECT qa.qid, qa.attribute, qa.value
$query="SELECT qa.qid, qa.attribute, qa.value, qa.language
FROM {{question_attributes}} qa JOIN {{questions}} q ON q.qid = qa.qid AND q.sid={$iSurveyID} and q.gid={$gid}
where q.language='{$sBaseLanguage}' group by qa.qid, qa.attribute, qa.value";
where q.language='{$sBaseLanguage}' group by qa.qid, qa.attribute, qa.value, qa.language";
}
buildXMLFromQuery($xml,$query,'question_attributes');

Expand All @@ -1704,25 +1704,14 @@ function questionExport($action, $iSurveyID, $gid, $qid)
$fn = "limesurvey_question_$qid.lsq";
$xml = getXMLWriter();

if($action=='exportstructureLsrcCsvQuestion')
{
include_once(APPPATH.'/remotecontrol/lsrc.config.php');
//Select title as Filename and save
$question = Questions::model()->findByAttributes(array('sid' => $iSurveyID, 'gid' => $gid, 'qid' => $qid));
$questionTitle = $question->title;
$xml->openURI('remotecontrol/'.$queDir.substr($questionTitle,0,20).".lsq");
}
else
{
header("Content-Type: text/html/force-download");
header("Content-Disposition: attachment; filename=$fn");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: cache");
// HTTP/1.0
$xml->openURI('php://output');
}
header("Content-Type: text/html/force-download");
header("Content-Disposition: attachment; filename=$fn");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: cache");
// HTTP/1.0
$xml->openURI('php://output');

$xml->setIndent(true);
$xml->startDocument('1.0', 'UTF-8');
Expand Down Expand Up @@ -1772,14 +1761,14 @@ function questionGetXMLStructure($xml,$gid,$qid)
$platform = Yii::app()->db->getDriverName();
if ($platform == 'mssql' || $platform =='sqlsrv')
{
$query="SELECT qa.qid, qa.attribute, cast(qa.value as varchar(4000)) as value
$query="SELECT qa.qid, qa.attribute, cast(qa.value as varchar(4000)) as value, qa.language
FROM {{question_attributes}} qa JOIN {{questions}} q ON q.qid = qa.qid AND q.sid={$iSurveyID} and q.qid={$qid}
where q.language='{$sBaseLanguage}' group by qa.qid, qa.attribute, cast(qa.value as varchar(4000))";
where q.language='{$sBaseLanguage}' group by qa.qid, qa.attribute, cast(qa.value as varchar(4000)), qa.language";
}
else {
$query="SELECT qa.qid, qa.attribute, qa.value
$query="SELECT qa.qid, qa.attribute, qa.value, qa.language
FROM {{question_attributes}} qa JOIN {{questions}} q ON q.qid = qa.qid AND q.sid={$iSurveyID} and q.qid={$qid}
where q.language='{$sBaseLanguage}' group by qa.qid, qa.attribute, qa.value";
where q.language='{$sBaseLanguage}' group by qa.qid, qa.attribute, qa.value, qa.language";
}
buildXMLFromQuery($xml,$query);

Expand Down
2 changes: 1 addition & 1 deletion application/views/admin/survey/Question/import_view.php
Expand Up @@ -20,5 +20,5 @@
<li><?php echo $clang->gT("Question attributes:") . $aImportResults['question_attributes'] ?></li>
</ul>
<strong><?php $clang->eT("Question import is complete.") ?></strong><br />
<input type='submit' value='<?php $clang->eT("Go to question") ?>' onclick="window.open('<?php echo $this->getController()->createUrl('admin/survey/view/surveyid/' . $surveyid . '/gid/' . $gid . '/qid/' . $aImportResults['newqid']) ?>', '_top')" />
<input type='submit' value='<?php $clang->eT("Go to question") ?>' onclick="window.open('<?php echo $this->createUrl('admin/survey/view/surveyid/' . $surveyid . '/gid/' . $gid . '/qid/' . $aImportResults['newqid']) ?>', '_top')" />
</div>

0 comments on commit 90b60d6

Please sign in to comment.