Changed the system to recode links to forums. Now it it detect

that the link doesn't belong to the course being restored, then
the original link is mantained.
With this, the backup/restore should be finished. Now some
tests to check everything !!
This commit is contained in:
stronk7
2004-05-07 23:40:41 +00:00
parent 3c01fbf4ba
commit 3a238a355a
4 changed files with 48 additions and 16 deletions
+1 -1
View File
@@ -94,7 +94,7 @@
//Check if the xxxx_decode_content_links_caller exists
$function_name = $name."_decode_content_links_caller";
if (function_exists($function_name)) {
echo "<li>".get_string("modulenameplural",$name);
echo "<li>".get_string ("to")." ".get_string("modulenameplural",$name);
$status = $function_name($restore);
}
}
+1 -1
View File
@@ -5,6 +5,6 @@
// database (backup_version) to determine whether upgrades should
// be performed (see db/backup_*.php)
$backup_version = 2004042800; // The current version is a date (YYYYMMDDXX)
$backup_version = 2004050800; // The current version is a date (YYYYMMDDXX)
$backup_release = "1.3 development"; // User-friendly version number
+1
View File
@@ -236,6 +236,7 @@ $string['datemostrecentfirst'] = 'Date - most recent first';
$string['datemostrecentlast'] = 'Date - most recent last';
$string['day'] = 'day';
$string['days'] = 'days';
$string['decodinginternallinks'] = 'Decoding internal links';
$string['defaultcoursefullname'] = 'Course Fullname 101';
$string['defaultcourseshortname'] = 'CF101';
$string['defaultcoursestudent'] = 'Student';
+45 -14
View File
@@ -680,10 +680,21 @@
//If found, then we are going to look for its new id (in backup tables)
if ($foundset[0]) {
//print_object($foundset); //Debug
//We get the needed variables here
$courseid = $restore->course_id;
//Now replace it
$result= preg_replace($searchstring,$CFG->wwwroot.'/mod/forum/index.php?id='.$courseid,$result);
//Iterate over foundset[2]. They are the old_ids
foreach($foundset[2] as $old_id) {
//We get the needed variables here (course id)
$rec = backup_getid($restore->backup_unique_code,"course",$old_id);
//Personalize the searchstring
$searchstring='/\$@(FORUMINDEX)\*('.$old_id.')@\$/';
//If it is a link to this course, update the link to its new location
if($rec->new_id) {
//Now replace it
$result= preg_replace($searchstring,$CFG->wwwroot.'/mod/forum/index.php?id='.$rec->new_id,$result);
} else {
//It's a foreign link so leave it as original
$result= preg_replace($searchstring,$restore->original_wwwroot.'/mod/forum/index.php?id='.$old_id,$result);
}
}
}
//Link to forum view by moduleid
@@ -698,11 +709,15 @@
foreach($foundset[2] as $old_id) {
//We get the needed variables here (course_modules id)
$rec = backup_getid($restore->backup_unique_code,"course_modules",$old_id);
//Personalize the searchstring
$searchstring='/\$@(FORUMVIEWBYID)\*('.$old_id.')@\$/';
//If it is a link to this course, update the link to its new location
if($rec->new_id) {
//Personalize the searchstring
$searchstring='/\$@(FORUMVIEWBYID)\*('.$old_id.')@\$/';
//Now replace it
$result= preg_replace($searchstring,$CFG->wwwroot.'/mod/forum/view.php?id='.$rec->new_id,$result);
} else {
//It's a foreign link so leave it as original
$result= preg_replace($searchstring,$restore->original_wwwroot.'/mod/forum/view.php?id='.$old_id,$result);
}
}
}
@@ -719,11 +734,15 @@
foreach($foundset[2] as $old_id) {
//We get the needed variables here (forum id)
$rec = backup_getid($restore->backup_unique_code,"forum",$old_id);
//Personalize the searchstring
$searchstring='/\$@(FORUMVIEWBYF)\*('.$old_id.')@\$/';
//If it is a link to this course, update the link to its new location
if($rec->new_id) {
//Personalize the searchstring
$searchstring='/\$@(FORUMVIEWBYF)\*('.$old_id.')@\$/';
//Now replace it
$result= preg_replace($searchstring,$CFG->wwwroot.'/mod/forum/view.php?f='.$rec->new_id,$result);
} else {
//It's a foreign link so leave it as original
$result= preg_replace($searchstring,$restore->original_wwwroot.'/mod/forum/view.php?f='.$old_id,$result);
}
}
}
@@ -740,11 +759,15 @@
foreach($foundset[2] as $old_id) {
//We get the needed variables here (discussion id)
$rec = backup_getid($restore->backup_unique_code,"forum_discussions",$old_id);
//Personalize the searchstring
$searchstring='/\$@(FORUMDISCUSSIONVIEW)\*('.$old_id.')@\$/';
//If it is a link to this course, update the link to its new location
if($rec->new_id) {
//Personalize the searchstring
$searchstring='/\$@(FORUMDISCUSSIONVIEW)\*('.$old_id.')@\$/';
//Now replace it
$result= preg_replace($searchstring,$CFG->wwwroot.'/mod/forum/discuss.php?d='.$rec->new_id,$result);
} else {
//It's a foreign link so leave it as original
$result= preg_replace($searchstring,$restore->original_wwwroot.'/mod/forum/discuss.php?d='.$old_id,$result);
}
}
}
@@ -763,11 +786,15 @@
//We get the needed variables here (discussion id and post id)
$rec = backup_getid($restore->backup_unique_code,"forum_discussions",$old_id);
$rec2 = backup_getid($restore->backup_unique_code,"forum_posts",$old_id2);
//Personalize the searchstring
$searchstring='/\$@(FORUMDISCUSSIONVIEWPARENT)\*('.$old_id.')\*('.$old_id2.')@\$/';
//If it is a link to this course, update the link to its new location
if($rec->new_id && $rec2->new_id) {
//Personalize the searchstring
$searchstring='/\$@(FORUMDISCUSSIONVIEWPARENT)\*('.$old_id.')\*('.$old_id2.')@\$/';
//Now replace it
$result= preg_replace($searchstring,$CFG->wwwroot.'/mod/forum/discuss.php?d='.$rec->new_id.'&parent='.$rec2->new_id,$result);
} else {
//It's a foreign link so leave it as original
$result= preg_replace($searchstring,$restore->original_wwwroot.'/mod/forum/discuss.php?d='.$old_id.'&parent='.$old_id2,$result);
}
}
}
@@ -786,11 +813,15 @@
//We get the needed variables here (discussion id and post id)
$rec = backup_getid($restore->backup_unique_code,"forum_discussions",$old_id);
$rec2 = backup_getid($restore->backup_unique_code,"forum_posts",$old_id2);
//Personalize the searchstring
$searchstring='/\$@(FORUMDISCUSSIONVIEWINSIDE)\*('.$old_id.')\*('.$old_id2.')@\$/';
//If it is a link to this course, update the link to its new location
if($rec->new_id && $rec2->new_id) {
//Personalize the searchstring
$searchstring='/\$@(FORUMDISCUSSIONVIEWINSIDE)\*('.$old_id.')\*('.$old_id2.')@\$/';
//Now replace it
$result= preg_replace($searchstring,$CFG->wwwroot.'/mod/forum/discuss.php?d='.$rec->new_id.'#'.$rec2->new_id,$result);
} else {
//It's a foreign link so leave it as original
$result= preg_replace($searchstring,$restore->original_wwwroot.'/mod/forum/discuss.php?d='.$old_id.'#'.$old_id2,$result);
}
}
}