Skip to content

Commit

Permalink
Fixed issue #8894: Error when importing an invalid file
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Mar 24, 2014
1 parent 29c994b commit dfd813a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
11 changes: 7 additions & 4 deletions application/controllers/admin/participantsaction.php
Expand Up @@ -1100,10 +1100,13 @@ function attributeMapCSV()
}
else
{
$templateData['error_msg'] = sprintf($clang->gT("This is not a .csv file."), Yii::app()->getConfig('tempdir'));
$errorinupload = array('error' => $this->upload->display_errors());
Yii::app()->session['summary'] = array('errorinupload' => $errorinupload);
$this->_renderWrappedTemplate('participants', array('participantsPanel', 'uploadSummary'),array('aAttributes' => ParticipantAttributeName::model()->getAllAttributes()));
$templateData['errorinupload']['error'] = $clang->gT("This is not a .csv file.");
$templateData['aAttributes'] = ParticipantAttributeName::model()->getAllAttributes();
$templateData['aGlobalErrors'] = array();
// $errorinupload = array('error' => $this->upload->display_errors());
// Yii::app()->session['summary'] = array('errorinupload' => $errorinupload);
$this->_renderWrappedTemplate('participants', array('participantsPanel', 'uploadSummary'),$templateData);
exit;
}


Expand Down
8 changes: 6 additions & 2 deletions application/controllers/admin/surveyadmin.php
Expand Up @@ -923,7 +923,11 @@ public function copy()
if ($action == 'importsurvey' && !$aData['bFailed'])
{
$aImportResults=importSurveyFile($sFullFilepath,(isset($_POST['translinksfields'])));
if (is_null($aImportResults)) $importerror = true;
if (is_null($aImportResults) || isset($aImportResults['error']))
{
$aData['sErrorMessage']=$aImportResults['error'];
$aData['bFailed'] = true;
}
}
elseif ($action == 'copysurvey' && !$aData['bFailed'])
{
Expand All @@ -940,7 +944,7 @@ public function copy()
}
else
{
$importerror = true;
$aData['bFailed'] = true;
}
if ($action == 'importsurvey' && isset($sFullFilepath))
{
Expand Down
4 changes: 2 additions & 2 deletions application/helpers/admin/import_helper.php
Expand Up @@ -3511,9 +3511,9 @@ function XMLImportSurvey($sFullFilePath,$sXMLdata=NULL,$sNewSurveyName=NULL,$iDe
{
$sXMLdata = file_get_contents($sFullFilePath);
}
$xml = simplexml_load_string($sXMLdata,'SimpleXMLElement',LIBXML_NONET);
$xml = @simplexml_load_string($sXMLdata,'SimpleXMLElement',LIBXML_NONET);

if ($xml->LimeSurveyDocType!='Survey')
if (!$xml || $xml->LimeSurveyDocType!='Survey')
{
$results['error'] = $clang->gT("This is not a valid LimeSurvey survey structure XML file.");
return $results;
Expand Down
6 changes: 3 additions & 3 deletions application/views/admin/participants/uploadSummary_view.php
Expand Up @@ -77,13 +77,13 @@
$uploadSummary .= "</ul></div></li>";
}
}
$uploadSummary .= "</div></div>";
}
else
{
echo $errorinupload['error'];
$uploadSummary .= "<div class='warningheader'>" . $errorinupload['error'] . "</div>";
$uploadSummary .= "<div class='warningheader'>" . $clang->gT('Error') . "</div>";
$uploadSummary .= $errorinupload['error'];
}
foreach($aGlobalErrors as $sGlobalError)
echo "<script> \$notifycontainer.notify('create', 'error-notify', { message:'{$sGlobalError}'});</script>";
$uploadSummary .= "</div></div>";
echo $uploadSummary;

0 comments on commit dfd813a

Please sign in to comment.