Skip to content

Commit

Permalink
Fixed issue #4979: Problem when transferring survey with embedded pic…
Browse files Browse the repository at this point in the history
…tures from system A to system B.

Fixed issue: linkes in URL containing uploaded images were not translated at import time.
Fixed issue: the 'Convert resource links and INSERTANS fields?' test was reversed

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_dev@9863 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
Thibault Le Meur committed Mar 8, 2011
1 parent 900ac63 commit 5f13c1b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions admin/import_functions.php
Expand Up @@ -1338,6 +1338,7 @@ function XMLImportSurvey($sFullFilepath,$sXMLdata=NULL,$sNewSurveyName=NULL,$iDe
$insertdata['qid']=$aQIDReplacements[(int)$insertdata['qid']]; // remap the parent_qid

// now translate any links
$insertdata['answer']=translink('survey', $oldsid, $newsid, $insertdata['answer']);
$query=$connect->GetInsertSQL($tablename,$insertdata);
$result=$connect->Execute($query) or safe_die ($clang->gT("Error").": Failed to insert data<br />{$query}<br />\n".$connect->ErrorMsg());
$results['answers']++;
Expand Down
11 changes: 6 additions & 5 deletions common_functions.php
Expand Up @@ -6701,21 +6701,22 @@ function getNextCode($sourcecode)
*/
function translink($type, $oldid, $newid, $text)
{
if (isset($_POST['translinksfields']))
global $relativeurl;
if (!isset($_POST['translinksfields']))
{
return $text;
}

if ($type == 'survey')
{
$pattern = "upload/surveys/$oldid/";
$replace = "upload/surveys/$newid/";
$pattern = "([^'\"]*)/upload/surveys/$oldid/";
$replace = "$relativeurl/upload/surveys/$newid/";
return preg_replace('#'.$pattern.'#', $replace, $text);
}
elseif ($type == 'label')
{
$pattern = "upload/labels/$oldid/";
$replace = "upload/labels/$newid/";
$pattern = "([^'\"]*)/upload/labels/$oldid/";
$replace = "$relativeurl/upload/labels/$newid/";
return preg_replace('#'.$pattern.'#', $replace, $text);
}
else
Expand Down

0 comments on commit 5f13c1b

Please sign in to comment.