]> git.mjollnir.org Git - moodle.git/commitdiff
Changed the system to recode links to forums. Now it it detect
authorstronk7 <stronk7>
Fri, 7 May 2004 23:40:41 +0000 (23:40 +0000)
committerstronk7 <stronk7>
Fri, 7 May 2004 23:40:41 +0000 (23:40 +0000)
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 !!

backup/restorelib.php
backup/version.php
lang/en/moodle.php
mod/forum/restorelib.php

index 36baf30e339421031e94cfb1408d444ee2473ee7..ffed41616c30f30602437d6e0d7e28e80e495ec6 100644 (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);
                 }
             }
index b7455123667f22e99631bd39053fa9e4b1e097aa..e9799d1fa7aa2d20ba6be1de0b1d065641cdfe93 100644 (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
index e2de8dadfbf577572a4501e4ad86015d113c0fa6..aee09f2e314333776ecd770ff1b3f2f3c3cbac3f 100644 (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';
index 73b89e066c8061ca6d7b5e1663190c196300289e..234a45927ab7a9f6f8cc11d9d999abf35be643e6 100644 (file)
         //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
             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);
                 }
             }
         }
             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);
                 }
             }
         }
             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);
                 }
             }
         }
                 //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);
                 }
             }
         }
                 //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);
                 }
             }
         }