]> git.mjollnir.org Git - moodle.git/commitdiff
Some minor changes about the system to encode file.php calls included.
authorstronk7 <stronk7>
Thu, 6 May 2004 22:17:45 +0000 (22:17 +0000)
committerstronk7 <stronk7>
Thu, 6 May 2004 22:17:45 +0000 (22:17 +0000)
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.

backup/backup_scheduled.php
backup/backuplib.php
backup/restorelib.php

index 676d55660f003c80fb619ee27801fa9240200990..29b31379d713dffbafd70330b099534ecd12884b 100644 (file)
@@ -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;
 }
 
index ae349c567d7850c8a986a600c291ce3bce5be237..98a565e0f6d1e9720d3373a80813af7fae987352 100644 (file)
             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));
                 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));
 
     //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);
 
index 1a5ede01905dd6a50e56b9abd8a7016d779c567b..e6ba723c0e818bfeaed5b4c0c94c440e9499456f 100644 (file)
                         $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
 
     //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 
         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);