Index: restorelib.php =================================================================== --- restorelib.php (revision 336) +++ restorelib.php (working copy) @@ -7604,15 +7604,28 @@ //Now check for the moodle.xml file if ($status) { - $xml_file = $CFG->dataroot."/temp/backup/".$backup_unique_code."/moodle.xml"; + $xml_file = $CFG->dataroot."/temp/backup/".$backup_unique_code."/moodle.xml"; if (!defined('RESTORE_SILENTLY')) { echo "
  • ".get_string("checkingbackup").'
  • '; } if (! $status = restore_check_moodle_file ($xml_file)) { if (!is_file($xml_file)) { - $errorstr = 'Error checking backup file. moodle.xml not found at root level of zip file.'; + + // ADDED 20100909 - CSW added the base folder name (same name as the zip) to the xml + // file path if the initial attempt didn't find anything. Also added the second level + // of file checks of the modified $xml_file + $orig_xml_file = $xml_file; + $xml_file = $CFG->dataroot."/temp/backup/".$backup_unique_code."/".preg_replace('/\\.zip/','',basename($file))."/moodle.xml"; + if (! $status = restore_check_moodle_file ($xml_file)) { + if (!is_file($xml_file)) { + $errorstr = 'Error checking backup file. moodle.xml not found at root level of zip file. ' + ."Looked for $xml_file and $orig_xml_file."; + } else { + $errorstr = "Error checking backup file. $xml_file is incorrect or corrupted."; + } + } } else { - $errorstr = 'Error checking backup file. moodle.xml is incorrect or corrupted.'; + $errorstr = "Error checking backup file. $xml_file is incorrect or corrupted."; } if (!defined('RESTORE_SILENTLY')) { notify($errorstr); @@ -7803,6 +7816,11 @@ //Location of the xml file $xml_file = $CFG->dataroot."/temp/backup/".$restore->backup_unique_code."/moodle.xml"; + // ADDED 20100909 - CSW - more checking for the moodle xml file - again, check in the sub-folder named for the zip file + if (! is_file($xml_file)) + { + $xml_file = $CFG->dataroot."/temp/backup/".$restore->backup_unique_code.'/'.preg_replace('/\\.zip/','',basename($restore->file))."/moodle.xml"; + } //Preprocess the moodle.xml file spliting into smaller chucks (modules, users, logs...) //for optimal parsing later in the restore process.