diff --git a/backup/lib.php b/backup/lib.php index af002b420f2..860fe4516d4 100644 --- a/backup/lib.php +++ b/backup/lib.php @@ -497,17 +497,25 @@ //This function is used to check that every necessary function to //backup/restore exists in the current php installation. Thanks to //gregb@crowncollege.edu by the idea. - function backup_required_functions() { + function backup_required_functions($justcheck=false) { if(!function_exists('utf8_encode')) { - error('You need to add XML support to your PHP installation'); + if (empty($justcheck)) { + error('You need to add XML support to your PHP installation'); + } else { + return false; + } } + return true; } //This function send n white characters to the browser and flush the //output buffer. Used to avoid browser timeouts and to show the progress. function backup_flush($n=0,$time=false) { + if (defined('RESTORE_SILENTLY_NOFLUSH')) { + return; + } if ($time) { $ti = strftime("%X",time()); } else { @@ -543,4 +551,108 @@ return ($status && $status2); } + + /** this function will restore an entire backup.zip into the specified course + * using standard moodle backup/restore functions, but silently. + * @param string $pathtofile the absolute path to the backup file. + * @param int $destinationcourse the course id to restore to. + * @param boolean $emptyfirst whether to delete all coursedata first. + * @param boolean $userdata whether to include any userdata that may be in the backup file. + */ + function import_backup_file_silently($pathtofile,$destinationcourse,$emptyfirst=false,$userdata=false) { + global $CFG,$SESSION,$USER; // is there such a thing on cron? I guess so.. + + if (empty($USER)) { + $USER = get_admin(); + $USER->admin = 1; // not sure why, but this doesn't get set + } + + define('RESTORE_SILENTLY',true); // don't output all the stuff to us. + + $debuginfo = 'import_backup_file_silently: '; + $cleanupafter = false; + $errorstr = ''; // passed by reference to restore_precheck to get errors from. + + if (!$course = get_record('course','id',$destinationcourse)) { + mtrace($debuginfo.'Course with id $destinationcourse was not a valid course!'); + return false; + } + + // first check we have a valid file. + if (!file_exists($pathtofile) || !is_readable($pathtofile)) { + mtrace($debuginfo.'File '.$pathtofile.' either didn\'t exist or wasn\'t readable'); + return false; + } + + // now make sure it's a zip file + require_once($CFG->dirroot.'/lib/filelib.php'); + $filename = substr($pathtofile,strrpos($pathtofile,'/')+1); + $mimetype = mimeinfo("type", $filename); + if ($mimetype != 'application/zip') { + mtrace($debuginfo.'File '.$pathtofile.' was of wrong mimetype ('.$mimetype.')' ); + return false; + } + + // restore_precheck wants this within dataroot, so lets put it there if it's not already.. + if (strstr($pathtofile,$CFG->dataroot) === false) { + // first try and actually move it.. + if (!check_dir_exists($CFG->dataroot.'/temp/backup/',true)) { + mtrace($debuginfo.'File '.$pathtofile.' outside of dataroot and couldn\'t move it! '); + return false; + } + if (!copy($pathtofile,$CFG->dataroot.'/temp/backup/'.$filename)) { + mtrace($debuginfo.'File '.$pathtofile.' outside of dataroot and couldn\'t move it! '); + return false; + } else { + $pathtofile = 'temp/backup/'.$filename; + $cleanupafter = true; + } + } else { + // it is within dataroot, so take it off the path for restore_precheck. + $pathtofile = substr($pathtofile,strlen($CFG->dataroot.'/')); + } + + if (!backup_required_functions()) { + mtrace($debuginfo.'Required function check failed (see backup_required_functions)'); + return false; + } + + @ini_set("max_execution_time","3000"); + raise_memory_limit("128M"); + + if (!$backup_unique_code = restore_precheck($destinationcourse,$pathtofile,$errorstr,true)) { + mtrace($debuginfo.'Failed restore_precheck (error was '.$errorstr.')'); + return false; + } + + restore_setup_for_check($SESSION->restore,$backup_unique_code); + + // add on some extra stuff we need... + $SESSION->restore->restoreto = 1; + $SESSION->restore->course_id = $destinationcourse; + $SESSION->restore->deleting = $emptyfirst; + + // maybe we need users (defaults to 2 in restore_setup_for_check) + if (!empty($userdata)) { + $SESSION->restore->users = 1; + } + + // we also need modules... + if ($allmods = get_records("modules")) { + foreach ($allmods as $mod) { + $modname = $mod->name; + //Now check that we have that module info in the backup file + if (isset($SESSION->info->mods[$modname]) && $SESSION->info->mods[$modname]->backup == "true") { + $SESSION->restore->mods[$modname]->restore = true; + $SESSION->restore->mods[$modname]->userinfo = $userdata; + } + } + } + if (!restore_execute($SESSION->restore,$SESSION->info,$SESSION->course_header,$errorstr)) { + mtrace($debuginfo.'Failed restore_execute (error was '.$errorstr.')'); + return false; + } + return true; + } + ?> diff --git a/backup/restore_execute.html b/backup/restore_execute.html index 2faeb97b675..d5893fc28fe 100644 --- a/backup/restore_execute.html +++ b/backup/restore_execute.html @@ -41,350 +41,8 @@ if (!$site = get_site()) { error("Site not found!"); } - - //Checks for the required files/functions to restore every module - //and include them - if ($allmods = get_records("modules") ) { - foreach ($allmods as $mod) { - $modname = $mod->name; - $modfile = "$CFG->dirroot/mod/$modname/restorelib.php"; - //If file exists and we have selected to restore that type of module - if ((file_exists($modfile)) and ($restore->mods[$modname]->restore)) { - include_once($modfile); - } - } - } - - //Start the main table - echo ""; - echo ""; - echo "
"; - - //Start the main ul - echo "
    "; - - //Init status - $status = true; - - //Localtion of the xml file - $xml_file = $CFG->dataroot."/temp/backup/".$restore->backup_unique_code."/moodle.xml"; - - //If we've selected to restore into new course - //create it (course) - //Saving conversion id variables into backup_tables - if ($restore->restoreto == 2) { - echo "
  • ".get_string("creatingnewcourse"); - $oldidnumber = $course_header->course_idnumber; - if (!$status = restore_create_new_course($restore,$course_header)) { - notify("Error while creating the new empty course."); - } - //Print course fullname and shortname and category - if ($status) { - echo "
      "; - echo "
    • ".$course_header->course_fullname." (".$course_header->course_shortname.")".'
    • '; - echo "
    • ".get_string("category").": ".$course_header->category->name.'
    • '; - if (!empty($oldidnumber)) { - echo "
    • ".get_string("nomoreidnumber","moodle",$oldidnumber)."
    • "; - } - echo "
  • "; - //Put the destination course_id - $restore->course_id = $course_header->course_id; - } - } else { - $course = get_record("course","id",$restore->course_id); - if ($course) { - echo "
  • ".get_string("usingexistingcourse"); - echo "
      "; - echo "
    • ".get_string("from").": ".$course_header->course_fullname." (".$course_header->course_shortname.")".'
    • '; - echo "
    • ".get_string("to").": ".$course->fullname." (".$course->shortname.")".'
    • '; - if (($restore->deleting)) { - echo "
    • ".get_string("deletingexistingcoursedata").'
    • '; - } else { - echo "
    • ".get_string("addingdatatoexisting").'
    • '; - } - echo "
  • "; - //If we have selected to restore deleting, we do it now. - if ($restore->deleting) { - echo "
  • ".get_string("deletingolddata").'
  • '; - $status = remove_course_contents($restore->course_id,false) and - delete_dir_contents($CFG->dataroot."/".$restore->course_id,"backupdata"); - if ($status) { - //Now , this situation is equivalent to the "restore to new course" one (we - //have a course record and nothing more), so define it as "to new course" - $restore->restoreto = 2; - } else { - notify("An error occurred while deleting some of the course contents."); - } - } - } else { - notify("Error opening existing course."); - $status = false; - } - } - - //Now create the course_sections and their associated course_modules - if ($status) { - //Into new course - if ($restore->restoreto == 2) { - echo "
  • ".get_string("creatingsections").'
  • '; - if (!$status = restore_create_sections($restore,$xml_file)) { - notify("Error creating sections in the existing course."); - } - //Into existing course - } else if ($restore->restoreto == 0 or $restore->restoreto == 1) { - echo "
  • ".get_string("checkingsections").'
  • '; - if (!$status = restore_create_sections($restore,$xml_file)) { - notify("Error creating sections in the existing course."); - } - //Error - } else { - notify("Neither a new course or an existing one was specified."); - $status = false; - } - } - - //Now create users as needed - if ($status and ($restore->users == 0 or $restore->users == 1)) { - echo "
  • ".get_string("creatingusers")."
    "; - if (!$status = restore_create_users($restore,$xml_file)) { - notify("Could not restore users."); - } - //Now print info about the work done - if ($status) { - $recs = get_records_sql("select old_id, new_id from {$CFG->prefix}backup_ids - where backup_code = '$restore->backup_unique_code' and - table_name = 'user'"); - //We've records - if ($recs) { - $new_count = 0; - $exists_count = 0; - $student_count = 0; - $teacher_count = 0; - $counter = 0; - //Iterate, filling counters - foreach ($recs as $rec) { - //Get full record, using backup_getids - $record = backup_getid($restore->backup_unique_code,"user",$rec->old_id); - if (strpos($record->info,"new") !== false) { - $new_count++; - } - if (strpos($record->info,"exists") !== false) { - $exists_count++; - } - if (strpos($record->info,"student") !== false) { - $student_count++; - } else if (strpos($record->info,"teacher") !== false) { - $teacher_count++; - } - //Do some output - $counter++; - if ($counter % 10 == 0) { - echo "."; - if ($counter % 200 == 0) { - echo "
    "; - } - backup_flush(300); - } - } - //Now print information gathered - echo " (".get_string("new").": ".$new_count.", ".get_string("existing").": ".$exists_count.")"; - echo "
      "; - echo "
    • ".get_string("students").": ".$student_count.'
    • '; - echo "
    • ".get_string("teachers").": ".$teacher_count.'
    • '; - echo "
    "; - } else { - notify("No users were found!"); - } - } - } - - //Now create metacourse info - if ($status and $restore->metacourse) { - //Only to new courses! - if ($restore->restoreto == 2) { - echo "
  • ".get_string("creatingmetacoursedata"); - if (!$status = restore_create_metacourse($restore,$xml_file)) { - notify("Error creating metacourse in the course."); - } - } - } - - - //Now create categories and questions as needed (STEP1) - if ($status and ($restore->mods['quiz']->restore)) { - echo "
  • ".get_string("creatingcategoriesandquestions"); - echo "
      "; - if (!$status = restore_create_questions($restore,$xml_file)) { - notify("Could not restore categories and questions!"); - } - echo "
  • "; - } - - //Now create user_files as needed - if ($status and ($restore->user_files)) { - echo "
  • ".get_string("copyinguserfiles"); - if (!$status = restore_user_files($restore)) { - notify("Could not restore user files!"); - } - //If all is ok (and we have a counter) - if ($status and ($status !== true)) { - //Inform about user dirs created from backup - echo "
      "; - echo "
    • ".get_string("userzones").": ".$status; - echo "
    "; - } - } - - //Now create course files as needed - if ($status and ($restore->course_files)) { - echo "
  • ".get_string("copyingcoursefiles")."
  • "; - if (!$status = restore_course_files($restore)) { - notify("Could not restore course files!"); - } - //If all is ok (and we have a counter) - if ($status and ($status !== true)) { - //Inform about user dirs created from backup - echo "
      "; - echo "
    • ".get_string("filesfolders").": ".$status; - echo "
    "; - } - } - - //Now create messages as needed - if ($status and ($restore->messages)) { - echo "
  • ".get_string("creatingmessagesinfo"); - if (!$status = restore_create_messages($restore,$xml_file)) { - notify("Could not restore messages!"); - } - echo "
  • "; - } - - //Now create scales as needed - if ($status) { - echo "
  • ".get_string("creatingscales").'
  • '; - if (!$status = restore_create_scales($restore,$xml_file)) { - notify("Could not restore custom scales!"); - } - } - - //Now create groups as needed - if ($status) { - echo "
  • ".get_string("creatinggroups").'
  • '; - if (!$status = restore_create_groups($restore,$xml_file)) { - notify("Could not restore groups!"); - } - } - - //Now create events as needed - if ($status) { - echo "
  • ".get_string("creatingevents").'
  • '; - if (!$status = restore_create_events($restore,$xml_file)) { - notify("Could not restore course events!"); - } - } - - //Now create course modules as needed - if ($status) { - echo "
  • ".get_string("creatingcoursemodules"); - if (!$status = restore_create_modules($restore,$xml_file)) { - notify("Could not restore modules!"); - } - } - - //Now create gradebook as needed -- AFTER modules!!! - if ($status) { - echo "
  • ".get_string("creatinggradebook"); - if (!$status = restore_create_gradebook($restore,$xml_file)) { - notify("Could not restore gradebook!"); - } - } - - //Bring back the course blocks -- do it AFTER the modules!!! - if($status) { - //If we are deleting and bringing into a course or making a new course, same situation - if($restore->restoreto == 0 || $restore->restoreto == 2) { - echo '
  • '.get_string('creatingblocks').'
  • '; - if (!$status = restore_create_blocks($restore, $info->backup_block_format, $course_header->blockinfo, $xml_file)) { - notify('Error while creating the course blocks'); - } - } - } - - //Now create log entries as needed - if ($status and ($restore->logs)) { - echo "
  • ".get_string("creatinglogentries"); - if (!$status = restore_create_logs($restore,$xml_file)) { - notify("Could not restore logs!"); - } - } - - //Now, if all is OK, adjust the instance field in course_modules !! - if ($status) { - echo "
  • ".get_string("checkinginstances").'
  • '; - if (!$status = restore_check_instances($restore)) { - notify("Could not adjust instances in course_modules!"); - } - } - - //Now, if all is OK, adjust activity events - if ($status) { - echo "
  • ".get_string("refreshingevents").'
  • '; - if (!$status = restore_refresh_events($restore)) { - notify("Could not refresh events for activities!"); - } - } - - //Now, if all is OK, adjust inter-activity links - if ($status) { - echo "
  • ".get_string("decodinginternallinks"); - if (!$status = restore_decode_content_links($restore)) { - notify("Could not refresh events for activities!"); - } - } - - //Now, with backup files prior to version 2005041100, - //convert all the wiki texts in the course to markdown - if ($status && $restore->backup_version < 2005041100) { - echo "
  • ".get_string("convertingwikitomarkdown"); - if (!$status = restore_convert_wiki2markdown($restore)) { - notify("Could not convert wiki texts to markdown!"); - } - } - - //Now if all is OK, update: - // - course modinfo field - // - categories table - // - add user as teacher - if ($status) { - echo "
  • ".get_string("checkingcourse").'
  • '; - //modinfo field - rebuild_course_cache($restore->course_id); - //categories table - $course = get_record("course","id",$restore->course_id); - fix_course_sortorder(); - //Make the user a teacher if the course hasn't teachers (bug 2381) - if (!isadmin()) { - if (!$checktea = get_records('user_teachers','course', $restore->course_id)) { - //Add the teacher to the course - $status = add_teacher($USER->id, $restore->course_id); - } - } - } - - //Cleanup temps (files and db) - if ($status) { - echo "
  • ".get_string("cleaningtempdata").'
  • '; - if (!$status = clean_temp_data ($restore)) { - notify("Could not clean up temporary data from files and database"); - } - } - - //End the main ul - echo "
"; - - - //End the main table - echo "
"; + $errorstr = ''; + $status = restore_execute($restore,$info,$course_header,$errorstr); if (!$status) { error ("An error has occurred and the restore could not be completed!"); diff --git a/backup/restore_precheck.html b/backup/restore_precheck.html index 02e82004469..ecf6def04ac 100644 --- a/backup/restore_precheck.html +++ b/backup/restore_precheck.html @@ -34,7 +34,11 @@ error("Site not found!"); } - $status = restore_precheck($id,$file,!empty($SESSION->restore->importing)); + $errorstr = ''; + if (!empty($SESSION->restore->importing)) { + define('RESTORE_SILENTLY',true); + } + $status = restore_precheck($id,$file,$errorstr); if (!$status) { error("An error occured"); diff --git a/backup/restorelib.php b/backup/restorelib.php index 937917b2c17..418b0d168ce 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -65,20 +65,26 @@ function restore_decode_content_links($restore) { $status = true; - echo ""; + } // TODO: process all html text also in blocks too @@ -105,20 +111,26 @@ $status = true; - echo ""; + } return $status; } @@ -965,7 +977,9 @@ $status = insert_record ('course_meta',$dbmetacourse); } else { //Child course not found, notice! - echo ''; + if (!defined('RESTORE_SILENTLY')) { + echo ''; + } } } //Now, recreate student enrolments... @@ -997,12 +1011,16 @@ //Now, recreate student enrolments in parent course sync_metacourse($dbcourse->id); } else { - //Parent course isn't metacourse, notice! - echo ''; + //Parent course isn't metacourse, notice! + if (!defined('RESTORE_SILENTLY')) { + echo ''; + } } } else { //Parent course not found, notice! - echo ''; + if (!defined('RESTORE_SILENTLY')) { + echo ''; + } } } } @@ -1036,7 +1054,9 @@ if ($preferencescount || $letterscount || $categoriescount) { //Start ul - echo ''; + } } } } @@ -1570,13 +1609,17 @@ $contactcount = count_records ('backup_ids', 'backup_code', $restore->backup_unique_code, 'table_name', 'message_contacts'); if ($unreadcount || $readcount || $contactcount) { //Start ul - echo ''; + } } } } @@ -2041,12 +2096,13 @@ //The structure is equal to the db, so insert the groups_members $newid = insert_record ("groups_members",$group_member); - //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
"; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
"; + } } backup_flush(300); } @@ -2203,7 +2259,9 @@ $result = str_replace($search,$replace,$content); if ($result != $content && $CFG->debug>7) { //Debug - echo '

'.htmlentities($content).'
changed to
'.htmlentities($result).'

'; //Debug + if (!defined('RESTORE_SILENTLY')) { + echo '

'.htmlentities($content).'
changed to
'.htmlentities($result).'

'; //Debug + } } //Debug return $result; @@ -2253,9 +2311,11 @@ } //Do some output if ($counter % 2 == 0) { - echo "."; - if ($counter % 40 == 0) { - echo "
"; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if ($counter % 40 == 0) { + echo "
"; + } } backup_flush(300); } @@ -2309,9 +2369,11 @@ } //Do some output if ($counter % 2 == 0) { - echo "."; - if ($counter % 40 == 0) { - echo "
"; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if ($counter % 40 == 0) { + echo "
"; + } } backup_flush(300); } @@ -2361,9 +2423,11 @@ } //Do some output if ($counter % 2 == 0) { - echo "."; - if ($counter % 40 == 0) { - echo "
"; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if ($counter % 40 == 0) { + echo "
"; + } } backup_flush(300); } @@ -2396,12 +2460,13 @@ //in backup_ids->info will be the real info (serialized) $info = restore_read_xml_modules($restore,$xml_file); } - //Now, if we have anything in info, we have to restore that mods //from backup_ids (calling every mod restore function) if ($info) { if ($info !== true) { - echo ''; + } } } else { $status = false; @@ -2516,9 +2583,11 @@ //Do some output $counter++; if ($counter % 10 == 0) { - echo "."; - if ($counter % 200 == 0) { - echo "
"; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if ($counter % 200 == 0) { + echo "
"; + } } backup_flush(300); } @@ -3741,9 +3810,11 @@ //Do some output if ($this->counter % 10 == 0) { - echo "."; - if ($this->counter % 200 == 0) { - echo "
"; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if ($this->counter % 200 == 0) { + echo "
"; + } } backup_flush(300); } @@ -4295,6 +4366,8 @@ } } + + //Stop parsing if todo = MODULES and tagName = MODULES (en of the tag, of course) //Speed up a lot (avoid parse all) if ($tagName == "MODULES" and $this->level == 3) { @@ -4459,25 +4532,31 @@ } //Get info from parser $info = $moodle_parser->info; - + //Clear parser mem xml_parser_free($xml_parser); - if ($status && $info) { + if ($status && !empty($info)) { return $info; } else { return $status; } } - function restore_precheck($id,$file,$silent=false) { + /** + * @param string $errorstr passed by reference, if silent is true, + * errorstr will be populated and this function will return false rather than calling error() or notify() + * @param boolean $noredirect (optional) if this is passed, this function will not print continue, or + * redirect to the next step in the restore process, instead will return $backup_unique_code + */ + function restore_precheck($id,$file,&$errorstr,$noredirect=false) { global $CFG, $SESSION; //Prepend dataroot to variable to have the absolute path $file = $CFG->dataroot."/".$file; - if (empty($silent)) { + if (!defined('RESTORE_SILENTLY')) { //Start the main table echo ""; echo "
"; @@ -4488,19 +4567,29 @@ //Check the file exists if (!is_file($file)) { - error ("File not exists ($file)"); + if (!defined('RESTORE_SILENTLY')) { + error ("File not exists ($file)"); + } else { + $errorstr = "File not exists ($file)"; + return false; + } } //Check the file name ends with .zip if (!substr($file,-4) == ".zip") { - error ("File has an incorrect extension"); + if (!defined('RESTORE_SILENTLY')) { + error ("File has an incorrect extension"); + } else { + $errorstr = 'File has an incorrect extension'; + return false; + } } //Now calculate the unique_code for this restore $backup_unique_code = time(); //Now check and create the backup dir (if it doesn't exist) - if (empty($silent)) { + if (!defined('RESTORE_SILENTLY')) { echo "
  • ".get_string("creatingtemporarystructures").'
  • '; } $status = check_and_create_backup_dir($backup_unique_code); @@ -4511,7 +4600,7 @@ //Now delete old data and directories under dataroot/temp/backup if ($status) { - if (empty($silent)) { + if (!defined('RESTORE_SILENTLY')) { echo "
  • ".get_string("deletingolddata").'
  • '; } $status = backup_delete_old_data(); @@ -4519,39 +4608,56 @@ //Now copy he zip file to dataroot/temp/backup/backup_unique_code if ($status) { - if (empty($silent)) { + if (!defined('RESTORE_SILENTLY')) { echo "
  • ".get_string("copyingzipfile").'
  • '; } if (! $status = backup_copy_file($file,$CFG->dataroot."/temp/backup/".$backup_unique_code."/".basename($file))) { - notify("Error copying backup file. Invalid name or bad perms."); + if (!defined('RESTORE_SILENTLY')) { + notify("Error copying backup file. Invalid name or bad perms."); + } else { + $errorstr = "Error copying backup file. Invalid name or bad perms"; + return false; + } } } //Now unzip the file if ($status) { - if (empty($silent)) { + if (!defined('RESTORE_SILENTLY')) { echo "
  • ".get_string("unzippingbackup").'
  • '; } if (! $status = restore_unzip ($CFG->dataroot."/temp/backup/".$backup_unique_code."/".basename($file))) { - notify("Error unzipping backup file. Invalid zip file."); + if (!defined('RESTORE_SILENTLY')) { + notify("Error unzipping backup file. Invalid zip file."); + } else { + $errorstr = "Error unzipping backup file. Invalid zip file."; + return false; + } } } //Check for Blackboard backups and convert if ($status){ require_once("$CFG->dirroot/backup/bb/restore_bb.php"); - echo "
  • ".get_string("checkingforbbexport"); + if (!defined('RESTORE_SILENTLY')) { + echo "
  • ".get_string("checkingforbbexport"); + } $status = blackboard_convert($CFG->dataroot."/temp/backup/".$backup_unique_code); } //Now check for the moodle.xml file if ($status) { $xml_file = $CFG->dataroot."/temp/backup/".$backup_unique_code."/moodle.xml"; - if (empty($silent)) { + if (!defined('RESTORE_SILENTLY')) { echo "
  • ".get_string("checkingbackup").'
  • '; } if (! $status = restore_check_moodle_file ($xml_file)) { - notify("Error checking backup file. Invalid or corrupted."); + if (!defined('RESTORE_SILENTLY')) { + notify("Error checking backup file. Invalid or corrupted."); + } else { + $errorstr = "Error checking backup file. Invalid or corrupted."; + return false; + } } } @@ -4560,7 +4666,7 @@ //Now read the info tag (all) if ($status) { - if (empty($silent)) { + if (!defined('RESTORE_SILENTLY')) { echo "
  • ".get_string("readinginfofrombackup").'
  • '; } //Reading info from file @@ -4569,7 +4675,7 @@ $course_header = restore_read_xml_course_header ($xml_file); } - if (empty($silent)) { + if (!defined('RESTORE_SILENTLY')) { //End the main ul echo ""; @@ -4591,10 +4697,14 @@ //Now we print in other table, the backup and the course it contains info if ($info and $course_header and $status) { //First, the course info - $status = restore_print_course_header($course_header); + if (!defined('RESTORE_SILENTLY')) { + $status = restore_print_course_header($course_header); + } //Now, the backup info if ($status) { - $status = restore_print_info($info); + if (!defined('RESTORE_SILENTLY')) { + $status = restore_print_info($info); + } } } @@ -4607,7 +4717,7 @@ //Finally, a little form to continue //with some hidden fields if ($status) { - if (empty($silent)) { + if (!defined('RESTORE_SILENTLY')) { echo "
    "; $hidden["backup_unique_code"] = $backup_unique_code; $hidden["launch"] = "form"; @@ -4617,12 +4727,21 @@ echo "
    "; } else { - redirect($CFG->wwwroot.'/backup/restore.php?backup_unique_code='.$backup_unique_code.'&launch=form&file='.$file.'&id='.$id); + if (empty($noredirect)) { + redirect($CFG->wwwroot.'/backup/restore.php?backup_unique_code='.$backup_unique_code.'&launch=form&file='.$file.'&id='.$id); + } else { + return $backup_unique_code; + } } } if (!$status) { - error ("An error has ocurred"); + if (!defined('RESTORE_SILENTLY')) { + error ("An error has ocurred"); + } else { + $errorstr = "An error has occured"; // helpful! :P + return false; + } } return true; } @@ -4642,6 +4761,7 @@ } } } + return true; } function backup_to_restore_array($backup,$k=0) { @@ -4680,4 +4800,539 @@ return !empty($restore->mods[$modname]->userinfo); } + function restore_execute(&$restore,$info,$course_header,&$errorstr) { + global $CFG; + $status = true; + //Checks for the required files/functions to restore every module + //and include them + if ($allmods = get_records("modules") ) { + foreach ($allmods as $mod) { + $modname = $mod->name; + $modfile = "$CFG->dirroot/mod/$modname/restorelib.php"; + //If file exists and we have selected to restore that type of module + if ((file_exists($modfile)) and ($restore->mods[$modname]->restore)) { + include_once($modfile); + } + } + } + + if (!defined('RESTORE_SILENTLY')) { + //Start the main table + echo ""; + echo ""; + echo "
    "; + + //Start the main ul + echo "
      "; + } + + //Localtion of the xml file + $xml_file = $CFG->dataroot."/temp/backup/".$restore->backup_unique_code."/moodle.xml"; + + //If we've selected to restore into new course + //create it (course) + //Saving conversion id variables into backup_tables + if ($restore->restoreto == 2) { + if (!defined('RESTORE_SILENTLY')) { + echo "
    • ".get_string("creatingnewcourse"); + } + $oldidnumber = $course_header->course_idnumber; + if (!$status = restore_create_new_course($restore,$course_header)) { + if (!defined('RESTORE_SILENTLY')) { + notify("Error while creating the new empty course."); + } else { + $errorstr = "Error while creating the new empty course."; + return false; + } + } + + //Print course fullname and shortname and category + if ($status) { + if (!defined('RESTORE_SILENTLY')) { + echo "
        "; + echo "
      • ".$course_header->course_fullname." (".$course_header->course_shortname.")".'
      • '; + echo "
      • ".get_string("category").": ".$course_header->category->name.'
      • '; + if (!empty($oldidnumber)) { + echo "
      • ".get_string("nomoreidnumber","moodle",$oldidnumber)."
      • "; + } + echo "
    • "; + //Put the destination course_id + } + $restore->course_id = $course_header->course_id; + } + } else { + $course = get_record("course","id",$restore->course_id); + if ($course) { + if (!defined('RESTORE_SILENTLY')) { + echo "
    • ".get_string("usingexistingcourse"); + echo "
        "; + echo "
      • ".get_string("from").": ".$course_header->course_fullname." (".$course_header->course_shortname.")".'
      • '; + echo "
      • ".get_string("to").": ".$course->fullname." (".$course->shortname.")".'
      • '; + if (($restore->deleting)) { + echo "
      • ".get_string("deletingexistingcoursedata").'
      • '; + } else { + echo "
      • ".get_string("addingdatatoexisting").'
      • '; + } + echo "
    • "; + } + //If we have selected to restore deleting, we do it now. + if ($restore->deleting) { + if (!defined('RESTORE_SILENTLY')) { + echo "
    • ".get_string("deletingolddata").'
    • '; + } + $status = remove_course_contents($restore->course_id,false) and + delete_dir_contents($CFG->dataroot."/".$restore->course_id,"backupdata"); + if ($status) { + //Now , this situation is equivalent to the "restore to new course" one (we + //have a course record and nothing more), so define it as "to new course" + $restore->restoreto = 2; + } else { + if (!defined('RESTORE_SILENTLY')) { + notify("An error occurred while deleting some of the course contents."); + } else { + $errrostr = "An error occurred while deleting some of the course contents."; + return false; + } + } + } + } else { + if (!defined('RESTORE_SILENTLY')) { + notify("Error opening existing course."); + $status = false; + } else { + $errorstr = "Error opening existing course."; + return false; + } + } + } + + //Now create the course_sections and their associated course_modules + if ($status) { + //Into new course + if ($restore->restoreto == 2) { + if (!defined('RESTORE_SILENTLY')) { + echo "
    • ".get_string("creatingsections").'
    • '; + } + if (!$status = restore_create_sections($restore,$xml_file)) { + if (!defined('RESTORE_SILENTLY')) { + notify("Error creating sections in the existing course."); + } else { + $errorstr = "Error creating sections in the existing course."; + return false; + } + } + //Into existing course + } else if ($restore->restoreto == 0 or $restore->restoreto == 1) { + if (!defined('RESTORE_SILENTLY')) { + echo "
    • ".get_string("checkingsections").'
    • '; + } + if (!$status = restore_create_sections($restore,$xml_file)) { + if (!defined('RESTORE_SILENTLY')) { + notify("Error creating sections in the existing course."); + } else { + $errorstr = "Error creating sections in the existing course."; + return false; + } + } + //Error + } else { + if (!defined('RESTORE_SILENTLY')) { + notify("Neither a new course or an existing one was specified."); + $status = false; + } else { + $errorstr = "Neither a new course or an existing one was specified."; + return false; + } + } + } + + //Now create users as needed + if ($status and ($restore->users == 0 or $restore->users == 1)) { + if (!defined('RESTORE_SILENTLY')) { + echo "
    • ".get_string("creatingusers")."
      "; + } + if (!$status = restore_create_users($restore,$xml_file)) { + if (!defined('RESTORE_SILENTLY')) { + notify("Could not restore users."); + } else { + $errorstr = "Could not restore users."; + return false; + } + } + //Now print info about the work done + if ($status) { + $recs = get_records_sql("select old_id, new_id from {$CFG->prefix}backup_ids + where backup_code = '$restore->backup_unique_code' and + table_name = 'user'"); + //We've records + if ($recs) { + $new_count = 0; + $exists_count = 0; + $student_count = 0; + $teacher_count = 0; + $counter = 0; + //Iterate, filling counters + foreach ($recs as $rec) { + //Get full record, using backup_getids + $record = backup_getid($restore->backup_unique_code,"user",$rec->old_id); + if (strpos($record->info,"new") !== false) { + $new_count++; + } + if (strpos($record->info,"exists") !== false) { + $exists_count++; + } + if (strpos($record->info,"student") !== false) { + $student_count++; + } else if (strpos($record->info,"teacher") !== false) { + $teacher_count++; + } + //Do some output + $counter++; + if ($counter % 10 == 0) { + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if ($counter % 200 == 0) { + echo "
      "; + } + } + backup_flush(300); + } + } + if (!defined('RESTORE_SILENTLY')) { + //Now print information gathered + echo " (".get_string("new").": ".$new_count.", ".get_string("existing").": ".$exists_count.")"; + echo "
        "; + echo "
      • ".get_string("students").": ".$student_count.'
      • '; + echo "
      • ".get_string("teachers").": ".$teacher_count.'
      • '; + echo "
      "; + } + } else { + if (!defined('RESTORE_SILENTLY')) { + notify("No users were found!"); + } // no need to return false here, it's recoverable. + } + } + } + + //Now create metacourse info + if ($status and $restore->metacourse) { + //Only to new courses! + if ($restore->restoreto == 2) { + if (!defined('RESTORE_SILENTLY')) { + echo "
    • ".get_string("creatingmetacoursedata"); + } + if (!$status = restore_create_metacourse($restore,$xml_file)) { + if (!defined('RESTORE_SILENTLY')) { + notify("Error creating metacourse in the course."); + } else { + $errorstr = "Error creating metacourse in the course."; + return false; + } + } + } + } + + + //Now create categories and questions as needed (STEP1) + if ($status and ($restore->mods['quiz']->restore)) { + if (!defined('RESTORE_SILENTLY')) { + echo "
    • ".get_string("creatingcategoriesandquestions"); + echo "
        "; + } + if (!$status = restore_create_questions($restore,$xml_file)) { + if (!defined('RESTORE_SILENTLY')) { + notify("Could not restore categories and questions!"); + } else { + $errorstr = "Could not restore categories and questions!"; + return false; + } + } + if (!defined('RESTORE_SILENTLY')) { + echo "
    • "; + } + } + + //Now create user_files as needed + if ($status and ($restore->user_files)) { + if (!defined('RESTORE_SILENTLY')) { + echo "
    • ".get_string("copyinguserfiles"); + } + if (!$status = restore_user_files($restore)) { + if (!defined('RESTORE_SILENTLY')) { + notify("Could not restore user files!"); + } else { + $errorstr = "Could not restore user files!"; + return false; + } + } + //If all is ok (and we have a counter) + if ($status and ($status !== true)) { + //Inform about user dirs created from backup + if (!defined('RESTORE_SILENTLY')) { + echo "
        "; + echo "
      • ".get_string("userzones").": ".$status; + echo "
      "; + } + } + } + + //Now create course files as needed + if ($status and ($restore->course_files)) { + if (!defined('RESTORE_SILENTLY')) { + echo "
    • ".get_string("copyingcoursefiles")."
    • "; + } + if (!$status = restore_course_files($restore)) { + if (empty($status)) { + notify("Could not restore course files!"); + } else { + $errorstr = "Could not restore course files!"; + return false; + } + } + //If all is ok (and we have a counter) + if ($status and ($status !== true)) { + //Inform about user dirs created from backup + if (!defined('RESTORE_SILENTLY')) { + echo "
        "; + echo "
      • ".get_string("filesfolders").": ".$status; + echo "
      "; + } + } + } + + //Now create messages as needed + if ($status and ($restore->messages)) { + if (!defined('RESTORE_SILENTLY')) { + echo "
    • ".get_string("creatingmessagesinfo"); + } + if (!$status = restore_create_messages($restore,$xml_file)) { + if (!defined('RESTORE_SILENTLY')) { + notify("Could not restore messages!"); + } else { + $errorstr = "Could not restore messages!"; + return false; + } + } + if (!defined('RESTORE_SILENTLY')) { + echo "
    • "; + } + } + + //Now create scales as needed + if ($status) { + if (!defined('RESTORE_SILENTLY')) { + echo "
    • ".get_string("creatingscales").'
    • '; + } + if (!$status = restore_create_scales($restore,$xml_file)) { + if (!defined('RESTORE_SILENTLY')) { + notify("Could not restore custom scales!"); + } else { + $errorstr = "Could not restore custom scales!"; + return false; + } + } + } + + //Now create groups as needed + if ($status) { + if (!defined('RESTORE_SILENTLY')) { + echo "
    • ".get_string("creatinggroups").'
    • '; + } + if (!$status = restore_create_groups($restore,$xml_file)) { + if (!defined('RESTORE_SILENTLY')) { + notify("Could not restore groups!"); + } else { + $errorstr = "Could not restore groups!"; + return false; + } + } + } + + //Now create events as needed + if ($status) { + if (!defined('RESTORE_SILENTLY')) { + echo "
    • ".get_string("creatingevents").'
    • '; + } + if (!$status = restore_create_events($restore,$xml_file)) { + if (!defined('RESTORE_SILENTLY')) { + notify("Could not restore course events!"); + } else { + $errorstr = "Could not restore course events!"; + return false; + } + } + } + + //Now create course modules as needed + if ($status) { + if (!defined('RESTORE_SILENTLY')) { + echo "
    • ".get_string("creatingcoursemodules"); + } + if (!$status = restore_create_modules($restore,$xml_file)) { + if (!defined('RESTORE_SILENTLY')) { + notify("Could not restore modules!"); + } else { + $errorstr = "Could not restore modules!"; + return false; + } + } + } + + //Now create gradebook as needed -- AFTER modules!!! + if ($status) { + if (!defined('RESTORE_SILENTLY')) { + echo "
    • ".get_string("creatinggradebook"); + } + if (!$status = restore_create_gradebook($restore,$xml_file)) { + if (!defined('RESTORE_SILENTLY')) { + notify("Could not restore gradebook!"); + } else { + $errorstr = "Could not restore gradebook!"; + return false; + } + } + } + + //Bring back the course blocks -- do it AFTER the modules!!! + if($status) { + //If we are deleting and bringing into a course or making a new course, same situation + if($restore->restoreto == 0 || $restore->restoreto == 2) { + if (!defined('RESTORE_SILENTLY')) { + echo '
    • '.get_string('creatingblocks').'
    • '; + } + if (!$status = restore_create_blocks($restore, $info->backup_block_format, $course_header->blockinfo, $xml_file)) { + if (!defined('RESTORE_SILENTLY')) { + notify('Error while creating the course blocks'); + } else { + $errorstr = "Error while creating the course blocks"; + return false; + } + } + } + } + + //Now create log entries as needed + if ($status and ($restore->logs)) { + if (!defined('RESTORE_SILENTLY')) { + echo "
    • ".get_string("creatinglogentries"); + } + if (!$status = restore_create_logs($restore,$xml_file)) { + if (!defined('RESTORE_SILENTLY')) { + notify("Could not restore logs!"); + } else { + $errorstr = "Could not restore logs!"; + return false; + } + } + } + + //Now, if all is OK, adjust the instance field in course_modules !! + if ($status) { + if (!defined('RESTORE_SILENTLY')) { + echo "
    • ".get_string("checkinginstances").'
    • '; + } + if (!$status = restore_check_instances($restore)) { + if (!defined('RESTORE_SILENTLY')) { + notify("Could not adjust instances in course_modules!"); + } else { + $errorstr = "Could not adjust instances in course_modules!"; + return false; + } + } + } + + //Now, if all is OK, adjust activity events + if ($status) { + if (!defined('RESTORE_SILENTLY')) { + echo "
    • ".get_string("refreshingevents").'
    • '; + } + if (!$status = restore_refresh_events($restore)) { + if (!defined('RESTORE_SILENTLY')) { + notify("Could not refresh events for activities!"); + } else { + $errorstr = "Could not refresh events for activities!"; + return false; + } + } + } + + //Now, if all is OK, adjust inter-activity links + if ($status) { + if (!defined('RESTORE_SILENTLY')) { + echo "
    • ".get_string("decodinginternallinks"); + } + if (!$status = restore_decode_content_links($restore)) { + if (!defined('RESTORE_SILENTLY')) { + notify("Could not refresh events for activities!"); + } else { + $errorstr = "Could not refresh events for activities!"; + return false; + } + } + } + + //Now, with backup files prior to version 2005041100, + //convert all the wiki texts in the course to markdown + if ($status && $restore->backup_version < 2005041100) { + if (!defined('RESTORE_SILENTLY')) { + echo "
    • ".get_string("convertingwikitomarkdown"); + } + if (!$status = restore_convert_wiki2markdown($restore)) { + if (!defined('RESTORE_SILENTLY')) { + notify("Could not convert wiki texts to markdown!"); + } else { + $errorstr = "Could not convert wiki texts to markdown!"; + return false; + } + } + } + + //Now if all is OK, update: + // - course modinfo field + // - categories table + // - add user as teacher + if ($status) { + if (!defined('RESTORE_SILENTLY')) { + echo "
    • ".get_string("checkingcourse").'
    • '; + } + //modinfo field + rebuild_course_cache($restore->course_id); + //categories table + $course = get_record("course","id",$restore->course_id); + fix_course_sortorder(); + //Make the user a teacher if the course hasn't teachers (bug 2381) + if (!isadmin()) { + if (!$checktea = get_records('user_teachers','course', $restore->course_id)) { + //Add the teacher to the course + $status = add_teacher($USER->id, $restore->course_id); + } + } + } + + //Cleanup temps (files and db) + if ($status) { + if (!defined('RESTORE_SILENTLY')) { + echo "
    • ".get_string("cleaningtempdata").'
    • '; + } + if (!$status = clean_temp_data ($restore)) { + if (!defined('RESTORE_SILENTLY')) { + notify("Could not clean up temporary data from files and database"); + } else { + $errorstr = "Could not clean up temporary data from files and database"; + return false; + } + } + } + + if (!defined('RESTORE_SILENTLY')) { + //End the main ul + echo "
    "; + + //End the main table + echo "
    "; + } + + return $status; + } + ?> diff --git a/mod/assignment/restorelib.php b/mod/assignment/restorelib.php index 30c75740d78..5518798d8b4 100644 --- a/mod/assignment/restorelib.php +++ b/mod/assignment/restorelib.php @@ -79,7 +79,9 @@ $newid = insert_record ("assignment",$assignment); //Do some output - echo "
  • ".get_string("modulename","assignment")." \"".format_string(stripslashes($assignment->name),true)."\"
  • "; + if (!defined('RESTORE_SILENTLY')) { + echo "
  • ".get_string("modulename","assignment")." \"".format_string(stripslashes($assignment->name),true)."\"
  • "; + } backup_flush(300); if ($newid) { @@ -154,9 +156,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -319,14 +323,18 @@ $assignment->description = addslashes($result); $status = update_record("assignment",$assignment); if ($CFG->debug>7) { - echo '

    '.htmlentities($content).'
    changed to
    '.htmlentities($result).'

    '; + if (!defined('RESTORE_SILENTLY')) { + echo '

    '.htmlentities($content).'
    changed to
    '.htmlentities($result).'

    '; + } } } //Do some output if (($i+1) % 5 == 0) { - echo "."; - if (($i+1) % 100 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 100 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -363,9 +371,11 @@ //Do some output $i++; if (($i+1) % 1 == 0) { - echo "."; - if (($i+1) % 20 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 20 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -455,7 +465,9 @@ } break; default: - echo "action (".$log->module."-".$log->action.") unknow. Not restored
    "; //Debug + if (!defined('RESTORE_SILENTLY')) { + echo "action (".$log->module."-".$log->action.") unknow. Not restored
    "; //Debug + } break; } diff --git a/mod/chat/restorelib.php b/mod/chat/restorelib.php index 6a5c89e4489..537463788fc 100644 --- a/mod/chat/restorelib.php +++ b/mod/chat/restorelib.php @@ -52,7 +52,9 @@ $newid = insert_record ("chat",$chat); //Do some output - echo "
  • ".get_string("modulename","chat")." \"".format_string(stripslashes($chat->name),true)."\"
  • "; + if (!defined('RESTORE_SILENTLY')) { + echo "
  • ".get_string("modulename","chat")." \"".format_string(stripslashes($chat->name),true)."\"
  • "; + } backup_flush(300); if ($newid) { @@ -120,9 +122,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -217,17 +221,21 @@ $chat->intro = addslashes($result); $status = update_record("chat",$chat); if ($CFG->debug>7) { - echo '

    '.htmlentities($content).'
    changed to
    '.htmlentities($result).'

    '; + if (!defined('RESTORE_SILENTLY')) { + echo '

    '.htmlentities($content).'
    changed to
    '.htmlentities($result).'

    '; + } } } //Do some output if (($i+1) % 5 == 0) { - echo "."; - if (($i+1) % 100 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 100 == 0) { + echo "
    "; + } } backup_flush(300); - } + } } } @@ -302,7 +310,9 @@ } break; default: - echo "action (".$log->module."-".$log->action.") unknow. Not restored
    "; //Debug + if (!defined('RESTORE_SILENTLY')) { + echo "action (".$log->module."-".$log->action.") unknow. Not restored
    "; //Debug + } break; } diff --git a/mod/choice/restorelib.php b/mod/choice/restorelib.php index 4fe031576c6..e0d4bc9d5f5 100644 --- a/mod/choice/restorelib.php +++ b/mod/choice/restorelib.php @@ -125,7 +125,9 @@ } //Do some output - echo "
  • ".get_string("modulename","choice")." \"".format_string(stripslashes($choice->name),true)."\"
  • "; + if (!defined('RESTORE_SILENTLY')) { + echo "
  • ".get_string("modulename","choice")." \"".format_string(stripslashes($choice->name),true)."\"
  • "; + } backup_flush(300); } else { @@ -164,9 +166,11 @@ function choice_options_restore_mods($choiceid,$info,$restore) { //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -232,9 +236,11 @@ function choice_options_restore_mods($choiceid,$info,$restore) { //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -338,17 +344,21 @@ function choice_options_restore_mods($choiceid,$info,$restore) { $choice->text = addslashes($result); $status = update_record("choice",$choice); if ($CFG->debug>7) { - echo '

    '.htmlentities($content).'
    changed to
    '.htmlentities($result).'

    '; + if (!defined('RESTORE_SILENTLY')) { + echo '

    '.htmlentities($content).'
    changed to
    '.htmlentities($result).'

    '; + } } } //Do some output if (($i+1) % 5 == 0) { - echo "."; - if (($i+1) % 100 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 100 == 0) { + echo "
    "; + } } backup_flush(300); - } + } } } @@ -383,9 +393,11 @@ function choice_options_restore_mods($choiceid,$info,$restore) { //Do some output $i++; if (($i+1) % 1 == 0) { - echo "."; - if (($i+1) % 20 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 20 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -474,7 +486,9 @@ function choice_options_restore_mods($choiceid,$info,$restore) { } break; default: - echo "action (".$log->module."-".$log->action.") unknow. Not restored
    "; //Debug + if (!defined('RESTORE_SILENTLY')) { + echo "action (".$log->module."-".$log->action.") unknow. Not restored
    "; //Debug + } break; } diff --git a/mod/exercise/restorelib.php b/mod/exercise/restorelib.php index d5393878ed1..f5169415ff1 100644 --- a/mod/exercise/restorelib.php +++ b/mod/exercise/restorelib.php @@ -75,7 +75,9 @@ $newid = insert_record ("exercise",$exercise); //Do some output - echo "
  • ".get_string("modulename","exercise")." \"".format_string(stripslashes($exercise->name),true)."\"
  • "; + if (!defined('RESTORE_SILENTLY')) { + echo "
  • ".get_string("modulename","exercise")." \"".format_string(stripslashes($exercise->name),true)."\"
  • "; + } backup_flush(300); if ($newid) { @@ -126,9 +128,11 @@ //Do some output if (($i+1) % 10 == 0) { - echo "."; - if (($i+1) % 200 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 200 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -174,9 +178,11 @@ //Do some output if (($i+1) % 10 == 0) { - echo "."; - if (($i+1) % 200 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 200 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -233,9 +239,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -305,9 +313,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -360,9 +370,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } diff --git a/mod/forum/restorelib.php b/mod/forum/restorelib.php index e185ab7a000..e049bf10568 100644 --- a/mod/forum/restorelib.php +++ b/mod/forum/restorelib.php @@ -92,7 +92,9 @@ } //Do some output - echo "
  • ".get_string("modulename","forum")." \"".format_string(stripslashes($forum->name),true)."\""; + if (!defined('RESTORE_SILENTLY')) { + echo "
  • ".get_string("modulename","forum")." \"".format_string(stripslashes($forum->name),true)."\""; + } backup_flush(300); if ($newid) { @@ -158,9 +160,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -232,9 +236,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -337,9 +343,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -401,9 +409,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -548,9 +558,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -599,9 +611,11 @@ //Do some output $i++; if (($i+1) % 1 == 0) { - echo "."; - if (($i+1) % 20 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 20 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -817,7 +831,9 @@ $status = true; break; default: - echo "action (".$log->module."-".$log->action.") unknow. Not restored
    "; //Debug + if (!defined('RESTORE_SILENTLY')) { + echo "action (".$log->module."-".$log->action.") unknow. Not restored
    "; //Debug + } break; } @@ -1021,14 +1037,18 @@ $post->message = addslashes($result); $status = update_record("forum_posts",$post); if ($CFG->debug>7) { - echo '

    '.htmlentities($content).'
    changed to
    '.htmlentities($result).'

    '; + if (!defined('RESTORE_SILENTLY')) { + echo '

    '.htmlentities($content).'
    changed to
    '.htmlentities($result).'

    '; + } } } //Do some output if (($i+1) % 5 == 0) { - echo "."; - if (($i+1) % 100 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 100 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -1051,14 +1071,18 @@ $forum->intro = addslashes($result); $status = update_record("forum",$forum); if ($CFG->debug>7) { - echo '

    '.htmlentities($content).'
    changed to
    '.htmlentities($result).'

    '; + if (!defined('RESTORE_SILENTLY')) { + echo '

    '.htmlentities($content).'
    changed to
    '.htmlentities($result).'

    '; + } } } //Do some output if (($i+1) % 5 == 0) { - echo "."; - if (($i+1) % 100 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 100 == 0) { + echo "
    "; + } } backup_flush(300); } diff --git a/mod/glossary/restorelib.php b/mod/glossary/restorelib.php index ed9ce19836e..5ebc12e1c55 100644 --- a/mod/glossary/restorelib.php +++ b/mod/glossary/restorelib.php @@ -113,7 +113,9 @@ $newid = insert_record ("glossary",$glossary); //Do some output - echo "
  • ".get_string("modulename","glossary")." \"".format_string(stripslashes($glossary->name),true)."\"
  • "; + if (!defined('RESTORE_SILENTLY')) { + echo "
  • ".get_string("modulename","glossary")." \"".format_string(stripslashes($glossary->name),true)."\"
  • "; + } backup_flush(300); if ($newid) { @@ -188,9 +190,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -255,9 +259,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -306,9 +312,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -344,9 +352,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -388,9 +398,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -440,9 +452,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -599,14 +613,18 @@ $entry->definition = addslashes($result); $status = update_record("glossary_entries",$entry); if ($CFG->debug>7) { - echo '

    '.htmlentities($content).'
    changed to
    '.htmlentities($result).'

    '; + if (!defined('RESTORE_SILENTLY')) { + echo '

    '.htmlentities($content).'
    changed to
    '.htmlentities($result).'

    '; + } } } //Do some output if (($i+1) % 5 == 0) { - echo "."; - if (($i+1) % 100 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 100 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -629,17 +647,21 @@ $glossary->intro = addslashes($result); $status = update_record("glossary",$glossary); if ($CFG->debug>7) { - echo '

    '.htmlentities($content).'
    changed to
    '.htmlentities($result).'

    '; + if (!defined('RESTORE_SILENTLY')) { + echo '

    '.htmlentities($content).'
    changed to
    '.htmlentities($result).'

    '; + } } } //Do some output if (($i+1) % 5 == 0) { - echo "."; - if (($i+1) % 100 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 100 == 0) { + echo "
    "; + } } backup_flush(300); - } + } } } @@ -678,9 +700,11 @@ //Do some output $i++; if (($i+1) % 1 == 0) { - echo "."; - if (($i+1) % 20 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 20 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -710,9 +734,11 @@ //Do some output $i++; if (($i+1) % 1 == 0) { - echo "."; - if (($i+1) % 20 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 20 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -902,7 +928,9 @@ } break; default: - echo "action (".$log->module."-".$log->action.") unknow. Not restored
    "; //Debug + if (!defined('RESTORE_SILENTLY')) { + echo "action (".$log->module."-".$log->action.") unknow. Not restored
    "; //Debug + } break; } diff --git a/mod/hotpot/restorelib.php b/mod/hotpot/restorelib.php index 843ff279c73..35774581a04 100644 --- a/mod/hotpot/restorelib.php +++ b/mod/hotpot/restorelib.php @@ -71,7 +71,9 @@ function hotpot_restore_mods($mod, $restore) { $foreign_keys = array('course' => $restore->course_id); $more_restore = ''; // print a message after each hotpot is backed up - $more_restore .= 'print "
  • ".get_string("modulename", "hotpot")." "".$record->name.""
  • ";'; + if (!defined('RESTORE_SILENTLY')) { + $more_restore .= 'print "
  • ".get_string("modulename", "hotpot")." "".$record->name.""
  • ";'; + } $more_restore .= 'backup_flush(300);'; if (restore_userdata_selected($restore,'hotpot',$mod->id)) { if (isset($xml["STRING_DATA"]) && isset($xml["QUESTION_DATA"])) { @@ -160,7 +162,9 @@ function hotpot_restore_clickreportids(&$restore, $status) { $status = execute_sql("UPDATE {$CFG->prefix}hotpot_attempts SET clickreportid=$new_clickreportid WHERE id=$id", false); } else { // New clickreport id could not be found - print "
    • New clickreportid could not be found: attempt id=$id, clickreportid=$clickreportid
    "; + if (!defined('RESTORE_SILENTLY')) { + print "
    • New clickreportid could not be found: attempt id=$id, clickreportid=$clickreportid
    "; + } $status = false; } } @@ -193,7 +197,9 @@ function hotpot_restore_details(&$restore, $status, &$xml, &$record) { if (insert_record('hotpot_details', $details)) { $status = true; } else { - print "
    • Details record could not be updated: attempt=$record->attempt
    "; + if (!defined('RESTORE_SILENTLY')) { + print "
    • Details record could not be updated: attempt=$record->attempt
    "; + } $status = false; } } @@ -291,14 +297,16 @@ function hotpot_restore_record(&$restore, $status, &$xml, $table, $foreign_keys, $new_ids[] = $key_record->new_id; } else { // foreign key could not be updated - print "
    • Warning:
      Foreign key could not be updated:
      "; - print "'$key_table' record (old id=$old_id) is missing from backup data
      "; - print "'$table' record "; - if (isset($record->id)) { - print "(old id=$record->id) "; - } - print "was not restored
    "; - $ok = false; + if (!defined('RESTORE_SILENTLY')) { + print "
    • Warning:
      Foreign key could not be updated:
      "; + print "'$key_table' record (old id=$old_id) is missing from backup data
      "; + print "'$table' record "; + if (isset($record->id)) { + print "(old id=$record->id) "; + } + print "was not restored
    "; + } + $ok = false; } } $record->$key = implode(',', $new_ids); @@ -333,7 +341,9 @@ function hotpot_restore_record(&$restore, $status, &$xml, $table, $foreign_keys, } } else { // failed to add (or find) $record - print "
    • Record could not be added: table=$table
    "; + if (!defined('RESTORE_SILENTLY')) { + print "
    • Record could not be added: table=$table
    "; + } $status = false; } // restore related records, if required @@ -398,7 +408,9 @@ function hotpot_restore_logs($restore, $log) { break; default: // Oops, unknown $log->action - print "

    action (".$log->module."-".$log->action.") unknown. Not restored

    "; + if (!defined('RESTORE_SILENTLY')) { + print "

    action (".$log->module."-".$log->action.") unknown. Not restored

    "; + } break; } // end switch return $status ? $log : false; diff --git a/mod/journal/restorelib.php b/mod/journal/restorelib.php index 844b9148781..e7684241071 100644 --- a/mod/journal/restorelib.php +++ b/mod/journal/restorelib.php @@ -59,7 +59,9 @@ $newid = insert_record ("journal",$journal); //Do some output - echo "
  • ".get_string("modulename","journal")." \"".format_string(stripslashes($journal->name),true)."\"
  • "; + if (!defined('RESTORE_SILENTLY')) { + echo "
  • ".get_string("modulename","journal")." \"".format_string(stripslashes($journal->name),true)."\"
  • "; + } backup_flush(300); if ($newid) { @@ -132,9 +134,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -181,9 +185,11 @@ //Do some output $i++; if (($i+1) % 1 == 0) { - echo "."; - if (($i+1) % 20 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 20 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -211,9 +217,11 @@ //Do some output $i++; if (($i+1) % 1 == 0) { - echo "."; - if (($i+1) % 20 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 20 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -309,7 +317,9 @@ $status = true; break; default: - echo "action (".$log->module."-".$log->action.") unknow. Not restored
    "; //Debug + if (!defined('RESTORE_SILENTLY')) { + echo "action (".$log->module."-".$log->action.") unknow. Not restored
    "; //Debug + } break; } diff --git a/mod/label/restorelib.php b/mod/label/restorelib.php index b8aae4ea9fa..1bd7f57dba9 100644 --- a/mod/label/restorelib.php +++ b/mod/label/restorelib.php @@ -43,7 +43,9 @@ $newid = insert_record ("label",$label); //Do some output - echo "
  • ".get_string("modulename","label")." \"".format_string(stripslashes($label->name),true)."\"
  • "; + if (!defined('RESTORE_SILENTLY')) { + echo "
  • ".get_string("modulename","label")." \"".format_string(stripslashes($label->name),true)."\"
  • "; + } backup_flush(300); if ($newid) { @@ -80,14 +82,18 @@ $label->content = addslashes($result); $status = update_record("label", $label); if ($CFG->debug>7) { - echo '

    '.htmlentities($content).'
    changed to
    '.htmlentities($result).'

    '; + if (!defined('RESTORE_SILENTLY')) { + echo '

    '.htmlentities($content).'
    changed to
    '.htmlentities($result).'

    '; + } } } //Do some output if (($i+1) % 5 == 0) { - echo "."; - if (($i+1) % 100 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 100 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -127,7 +133,9 @@ } break; default: - echo "action (".$log->module."-".$log->action.") unknow. Not restored
    "; //Debug + if (!defined('RESTORE_SILENTLY')) { + echo "action (".$log->module."-".$log->action.") unknow. Not restored
    "; //Debug + } break; } diff --git a/mod/lesson/restorelib.php b/mod/lesson/restorelib.php index 1efc9d028c8..53f59937325 100644 --- a/mod/lesson/restorelib.php +++ b/mod/lesson/restorelib.php @@ -90,7 +90,9 @@ $newid = insert_record("lesson", $lesson); //Do some output - echo "
  • ".get_string("modulename","lesson")." \"".format_string(stripslashes($lesson->name),true)."\"
  • "; + if (!defined('RESTORE_SILENTLY')) { + echo "
  • ".get_string("modulename","lesson")." \"".format_string(stripslashes($lesson->name),true)."\"
  • "; + } backup_flush(300); if ($newid) { @@ -172,9 +174,11 @@ //Do some output if (($i+1) % 10 == 0) { - echo "."; - if (($i+1) % 200 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 200 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -300,9 +304,11 @@ //Do some output if (($i+1) % 10 == 0) { - echo "."; - if (($i+1) % 200 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 200 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -366,9 +372,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -417,9 +425,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -474,9 +484,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -522,9 +534,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -575,9 +589,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -642,9 +658,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -748,14 +766,18 @@ $page->contents = addslashes($result); $status = update_record("lesson_pages",$page); if ($CFG->debug>7) { - echo '

    '.htmlentities($content).'
    changed to
    '.htmlentities($result).'

    '; + if (!defined('RESTORE_SILENTLY')) { + echo '

    '.htmlentities($content).'
    changed to
    '.htmlentities($result).'

    '; + } } } //Do some output if (($i+1) % 5 == 0) { - echo "."; - if (($i+1) % 100 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 100 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -833,7 +855,9 @@ } break; default: - echo "action (".$log->module."-".$log->action.") unknow. Not restored
    "; //Debug + if (!defined('RESTORE_SILENTLY')) { + echo "action (".$log->module."-".$log->action.") unknow. Not restored
    "; //Debug + } break; } diff --git a/mod/quiz/question.php b/mod/quiz/question.php index 686332921dd..b51c7245b63 100644 --- a/mod/quiz/question.php +++ b/mod/quiz/question.php @@ -339,7 +339,7 @@ echo '
    '; print_simple_box_start('center'); - require('questiontypes/'.$QUIZ_QTYPES[$qtype]->name().'/editquestion.php'); + require_once('questiontypes/'.$QUIZ_QTYPES[$qtype]->name().'/editquestion.php'); print_simple_box_end(); if ($usehtmleditor) { diff --git a/mod/quiz/restorelib.php b/mod/quiz/restorelib.php index 95683c87e97..c20dee0edcc 100644 --- a/mod/quiz/restorelib.php +++ b/mod/quiz/restorelib.php @@ -146,10 +146,14 @@ //Do some output if ($newid) { - echo "
  • ".get_string('category', 'quiz')." \"".$quiz_cat->name."\"
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "
  • ".get_string('category', 'quiz')." \"".$quiz_cat->name."\"
    "; + } } else { //We must never arrive here !! - echo "
  • ".get_string('category', 'quiz')." \"".$quiz_cat->name."\" Error!
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "
  • ".get_string('category', 'quiz')." \"".$quiz_cat->name."\" Error!
    "; + } $status = false; } backup_flush(300); @@ -164,7 +168,9 @@ } else { $status = false; } - echo '
  • '; + if (!defined('RESTORE_SILENTLY')) { + echo ''; + } } return $status; @@ -315,9 +321,11 @@ //Do some output if (($i+1) % 2 == 0) { - echo "."; - if (($i+1) % 40 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 40 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -356,9 +364,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -416,9 +426,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -483,9 +495,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -536,9 +550,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -600,9 +616,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -648,9 +666,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -724,9 +744,11 @@ "answertext",$match_sub->answertext); //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -779,9 +801,11 @@ "positionkey",$multianswer->positionkey); //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -824,9 +848,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -871,9 +897,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -924,9 +952,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -1001,9 +1031,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -1056,9 +1088,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -1324,7 +1358,9 @@ $newid = insert_record ("quiz",$quiz); //Do some output - echo "
  • ".get_string("modulename","quiz")." \"".format_string(stripslashes($quiz->name),true)."\"
  • "; + if (!defined('RESTORE_SILENTLY')) { + echo "
  • ".get_string("modulename","quiz")." \"".format_string(stripslashes($quiz->name),true)."\"
  • "; + } backup_flush(300); if ($newid) { @@ -1390,9 +1426,11 @@ //Do some output if (($i+1) % 10 == 0) { - echo "."; - if (($i+1) % 200 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 200 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -1461,9 +1499,11 @@ //Do some output if (($i+1) % 10 == 0) { - echo "."; - if (($i+1) % 200 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 200 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -1534,9 +1574,11 @@ //Do some output if (($i+1) % 10 == 0) { - echo "."; - if (($i+1) % 200 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 200 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -1772,9 +1814,11 @@ //Do some output if (($i+1) % 10 == 0) { - echo "."; - if (($i+1) % 200 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 200 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -1919,9 +1963,11 @@ //Do some output if (($i+1) % 10 == 0) { - echo "."; - if (($i+1) % 200 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 200 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -2025,17 +2071,21 @@ $quiz->intro = addslashes($result); $status = update_record("quiz",$quiz); if ($CFG->debug>7) { - echo '

    '.htmlentities($content).'
    changed to
    '.htmlentities($result).'

    '; + if (!defined('RESTORE_SILENTLY')) { + echo '

    '.htmlentities($content).'
    changed to
    '.htmlentities($result).'

    '; + } } } //Do some output if (($i+1) % 5 == 0) { - echo "."; - if (($i+1) % 100 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 100 == 0) { + echo "
    "; + } } backup_flush(300); - } + } } } @@ -2069,9 +2119,11 @@ //Do some output $i++; if (($i+1) % 1 == 0) { - echo "."; - if (($i+1) % 20 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 20 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -2199,7 +2251,9 @@ } break; default: - echo "action (".$log->module."-".$log->action.") unknow. Not restored
    "; //Debug + if (!defined('RESTORE_SILENTLY')) { + echo "action (".$log->module."-".$log->action.") unknow. Not restored
    "; //Debug + } break; } diff --git a/mod/quiz/restorelibpre15.php b/mod/quiz/restorelibpre15.php index 3f705772220..53ee83303d6 100644 --- a/mod/quiz/restorelibpre15.php +++ b/mod/quiz/restorelibpre15.php @@ -132,10 +132,14 @@ //Do some output if ($newid) { - echo "
  • ".get_string('category', 'quiz')." \"".$quiz_cat->name."\"
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "
  • ".get_string('category', 'quiz')." \"".$quiz_cat->name."\"
    "; + } } else { - //We must never arrive here !! - echo "
  • ".get_string('category', 'quiz')." \"".$quiz_cat->name."\" Error!
    "; + if (!defined('RESTORE_SILENTLY')) { + //We must never arrive here !! + echo "
  • ".get_string('category', 'quiz')." \"".$quiz_cat->name."\" Error!
    "; + } $status = false; } backup_flush(300); @@ -150,7 +154,9 @@ } else { $status = false; } - echo '
  • '; + if (!defined('RESTORE_SILENTLY')) { + echo ''; + } } return $status; @@ -247,9 +253,11 @@ //Do some output if (($i+1) % 2 == 0) { - echo "."; - if (($i+1) % 40 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 40 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -350,9 +358,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -411,9 +421,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -481,9 +493,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -534,9 +548,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -601,9 +617,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -649,9 +667,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -725,9 +745,11 @@ "answertext",$match_sub->answertext); //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -770,9 +792,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -828,9 +852,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -888,9 +914,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -983,9 +1011,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -1262,7 +1292,9 @@ $newid = insert_record ("quiz",$quiz); //Do some output - echo "
  • ".get_string("modulename","quiz")." \"".format_string(stripslashes($quiz->name),true)."\"
  • "; + if (!defined('RESTORE_SILENTLY')) { + echo "
  • ".get_string("modulename","quiz")." \"".format_string(stripslashes($quiz->name),true)."\"
  • "; + } backup_flush(300); if ($newid) { @@ -1328,9 +1360,11 @@ //Do some output if (($i+1) % 10 == 0) { - echo "."; - if (($i+1) % 200 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 200 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -1399,9 +1433,11 @@ //Do some output if (($i+1) % 10 == 0) { - echo "."; - if (($i+1) % 200 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 200 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -1470,9 +1506,11 @@ //Do some output if (($i+1) % 10 == 0) { - echo "."; - if (($i+1) % 200 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 200 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -1718,9 +1756,11 @@ //Do some output if (($i+1) % 10 == 0) { - echo "."; - if (($i+1) % 200 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 200 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -1775,9 +1815,11 @@ //Do some output if (($i+1) % 10 == 0) { - echo "."; - if (($i+1) % 200 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 200 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -1821,9 +1863,11 @@ //Do some output $i++; if (($i+1) % 1 == 0) { - echo "."; - if (($i+1) % 20 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 20 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -1951,7 +1995,9 @@ } break; default: - echo "action (".$log->module."-".$log->action.") unknow. Not restored
    "; //Debug + if (!defined('RESTORE_SILENTLY')) { + echo "action (".$log->module."-".$log->action.") unknow. Not restored
    "; //Debug + } break; } diff --git a/mod/resource/restorelib.php b/mod/resource/restorelib.php index 6b832226364..e5505ec42d9 100644 --- a/mod/resource/restorelib.php +++ b/mod/resource/restorelib.php @@ -82,7 +82,9 @@ $newid = insert_record ("resource",$resource); //Do some output - echo "
  • ".get_string("modulename","resource")." \"".format_string(stripslashes($resource->name),true)."\"
  • "; + if (!defined('RESTORE_SILENTLY')) { + echo "
  • ".get_string("modulename","resource")." \"".format_string(stripslashes($resource->name),true)."\"
  • "; + } backup_flush(300); if ($newid) { @@ -196,15 +198,19 @@ $resource->summary = addslashes($result2); $status = update_record("resource",$resource); if ($CFG->debug>7) { - echo '

    '.htmlentities($content1).'
    changed to
    '.htmlentities($result1).'

    '; - echo '

    '.htmlentities($content2).'
    changed to
    '.htmlentities($result2).'

    '; + if (!defined('RESTORE_SILENTLY')) { + echo '

    '.htmlentities($content1).'
    changed to
    '.htmlentities($result1).'

    '; + echo '

    '.htmlentities($content2).'
    changed to
    '.htmlentities($result2).'

    '; + } } } //Do some output if (($i+1) % 5 == 0) { - echo "."; - if (($i+1) % 100 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 100 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -241,9 +247,11 @@ //Do some output $i++; if (($i+1) % 1 == 0) { - echo "."; - if (($i+1) % 20 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 20 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -300,7 +308,9 @@ $status = true; break; default: - echo "action (".$log->module."-".$log->action.") unknow. Not restored
    "; //Debug + if (!defined('RESTORE_SILENTLY')) { + echo "action (".$log->module."-".$log->action.") unknow. Not restored
    "; //Debug + } break; } diff --git a/mod/scorm/restorelib.php b/mod/scorm/restorelib.php index 534da7cae0b..748d6485697 100755 --- a/mod/scorm/restorelib.php +++ b/mod/scorm/restorelib.php @@ -113,7 +113,9 @@ //The structure is equal to the db, so insert the scorm $newid = insert_record ("scorm",$scorm); //Do some output - echo "
  • ".get_string("modulename","scorm")." \"".format_string(stripslashes($scorm->name),true)."\"
  • "; + if (!defined('RESTORE_SILENTLY')) { + echo "
  • ".get_string("modulename","scorm")." \"".format_string(stripslashes($scorm->name),true)."\"
  • "; + } backup_flush(300); if ($newid) { @@ -248,9 +250,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -327,9 +331,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -477,14 +483,18 @@ $scorm->summary = addslashes($result); $status = update_record("scorm",$scorm); if ($CFG->debug>7) { - echo '

    '.htmlentities($content).'
    changed to
    '.htmlentities($result).'

    '; + if (!defined('RESTORE_SILENTLY')) { + echo '

    '.htmlentities($content).'
    changed to
    '.htmlentities($result).'

    '; + } } } //Do some output if (($i+1) % 5 == 0) { - echo "."; - if (($i+1) % 100 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 100 == 0) { + echo "
    "; + } } backup_flush(300); } diff --git a/mod/survey/restorelib.php b/mod/survey/restorelib.php index 5b9c643b9dd..b243fc334ea 100644 --- a/mod/survey/restorelib.php +++ b/mod/survey/restorelib.php @@ -53,7 +53,9 @@ $newid = insert_record ("survey",$survey); //Do some output - echo "
  • ".get_string("modulename","survey")." \"".format_string(stripslashes($survey->name),true)."\"
  • "; + if (!defined('RESTORE_SILENTLY')) { + echo "
  • ".get_string("modulename","survey")." \"".format_string(stripslashes($survey->name),true)."\"
  • "; + } backup_flush(300); if ($newid) { @@ -119,9 +121,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -175,9 +179,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -281,17 +287,21 @@ $survey->intro = addslashes($result); $status = update_record("survey",$survey); if ($CFG->debug>7) { - echo '

    '.htmlentities($content).'
    changed to
    '.htmlentities($result).'

    '; + if (!defined('RESTORE_SILENTLY')) { + echo '

    '.htmlentities($content).'
    changed to
    '.htmlentities($result).'

    '; + } } } //Do some output if (($i+1) % 5 == 0) { - echo "."; - if (($i+1) % 100 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 100 == 0) { + echo "
    "; + } } backup_flush(300); - } + } } } @@ -390,7 +400,9 @@ } break; default: - echo "action (".$log->module."-".$log->action.") unknow. Not restored
    "; //Debug + if (!defined('RESTORE_SILENTLY')) { + echo "action (".$log->module."-".$log->action.") unknow. Not restored
    "; //Debug + } break; } diff --git a/mod/wiki/restorelib.php b/mod/wiki/restorelib.php index 13c60c4a6e0..39352fdfa7a 100644 --- a/mod/wiki/restorelib.php +++ b/mod/wiki/restorelib.php @@ -59,7 +59,9 @@ $newid = insert_record ("wiki",$wiki); //Do some output - echo "
  • ".get_string("modulename","wiki")." \"".format_string(stripslashes($wiki->name),true)."\"
  • "; + if (!defined('RESTORE_SILENTLY')) { + echo "
  • ".get_string("modulename","wiki")." \"".format_string(stripslashes($wiki->name),true)."\"
  • "; + } backup_flush(300); if ($newid) { @@ -125,9 +127,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -192,9 +196,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -350,14 +356,18 @@ $page->content = addslashes($result); $status = update_record("wiki_pages",$page); if ($CFG->debug>7) { - echo '

    '.htmlentities($content).'
    changed to
    '.htmlentities($result).'

    '; + if (!defined('RESTORE_SILENTLY')) { + echo '

    '.htmlentities($content).'
    changed to
    '.htmlentities($result).'

    '; + } } } //Do some output if (($i+1) % 5 == 0) { - echo "."; - if (($i+1) % 100 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 100 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -380,17 +390,21 @@ $wiki->summary = addslashes($result); $status = update_record("wiki",$wiki); if ($CFG->debug>7) { - echo '

    '.htmlentities($content).'
    changed to
    '.htmlentities($result).'

    '; + if (!defined('RESTORE_SILENTLY')) { + echo '

    '.htmlentities($content).'
    changed to
    '.htmlentities($result).'

    '; + } } } //Do some output if (($i+1) % 5 == 0) { - echo "."; - if (($i+1) % 100 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 100 == 0) { + echo "
    "; + } } backup_flush(300); - } + } } } diff --git a/mod/workshop/restorelib.php b/mod/workshop/restorelib.php index ae098198547..4c32bcbf54e 100644 --- a/mod/workshop/restorelib.php +++ b/mod/workshop/restorelib.php @@ -138,9 +138,11 @@ $newid = insert_record ("workshop",$workshop); //Do some output - echo "
  • ".get_string("modulename","workshop")." \"".format_string(stripslashes($workshop->name),true)."\"
  • "; + if (!defined('RESTORE_SILENTLY')) { + echo "
  • ".get_string("modulename","workshop")." \"".format_string(stripslashes($workshop->name),true)."\"
  • "; + } backup_flush(300); - + if ($newid) { //We have the newid, update backup_ids backup_putid($restore->backup_unique_code,$mod->modtype, @@ -194,9 +196,11 @@ //Do some output if (($i+1) % 10 == 0) { - echo "."; - if (($i+1) % 200 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 200 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -244,9 +248,11 @@ //Do some output if (($i+1) % 10 == 0) { - echo "."; - if (($i+1) % 200 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 200 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -288,9 +294,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -348,9 +356,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -422,9 +432,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -491,9 +503,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -537,9 +551,11 @@ //Do some output if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 1000 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -633,9 +649,11 @@ //Do some output $i++; if (($i+1) % 1 == 0) { - echo "."; - if (($i+1) % 20 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 20 == 0) { + echo "
    "; + } } backup_flush(300); } @@ -733,17 +751,21 @@ $workshop->description = addslashes($result); $status = update_record("workshop",$workshop); if ($CFG->debug>7) { - echo '

    '.htmlentities($content).'
    changed to
    '.htmlentities($result).'

    '; + if (!defined('RESTORE_SILENTLY')) { + echo '

    '.htmlentities($content).'
    changed to
    '.htmlentities($result).'

    '; + } } } //Do some output if (($i+1) % 5 == 0) { - echo "."; - if (($i+1) % 100 == 0) { - echo "
    "; + if (!defined('RESTORE_SILENTLY')) { + echo "."; + if (($i+1) % 100 == 0) { + echo "
    "; + } } backup_flush(300); - } + } } } @@ -928,7 +950,9 @@ } break; default: - echo "action (".$log->module."-".$log->action.") unknow. Not restored
    "; //Debug + if (!defined('RESTORE_SILENTLY')) { + echo "action (".$log->module."-".$log->action.") unknow. Not restored
    "; //Debug + } break; }