From: stronk7 Date: Thu, 6 May 2004 22:17:45 +0000 (+0000) Subject: Some minor changes about the system to encode file.php calls included. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=4c49c802d0172f5184707b7ba06c00d848f41416;p=moodle.git Some minor changes about the system to encode file.php calls included. Solve an important issue about scheduled backups not working properly when encoding links... Added support for event->visible in backup & restore. TODO: Add wwwroot to backup/restore to use it when decoding. Change the system to encode forum calls. --- diff --git a/backup/backup_scheduled.php b/backup/backup_scheduled.php index 676d55660f..29b31379d7 100644 --- a/backup/backup_scheduled.php +++ b/backup/backup_scheduled.php @@ -462,6 +462,13 @@ function schedule_backup_course_execute($preferences,$starttime = 0) { $preferences->backup_version = $CFG->backup_version; $preferences->backup_release = $CFG->backup_release; + //Some parts of the backup doesn't know about $preferences, so we + //put a copy of it inside that CFG (always global) to be able to + //use it. Then, when needed I search for preferences inside CFG + //Used to avoid some problems in full_tag() when preferences isn't + //set globally (i.e. in scheduled backups) + $CFG->backup_preferences = $preferences; + //Check for temp and backup and backup_unique_code directory //Create them as needed schedule_backup_log($starttime,$preferences->backup_course," checking temp structures"); @@ -612,6 +619,9 @@ function schedule_backup_course_execute($preferences,$starttime = 0) { $status = clean_temp_data ($preferences); } + //Unset CFG->backup_preferences only needed in scheduled backups + unset ($CFG->backup_preferences); + return $status; } diff --git a/backup/backuplib.php b/backup/backuplib.php index ae349c567d..98a565e0f6 100644 --- a/backup/backuplib.php +++ b/backup/backuplib.php @@ -560,7 +560,7 @@ fwrite ($bf,full_tag("GUEST",3,false,$course->guest)); fwrite ($bf,full_tag("STARTDATE",3,false,$course->startdate)); fwrite ($bf,full_tag("NUMSECTIONS",3,false,$course->numsections)); - fwrite ($bf,full_tag("SHOWRECENT",3,false,$course->showrecent)); + //fwrite ($bf,full_tag("SHOWRECENT",3,false,$course->showrecent)); INFO: This is out in 1.3 fwrite ($bf,full_tag("MAXBYTES",3,false,$course->maxbytes)); fwrite ($bf,full_tag("SHOWREPORTS",3,false,$course->showreports)); fwrite ($bf,full_tag("GROUPMODE",3,false,$course->groupmode)); @@ -996,6 +996,7 @@ fwrite ($bf,full_tag("EVENTTYPE",4,false,$event->eventtype)); fwrite ($bf,full_tag("TIMESTART",4,false,$event->timestart)); fwrite ($bf,full_tag("TIMEDURATION",4,false,$event->timeduration)); + fwrite ($bf,full_tag("VISIBLE",4,false,$event->visible)); fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$event->timemodified)); //End event tag fwrite ($bf,end_tag("EVENT",3,true)); @@ -1114,20 +1115,24 @@ //This function encode things to make backup multi-site fully functional //It does this conversions: - // - $CFG->wwwroot -----------------------------> $@WWWROOT@$ - // - /file.php/$courseid -----------------------> /file.php/$@COURSEID@$ + // - $CFG->wwwroot/file.php/courseid ----------------------> $@FILEPHP@$ // - Links to forums everywhere (DB) are encoded. // function backup_encode_absolute_links($content) { global $CFG,$preferences; - //Now we encode calls to file.php or wwwroot - $search = array ($CFG->wwwroot, - "/file.php/".$preferences->backup_course); + //Check if preferences is ok. If it isn't set, we are + //in a scheduled_backup to we are able to get a copy + //from CFG->backup_preferences + if (!isset($preferences)) { + $preferences = $CFG->backup_preferences; + } + + //First, we check for every call to file.php inside the course + $search = array($CFG->wwwroot."/file.php/".$preferences->backup_course); - $replace = array ("$@WWWROOT@$", - "/file.php/$@COURSEID@$"); + $replace = array("$@FILEPHP@$"); $result = str_replace($search,$replace,$content); diff --git a/backup/restorelib.php b/backup/restorelib.php index 1a5ede0190..e6ba723c0e 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -1056,6 +1056,7 @@ $eve->eventtype = backup_todb($info['EVENT']['#']['EVENTTYPE']['0']['#']); $eve->timestart = backup_todb($info['EVENT']['#']['TIMESTART']['0']['#']); $eve->timeduration = backup_todb($info['EVENT']['#']['TIMEDURATION']['0']['#']); + $eve->visible = backup_todb($info['EVENT']['#']['VISIBLE']['0']['#']); $eve->timemodified = backup_todb($info['EVENT']['#']['TIMEMODIFIED']['0']['#']); //Now search if that event exists (by description and timestart field) in @@ -1107,8 +1108,7 @@ //This function decode things to make restore multi-site fully functional //It does this conversions: - // - $@WWWROOT@$ -------------------------------> $CFG->wwwroot - // - $@COURSEID@$ ------------------------------> $courseid + // - $@FILEPHP@$ -------------------------------> $CFG->wwwroot/file.php/courseid // //Note: Inter-activities linking is being implemented as a final //step in the restore execution, because we need to have it @@ -1118,11 +1118,9 @@ global $CFG,$restore; //Now decode wwwroot and file.php calls - $search = array ("$@WWWROOT@$", - "$@COURSEID@$"); + $search = array ("$@FILEPHP@$"); - $replace = array ($CFG->wwwroot, - $restore->course_id); + $replace = array ($CFG->wwwroot."/file.php/".$restore->course_id); $result = str_replace($search,$replace,$content);