Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix for installation dependent import issues
- Sometimes likelihood array would contain empty string
- Loop construct chosesn would end the loop too early
- Made the code more robust
  • Loading branch information
torinfo committed Jul 15, 2015
1 parent 583b6f8 commit fe6c9bb
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions website_code/php/import/import.php
Expand Up @@ -36,8 +36,6 @@
include "../file_library.php";
include "../template_status.php";

ini_set('memory_limit','64M');

$likelihood_array = array();
$delete_folder_array = array();
$delete_file_array = array();
Expand Down Expand Up @@ -325,7 +323,9 @@ function folder_loop($path){
$template_check = simplexml_load_file($path . $f);
if ($template_check->getName() == "learningObject") {
$folder = (string)$template_check['targetFolder'];
array_push($likelihood_array, $folder);
if ($folder != "") {
array_push($likelihood_array, $folder);
}
}
}
}
Expand Down Expand Up @@ -483,13 +483,15 @@ function folder_loop($path){

if($file_to_create[2]=="media"){

$fp = fopen($xerte_toolkits_site->import_path . $this_dir . $file_to_create[0],"w");
if ($file_to_create[0] != "") {
$fp = fopen($xerte_toolkits_site->import_path . $this_dir . $file_to_create[0], "w");

fwrite($fp,$file_to_create[1]);
fwrite($fp, $file_to_create[1]);

fclose($fp);
fclose($fp);

chmod($xerte_toolkits_site->import_path . $this_dir . $file_to_create[0],0777);
chmod($xerte_toolkits_site->import_path . $this_dir . $file_to_create[0], 0777);
}

}else if($file_to_create[2]=="rlt"){

Expand Down Expand Up @@ -561,6 +563,7 @@ function folder_loop($path){
if ($folder=="" && $data_xml_is_a_LO) {
$folder = "Nottingham";
}
_debug("Import: folder found is " . $folder);

if(!empty($_POST['replace'])){

Expand Down Expand Up @@ -591,7 +594,8 @@ function folder_loop($path){

$template_found = false;

while($template = array_pop($likelihood_array)){
foreach($likelihood_array as $template){
_debug("Import: checking template (" . $template . ")");
if($folder==$template){

$template_found=true;
Expand Down Expand Up @@ -637,8 +641,8 @@ function folder_loop($path){

$template_found = false;

while($template = array_pop($likelihood_array)){

foreach($likelihood_array as $template) {
_debug("Import: checking template (" . $template . ")");
if($folder==$template){

$template_found=true;
Expand All @@ -647,7 +651,7 @@ function folder_loop($path){
}

}

_debug("Import: template_found=" . $template_found);
if($template_found){

/*
Expand Down

0 comments on commit fe6c9bb

Please sign in to comment.