]> git.mjollnir.org Git - moodle.git/commitdiff
Now the restore process is XHTMLised
authorstronk7 <stronk7>
Mon, 7 Feb 2005 23:28:52 +0000 (23:28 +0000)
committerstronk7 <stronk7>
Mon, 7 Feb 2005 23:28:52 +0000 (23:28 +0000)
backup/CHANGES_14_15.txt
backup/restore_execute.html
backup/restore_form.html
backup/restorelib.php
backup/version.php

index 714edc6f70ba157e5e3fe964a6e58f3ff9233845..fda9bf244586570c76baf8aa3e2120b05fa1a07a 100644 (file)
@@ -42,6 +42,6 @@ Now I show the specific detailed status of every item in the process:
 25. TODO: Add support for forum_read table in backup and restore.
 26. DONE: chat_users->course and chat_users->lang. No changes required!
 27. PROG: Make the backup/restore/config/logs/index.php XHTML 1.0 Transitional.
-          Done in manual backups, config and logs
+          Done in manual backups, config, logs and restore.
 Eloy (stronk7)
 23-01-2004
index 4031b00f2cbee2349f4685b2947c36291ec61a2c..5490bc89e622b3b26d74f5bd560ce27ba659defc 100644 (file)
         //Print course fullname and shortname and category
         if ($status) {
             echo "<ul>";
-            echo "<li>".$course_header->course_fullname." (".$course_header->course_shortname.")";
-            echo "<li>".get_string("category").": ".$course_header->category->name;
+            echo "<li>".$course_header->course_fullname." (".$course_header->course_shortname.")".'</li>';
+            echo "<li>".get_string("category").": ".$course_header->category->name.'</li>';
             if (!empty($oldidnumber)) {
                 echo "<li>".get_string("nomoreidnumber","moodle",$oldidnumber)."</li>";
             }
-            echo "</ul>";
+            echo "</ul></li>";
             //Put the destination course_id
             $restore->course_id = $course_header->course_id;
         }
         if ($course) {
             echo "<li>".get_string("usingexistingcourse"); 
             echo "<ul>";
-            echo "<li>".get_string("from").": ".$course_header->course_fullname." (".$course_header->course_shortname.")";
-            echo "<li>".get_string("to").": ".$course->fullname." (".$course->shortname.")";
+            echo "<li>".get_string("from").": ".$course_header->course_fullname." (".$course_header->course_shortname.")".'</li>';
+            echo "<li>".get_string("to").": ".$course->fullname." (".$course->shortname.")".'</li>';
             if (($restore->deleting)) {
-                echo "<li>".get_string("deletingexistingcoursedata");
+                echo "<li>".get_string("deletingexistingcoursedata").'</li>';
             } else {
-                echo "<li>".get_string("addingdatatoexisting");
+                echo "<li>".get_string("addingdatatoexisting").'</li>';
             }
-            echo "</ul>";
+            echo "</ul></li>";
             //If we have selected to restore deleting, we do it now.
             if ($restore->deleting) {
-                echo "<li>".get_string("deletingolddata");
+                echo "<li>".get_string("deletingolddata").'</li>';
                 $status = remove_course_contents($restore->course_id,false) and 
                           delete_dir_contents($CFG->dataroot."/".$restore->course_id,"backupdata");
                 if ($status) {
     if($status) {
         //If we are deleting and bringing into a course or making a new course, same situation
         if($restore->restoreto == 0 || $restore->restoreto == 2) {
-            echo '<li>'.get_string('creatingblocks');
+            echo '<li>'.get_string('creatingblocks').'</li>';
             if (!$status = restore_create_blocks($restore, $info->backup_block_format, $course_header->blockinfo, $xml_file)) {
                 notify('Error while creating the course blocks');
             }
     if ($status) {
         //Into new course
         if ($restore->restoreto == 2) {
-            echo "<li>".get_string("creatingsections");
+            echo "<li>".get_string("creatingsections").'</li>';
             if (!$status = restore_create_sections($restore,$xml_file)) {
                 notify("Error creating sections in the existing course.");
             }
         //Into existing course
         } else if ($restore->restoreto == 0 or $restore->restoreto == 1) {
-            echo "<li>".get_string("checkingsections");
+            echo "<li>".get_string("checkingsections").'</li>';
             if (!$status = restore_create_sections($restore,$xml_file)) {
                 notify("Error creating sections in the existing course.");
             }
                 //Now print information gathered
                 echo " (".get_string("new").": ".$new_count.", ".get_string("existing").": ".$exists_count.")";
                 echo "<ul>";
-                echo "<li>".get_string("students").": ".$student_count;
-                echo "<li>".get_string("teachers").": ".$teacher_count;
+                echo "<li>".get_string("students").": ".$student_count.'</li>';
+                echo "<li>".get_string("teachers").": ".$teacher_count.'</li>';
                 echo "</ul>";
             } else {
                 notify("No users were found!");
     if ($status and $restore->metacourse) {
         //Only to new courses!
         if ($restore->restoreto == 2) {
-            echo "<li>".get_string("creatingmetacoursedata");
+            echo "</li><li>".get_string("creatingmetacoursedata");
             if (!$status = restore_create_metacourse($restore,$xml_file)) {
                 notify("Error creating metacourse in the course.");
             }
 
     //Now create categories and questions as needed (STEP1)
     if ($status and ($restore->mods['quiz']->restore)) {
-         echo "<li>".get_string("creatingcategoriesandquestions")."<br />";
-         if (!$status = restore_create_questions($restore,$xml_file)) {
-             notify("Could not restore categories and questions!");
-         }
+        echo "</li><li>".get_string("creatingcategoriesandquestions")."</li>";
+        if (!$status = restore_create_questions($restore,$xml_file)) {
+            notify("Could not restore categories and questions!");
+        }
     }
 
     //Now create user_files as needed
     if ($status and ($restore->user_files)) {
-        echo "<li>".get_string("copyinguserfiles")."<br />";
+        echo "<li>".get_string("copyinguserfiles");
         if (!$status = restore_user_files($restore)) {
             notify("Could not restore user files!");
         }
             //Inform about user dirs created from backup
             echo "<ul>";
             echo "<li>".get_string("userzones").": ".$status;
-            echo "</ul>";
+            echo "</li></ul>";
         }
     }
 
     //Now create course files as needed
     if ($status and ($restore->course_files)) {
-        echo "<li>".get_string("copyingcoursefiles")."<br />";
+        echo "</li><li>".get_string("copyingcoursefiles")."</li>";
         if (!$status = restore_course_files($restore)) {
             notify("Could not restore course files!");
         }
 
     //Now create scales as needed
     if ($status) {
-        echo "<li>".get_string("creatingscales");
+        echo "<li>".get_string("creatingscales").'</li>';
         if (!$status = restore_create_scales($restore,$xml_file)) {
             notify("Could not restore custom scales!");
         }
 
     //Now create groups as needed
     if ($status) {
-        echo "<li>".get_string("creatinggroups");
+        echo "<li>".get_string("creatinggroups").'</li>';
         if (!$status = restore_create_groups($restore,$xml_file)) {
             notify("Could not restore groups!");
         }
 
     //Now create events as needed
     if ($status) {
-        echo "<li>".get_string("creatingevents");
+        echo "<li>".get_string("creatingevents").'</li>';
         if (!$status = restore_create_events($restore,$xml_file)) {
             notify("Could not restore course events!");
         }
 
     //Now create log entries as needed
     if ($status and ($restore->logs)) {
-        echo "<li>".get_string("creatinglogentries");
+        echo "</li><li>".get_string("creatinglogentries");
         if (!$status = restore_create_logs($restore,$xml_file)) {
             notify("Could not restore logs!");
         }
 
     //Now, if all is OK, adjust the instance field in course_modules !!
     if ($status) {
-        echo "<li>".get_string("checkinginstances");
+        echo "</li><li>".get_string("checkinginstances").'</li>';
         if (!$status = restore_check_instances($restore)) {
             notify("Could not adjust instances in course_modules!");
         }
 
     //Now, if all is OK, adjust activity events
     if ($status) {
-        echo "<li>".get_string("refreshingevents");
+        echo "<li>".get_string("refreshingevents").'</li>';
         if (!$status = restore_refresh_events($restore)) {
             notify("Could not refresh events for activities!");
         }
     //   - course modinfo field 
     //   - categories table
     if ($status) {
-        echo "<li>".get_string("checkingcourse");
+        echo "</li><li>".get_string("checkingcourse").'</li>';
         //modinfo field
         rebuild_course_cache($restore->course_id);
         //categories table
 
     //Cleanup temps (files and db)
     if ($status) {
-        echo "<li>".get_string("cleaningtempdata");
+        echo "<li>".get_string("cleaningtempdata").'</li>';
         if (!$status = clean_temp_data ($restore)) {
             notify("Could not clean up temporary data from files and database");
         }
 
 
     //End the main table     
-    echo "</tr></td>";
+    echo "</td></tr>";
     echo "</table>";
 
     if (!$status) {
     if (!$restore->importing) {
         echo $output;
         //Print final message
-        print_simple_box(get_string("restorefinished"),"CENTER");
+        print_simple_box(get_string("restorefinished"),"center");
     } else {
-        print_simple_box(get_string("importdatafinished"),"CENTER");
+        print_simple_box(get_string("importdatafinished"),"center");
         unset($SESSION->restore);
     }
     print_continue("$CFG->wwwroot/course/view.php?id=".$restore->course_id);
index 625fd91c72e4a4569fab53333592aa797e5fc321..9b00a176982017198e8689805d624ea76b54b289 100644 (file)
 
 ?>
 
-<script language="JavaScript">
+<script language="JavaScript" type="text/javascript">
 <!--
 function selectItemInMenuByName(formId, menuName, selectIndex ) {
     myForm = document.getElementById(formId)
@@ -124,7 +124,7 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) {
     //First, course destination
     //Print the full tr
     echo "<tr>";
-    echo "<td align=\"right\"><p><b>";
+    echo "<td align=\"right\"><b>";
     echo get_string("restoreto").":</b>";
     echo "</td><td>";
     if (isteacheredit($id) and !iscreator()) {
@@ -139,7 +139,7 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) {
     choose_from_menu($restore_restoreto_options, "restore_restoreto", $restore_restoreto, "");
     echo "</td></tr>";
     //Line
-    echo "<tr><td colspan=\"2\"><hr noshade size=\"1\"></td></tr>";
+    echo "<tr><td colspan=\"2\"><hr /></td></tr>";
     //Now, check modules and info and show posibilities
     if ($allmods = get_records("modules") ) {
         //Print option to select/deselect every "with user info" popup. For Gustav, lol, Eloy :-)
@@ -152,7 +152,7 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) {
              get_string("none")."</a>";
         echo "</font></td>";
         echo "</tr>";
-        echo "<tr><td colspan=\"2\"><hr noshade size=\"1\"></td></tr>";
+        echo "<tr><td colspan=\"2\"><hr /></td></tr>";
         foreach ($allmods as $mod) {
             $modname = $mod->name;
             $modrestore = $modname."_restore_mods";
@@ -166,9 +166,9 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) {
                     if (isset($info->mods[$modname]) && $info->mods[$modname]->backup == "true") {
                         //Print the full tr
                         echo "<tr>";
-                        echo "<td align=\"right\"><p><b>";
+                        echo "<td align=\"right\"><b>";
                         echo get_string("include")." ". get_string("modulenameplural",$modname).":";
-                        echo "</td><td>";
+                        echo "</b></td><td>";
                         $restore_options[0] = get_string("no"); 
                         $restore_options[1] = get_string("yes");
                         choose_from_menu($restore_options, $restore_var, $$restore_var, "");
@@ -181,33 +181,33 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) {
                         } else {
                             //Module haven't userdata
                             echo get_string("withoutuserdata");
-                            echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\">";
+                            echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\" />";
                         }
                         echo "</td></tr>";
                     } else {
                         //Module isn't restorable
-                        echo "<input type=\"hidden\" name=\"$restore_var\" value=\"0\">";
-                        echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\">";
+                        echo "<input type=\"hidden\" name=\"$restore_var\" value=\"0\" />";
+                        echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\" />";
                     }
                 } else {
                     //Module isn't restorable
-                    echo "<input type=\"hidden\" name=\"$restore_var\" value=\"0\">";
-                    echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\">";
+                    echo "<input type=\"hidden\" name=\"$restore_var\" value=\"0\" />";
+                    echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\" />";
                 }
             } else {
                 //Module isn't restorable
-                echo "<input type=\"hidden\" name=\"$restore_var\" value=\"0\">";
-                echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\">";
+                echo "<input type=\"hidden\" name=\"$restore_var\" value=\"0\" />";
+                echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\" />";
             }
         }
         //Line
-        echo "<tr><td colspan=\"2\"><hr noshade size=\"1\"></td></tr>";
+        echo "<tr><td colspan=\"2\"><hr /></td></tr>";
 
         //Now print the Metacourse tr
         echo "<tr>";
-        echo "<td align=\"right\"><p><b>";
+        echo "<td align=\"right\"><b>";
         echo get_string("metacourse").":";                                               
-        echo "</td><td>";
+        echo "</b></td><td>";
         //If metacourse are in the backup file, show menu, else fixed to no
         if ($info->backup_metacourse == "true") {
             $metacourse_options[0] = get_string("no");
@@ -215,14 +215,14 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) {
             choose_from_menu($metacourse_options, "restore_metacourse", $restore_metacourse, ""); 
         } else {
             echo get_string("no");
-            echo "<input type=\"hidden\" name=\"restore_metacourse\" value=\"0\">";
+            echo "<input type=\"hidden\" name=\"restore_metacourse\" value=\"0\" />";
         }
         echo "</td></tr>";
         //Now print the Users tr
         echo "<tr>";
-        echo "<td align=\"right\"><p><b>";
+        echo "<td align=\"right\"><b>";
         echo get_string("users").":";
-        echo "</td><td>";
+        echo "</b></td><td>";
         //If some user is present in the backup file
         if ($info->backup_users == "all" or $info->backup_users == "course") {
             //If all users are in the backup file
@@ -234,16 +234,16 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) {
             choose_from_menu($user_options, "restore_users", $restore_users, "");
         } else {
             echo get_string("none");
-            echo "<input type=\"hidden\" name=\"restore_users\" value=\"2\">";
+            echo "<input type=\"hidden\" name=\"restore_users\" value=\"2\" />";
 
         }
         echo "</td></tr>";
 
         //Now print the Logs tr
         echo "<tr>";
-        echo "<td align=\"right\"><p><b>";
+        echo "<td align=\"right\"><b>";
         echo get_string("logs").":";                                               
-        echo "</td><td>";
+        echo "</b></td><td>";
         //If logs are in the backup file, show menu, else fixed to no
         if ($info->backup_logs == "true") {
             $log_options[0] = get_string("no");
@@ -251,15 +251,15 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) {
             choose_from_menu($log_options, "restore_logs", $restore_logs, ""); 
         } else {
             echo get_string("no");
-            echo "<input type=\"hidden\" name=\"restore_logs\" value=\"0\">";
+            echo "<input type=\"hidden\" name=\"restore_logs\" value=\"0\" />";
         }
         echo "</td></tr>";
 
         //Now print the User Files tr
         echo "<tr>";
-        echo "<td align=\"right\"><p><b>";
+        echo "<td align=\"right\"><b>";
         echo get_string ("userfiles").":";
-        echo "</td><td>";
+        echo "</b></td><td>";
         //If user files are in the backup file, show menu, else fixed to no
         if ($info->backup_user_files == "true") {
             $user_file_options[0] = get_string("no"); 
@@ -267,15 +267,17 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) {
             choose_from_menu($user_file_options, "restore_user_files", $restore_user_files, "");
         } else {
             echo get_string("no");
-            echo "<input type=\"hidden\" name=\"restore_user_files\" value=\"0\">";
+            echo "<input type=\"hidden\" name=\"restore_user_files\" value=\"0\" />";
         }
         echo "</td></tr>";
 
         //Now print the Course Files tr
         echo "<tr>";
-        echo "<td align=\"right\"><p><b>";
+        echo "<td align=\"right\"><b>";
         echo get_string ("coursefiles").":";
-        echo "</td><td>";
+        echo "</b></td><td>";
+        echo "<input type=\"hidden\" name=\"backup_unique_code\" value=\"$backup_unique_code\" />";
+        echo "<input type=\"hidden\" name=\"file\" value=\"$file\" />";
         //If course files are in the backup file, show menu, else fixed to no
         if ($info->backup_course_files == "true") {
             $course_file_options[0] = get_string("no");
@@ -283,19 +285,17 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) {
             choose_from_menu($course_file_options, "restore_course_files", $restore_course_files, "");
         } else {
             echo get_string("no");
-            echo "<input type=\"hidden\" name=\"restore_course_files\" value=\"0\">";
+            echo "<input type=\"hidden\" name=\"restore_course_files\" value=\"0\" />";
         }
         echo "</td></tr>";
-        echo "<input type=\"hidden\" name=\"backup_unique_code\" value=\"$backup_unique_code\">";
-        echo "<input type=\"hidden\" name=\"file\" value=\"$file\">";
     }
 ?>
 </table>
 <br />
 <center>
-<input type="hidden" name="id"     value="<?php  p($id) ?>">
-<input type="hidden" name="launch" value="check">
-<input type="submit" value="<?php  print_string("continue") ?>">
-<input type="submit" name="cancel" value="<?php  print_string("cancel") ?>">
+<input type="hidden" name="id"     value="<?php  p($id) ?>" />
+<input type="hidden" name="launch" value="check" />
+<input type="submit" value="<?php  print_string("continue") ?>" />
+<input type="submit" name="cancel" value="<?php  print_string("cancel") ?>" />
 </center>
 </form>
index 35009e5f459d1df2d8ae51ee283880b78867f3f2..801974ebdc4ae3beca8d61030c419cfe2c60d3f8 100644 (file)
                 if (function_exists($function_name)) {
                     echo "<li>".get_string ("to")." ".get_string("modulenameplural",$name);
                     $status = $function_name($restore);
+                    echo '</li>';
                 }
             }
         }
 
         //Now I'm going to decode to their new location all the links in wiki texts
         //having the syntax " modulename:moduleid".
-        echo "<li>wiki";
+        echo "<li>Wiki";
         $status = restore_decode_wiki_texts($restore);
+        echo '</li>';
 
         echo "</ul>";
 
         //FORUM: Decode every POST (message) in the course
         //Check we are restoring forums
         if ($restore->mods['forum']->restore == 1) {
-            echo "<li>".get_string("from")." ".get_string("modulenameplural","forum");
+            echo "<li>".get_string("from")." ".get_string("modulenameplural","forum").'</li>';
             //Get all course posts being restored
             if ($posts = get_records_sql ("SELECT p.id, p.message
                                        FROM {$CFG->prefix}forum_posts p,
 
         //Check we are restoring resources
         if ($restore->mods['resource']->restore == 1) {
-            echo "<li>".get_string("from")." ".get_string("modulenameplural","resource");
+            echo "<li>".get_string("from")." ".get_string("modulenameplural","resource").'</li>';
             //Get all course resources of type='text' and options=FORMAT_WIKI being restored
             if ($resources = get_records_sql ("SELECT r.id, r.alltext
                                        FROM {$CFG->prefix}resource r,
         $status = true;
         if ($info) {
             //This is tha align to every ingo table      
-            $table->align = array ("RIGHT","LEFT");
+            $table->align = array ("right","left");
             //This is the nowrap clause 
-            $table->wrap = array ("","NOWRAP");
+            $table->wrap = array ("","nowrap");
             //The width
             $table->width = "70%";
             //Put interesting info in table
         $status = true;
         if ($course_header) {
             //This is tha align to every ingo table
-            $table->align = array ("RIGHT","LEFT");
+            $table->align = array ("right","left");
             //The width
             $table->width = "70%";
             //Put interesting course header in table
         //from backup_ids (calling every mod restore function)
         if ($info) {
             if ($info !== true) {
+                echo '<ul>';
                 //Iterate over each module
                 foreach ($info as $mod) {
                     $modrestore = $mod->modtype."_restore_mods";
                         $status = false;
                     }
                 }
+                echo '</ul>';
             }
         } else {
             $status = false;
         
         //Now check and create the backup dir (if it doesn't exist)
         if (empty($silent)) {
-            echo "<li>".get_string("creatingtemporarystructures");
+            echo "<li>".get_string("creatingtemporarystructures").'</li>';
         }
         $status = check_and_create_backup_dir($backup_unique_code);
         //Empty dir
         //Now delete old data and directories under dataroot/temp/backup
         if ($status) {   
             if (empty($silent)) {
-                echo "<li>".get_string("deletingolddata");
+                echo "<li>".get_string("deletingolddata").'</li>';
             }
             $status = backup_delete_old_data();
         }
         //Now copy he zip file to dataroot/temp/backup/backup_unique_code
         if ($status) {
             if (empty($silent)) {
-                echo "<li>".get_string("copyingzipfile");
+                echo "<li>".get_string("copyingzipfile").'</li>';
             }
             if (! $status = backup_copy_file($file,$CFG->dataroot."/temp/backup/".$backup_unique_code."/".basename($file))) {
                 notify("Error copying backup file. Invalid name or bad perms.");
         //Now unzip the file
         if ($status) {
             if (empty($silent)) {
-                echo "<li>".get_string("unzippingbackup");
+                echo "<li>".get_string("unzippingbackup").'</li>';
             }
             if (! $status = restore_unzip ($CFG->dataroot."/temp/backup/".$backup_unique_code."/".basename($file))) {
                 notify("Error unzipping backup file. Invalid zip file.");
         if ($status) {
             $xml_file  = $CFG->dataroot."/temp/backup/".$backup_unique_code."/moodle.xml";
             if (empty($silent)) {
-                echo "<li>".get_string("checkingbackup");
+                echo "<li>".get_string("checkingbackup").'</li>';
             }
             if (! $status = restore_check_moodle_file ($xml_file)) {
                 notify("Error checking backup file. Invalid or corrupted.");
         //Now read the info tag (all)
         if ($status) {
             if (empty($silent)) {
-                echo "<li>".get_string("readinginfofrombackup");
+                echo "<li>".get_string("readinginfofrombackup").'</li>';
             }
             //Reading info from file
             $info = restore_read_xml_info ($xml_file);
             echo "</ul>";
             
             //End the main table
-            echo "</tr></td>";
+            echo "</td></tr>";
             echo "</table>";
         }
         
index 1bef28d4813459514887cbbc75c72b8ed93e9c9b..01484b779992ac2b5d50f89f4f658041ed1b77ee 100644 (file)
@@ -5,6 +5,6 @@
 // database (backup_version) to determine whether upgrades should
 // be performed (see db/backup_*.php)
 
-$backup_version = 2005020500;   // The current version is a date (YYYYMMDDXX)
+$backup_version = 2005020700;   // The current version is a date (YYYYMMDDXX)
 
 $backup_release = "1.5 development";  // User-friendly version number