Skip to content

Commit

Permalink
fix for issue #10 - add support for complex IDNo
Browse files Browse the repository at this point in the history
  • Loading branch information
mah0001 committed May 11, 2019
1 parent ec331bd commit a76635d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions application/libraries/DDI2_import.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,14 @@ public function import($params,$sid=null)
throw new Exception(t('Required IDNo element is not set in the DDI xml file. Fix the DDI and set the codeBook/@ID and/or stdyDscr/citation/titlStmt/IDNo element.'));
}

if(trim($idno)==''){
throw new Exception('CODEBOOK_IDNO_MISSING');
}

//sanitize ID to remove anything except a-Z1-9 characters
if ($idno!==$this->sanitize_filename($idno)){
/*if ($idno!==$this->sanitize_filename($idno)){
throw new Exception(t('IDNO_INVALID_FORMAT').': '.$idno);
}
}*/

//check if the study already exists, find the sid
if (!$sid){
Expand All @@ -117,7 +121,7 @@ public function import($params,$sid=null)
}

$repositoryid=$this->repositoryid;
$ddi_filename=$idno.".xml";
$ddi_filename=$this->sanitize_filename($idno).".xml";

//generate survey folder name hash
$survey_folder_hash=md5($repositoryid.':'.$idno);
Expand All @@ -129,7 +133,7 @@ public function import($params,$sid=null)
$survey_folder_rel_path=$repositoryid.'/'.$survey_folder_hash;

//target file path
$survey_target_filepath=unix_path($survey_folder_path.'/'.$idno.'.xml');
$survey_target_filepath=unix_path($survey_folder_path.'/'.$ddi_filename);

//copy the xml file to the survey folder - skip copying if source and target are the same (e.g. for ddi refresh)
if($this->file_path!==$survey_target_filepath){
Expand Down

0 comments on commit a76635d

Please sign in to comment.