//Return the start tag, the contents and the end tag
function full_tag($tag,$level=0,$endline=true,$content,$to_utf=true) {
+ //Here we encode absolute links
+ $content = backup_encode_absolute_links($content);
$st = start_tag($tag,$level,$endline);
$co="";
if ($to_utf) {
}
+ //This function encode things to make backup multi-site fully functional
+ //It does this conversions:
+ // - $CFG->wwwroot -----------------------------> $@WWWROOT@$
+ // - /file.php/$courseid -----------------------> /file.php/$@COURSEID@$
+ //
+ function backup_encode_absolute_links($content) {
+
+ global $CFG,$preferences;
+
+ $search = array ($CFG->wwwroot,
+ "/file.php/".$preferences->backup_course);
+
+ $replace = array ("$@WWWROOT@$",
+ "/file.php/$@COURSEID@$");
+
+ $result = str_replace($search,$replace,$content);
+
+ //if ($result != $content) { //Debug
+ // echo "\n<hr>".$content." \nchanged to \n".$result."<hr>\n"; //Debug
+ //} //Debug
+
+ return $result;
+ }
+
//This function copies all the needed files under the "users" directory to the "user_files"
//directory under temp/backup
function backup_copy_user_files ($preferences) {
//This function is used to add slashes and decode from UTF-8
//It's used intensivelly when restoring modules and saving them in db
function backup_todb ($data) {
- return addslashes(utf8_decode($data));
+ return restore_decode_absolute_links(addslashes(utf8_decode($data)));
}
//This function is used to check that every necessary function to
return $status;
}
+ //This function decode things to make restore multi-site fully functional
+ //It does this conversions:
+ // - $@WWWROOT@$ -------------------------------> $CFG->wwwroot
+ // - $@COURSEID@$ ------------------------------> $courseid
+ //
+ function restore_decode_absolute_links($content) {
+
+ global $CFG,$restore;
+
+ $search = array ("$@WWWROOT@$",
+ "$@COURSEID@$");
+
+ $replace = array ($CFG->wwwroot,
+ $restore->course_id);
+
+ $result = str_replace($search,$replace,$content);
+
+ //if ($result != $content) { //Debug
+ // echo "\n<hr>".$content." \nchanged to \n".$result."<hr>\n"; //Debug
+ //} //Debug
+
+ return $result;
+ }
+
//This function restores the userfiles from the temp (user_files) directory to the
//dataroot/users directory
function restore_user_files($restore) {
// database (backup_version) to determine whether upgrades should
// be performed (see db/backup_*.php)
-$backup_version = 2004032500; // The current version is a date (YYYYMMDDXX)
+$backup_version = 2004040100; // The current version is a date (YYYYMMDDXX)
-$backup_release = "1.2.1"; // User-friendly version number
+$backup_release = "1.3 development"; // User-friendly version number