Skip to content

Commit

Permalink
Fixed issue #8501: Problem with importing a survey archive
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Jan 17, 2014
1 parent 521095a commit 75ed6ed
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions application/helpers/admin/import_helper.php
Expand Up @@ -3364,7 +3364,8 @@ function importSurveyFile($sFullFilepath, $bTranslateLinksFields, $sNewSurveyNam
$aTokenCreateResults = array('tokentablecreated' => true);
$aImportResults = array_merge($aTokenCreateResults, $aImportResults);
$aTokenImportResults = XMLImportTokens(Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . $aFile['filename'], $aImportResults['newsid']);
$aImportResults = array_merge($aTokenImportResults, $aImportResults);
$aImportResults = array_merge_recursive($aTokenImportResults, $aImportResults);
$aImportResults['importwarnings']=array_merge($aImportResults['importwarnings'],$aImportResults['warnings']);
unlink(Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . $aFile['filename']);
break;
}
Expand Down Expand Up @@ -4133,7 +4134,7 @@ function XMLImportTokens($sFullFilepath,$iSurveyID,$sCreateMissingAttributeField
Yii::app()->loadHelper('database');
$clang = Yii::app()->lang;
$xml = simplexml_load_file($sFullFilepath);

$results['warnings']=array();
if ($xml->LimeSurveyDocType!='Tokens')
{
$results['error'] = $clang->gT("This is not a valid token data XML file.");
Expand Down Expand Up @@ -4191,8 +4192,10 @@ function XMLImportTokens($sFullFilepath,$iSurveyID,$sCreateMissingAttributeField

$token = Token::create($iSurveyID);
$token->setAttributes($insertdata, false);
$result = $token->save() or safeDie($clang->gT("Error").": " . print_r($token->errors, true));

if (!$token->save())
{
$results['warnings'][]=$clang->gT("Skipped tokens entry:").' '. implode('. ',$token->errors['token']);
};
$results['tokens']++;
}
switchMSSQLIdentityInsert('tokens_'.$iSurveyID,false);
Expand Down

0 comments on commit 75ed6ed

Please sign in to comment.