From: stronk7 Date: Fri, 7 May 2004 23:40:41 +0000 (+0000) Subject: Changed the system to recode links to forums. Now it it detect X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=3a238a355a11d5ff2d148c047369db9870e2105f;p=moodle.git 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 !! --- diff --git a/backup/restorelib.php b/backup/restorelib.php index 36baf30e33..ffed41616c 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -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 "
  • ".get_string("modulenameplural",$name); + echo "
  • ".get_string ("to")." ".get_string("modulenameplural",$name); $status = $function_name($restore); } } diff --git a/backup/version.php b/backup/version.php index b745512366..e9799d1fa7 100644 --- a/backup/version.php +++ b/backup/version.php @@ -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 diff --git a/lang/en/moodle.php b/lang/en/moodle.php index e2de8dadfb..aee09f2e31 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -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'; diff --git a/mod/forum/restorelib.php b/mod/forum/restorelib.php index 73b89e066c..234a45927a 100644 --- a/mod/forum/restorelib.php +++ b/mod/forum/restorelib.php @@ -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); } } }