]> git.mjollnir.org Git - moodle.git/commitdiff
First Version. Do nothing but I saved it from accidental remove !!
authorstronk7 <stronk7>
Thu, 1 May 2003 00:45:40 +0000 (00:45 +0000)
committerstronk7 <stronk7>
Thu, 1 May 2003 00:45:40 +0000 (00:45 +0000)
backup/backup.html [new file with mode: 0644]
backup/backup.php [new file with mode: 0644]

diff --git a/backup/backup.html b/backup/backup.html
new file mode 100644 (file)
index 0000000..3f4a22a
--- /dev/null
@@ -0,0 +1,137 @@
+<?PHP //$Id$
+    //This page prints the backup form to select everything
+echo "aqui";
+echo $id;
+echo $launch;
+echo $cancel;
+   //Checks for the required files/functions to backup every mod
+    //And check if there is data about it on $form
+    $count = 0;
+    if ($allmods = get_records("modules") ) {
+        foreach ($allmods as $mod) {
+            $modname = $mod->name;
+            $modfile = "$mods_home/$modname/backuplib.php";
+            $modbackup = $modname."_backup_mods";
+            if (file_exists($modfile)) {
+               include_once($modfile);
+               if (function_exists($modbackup)) {
+                   $var = "exists_".$modname;
+                   $var = true;
+                   $count++;
+               }
+            }
+            //Check data
+            //Check module info
+            $var = "backup_".$modname;
+            if (!isset($var)) {
+                $var = 1;
+            }
+            //Check include user info
+            $var = "backup_user_info_".$modname;
+            if (!isset($var)) {
+                $var = 1;
+            }
+        }
+    }
+
+    //Check other parameters
+    if (!isset($ackup_users)) {
+        $ackup_users = 2;
+    }
+    if (!isset($ackup_logs)) {
+        $ackup_logs = 1;
+    }
+    if (!isset($ackup_user_files)) {
+        $ackup_user_files = 1;
+    }
+    if (!isset($ackup_course_files)) {
+        $ackup_course_files = 1;
+    }
+
+    if ($count == 0) {
+        error("No backupable modules are installed!");
+    }
+
+?>
+
+<form name="form" method="post" <?=$onsubmit ?> action="<?=$ME ?>">
+<table cellpadding=5>
+<?
+    if ($allmods = get_records("modules") ) {
+        foreach ($allmods as $mod) {
+            $modname = $mod->name;
+            $modbackup = $modname."_backup_mods";
+            //If exists the lib & function
+            $var = "exists_".$modname;
+            if ($var) {
+                //Print the full tr
+                echo "<tr>";
+                echo "<td align=\"right\"><P><B>";
+                echo get_string("include")." ". get_string("modulenameplural",$modname).":";
+                echo "</td><td>";
+                $backup_options[0] = get_string("no"); 
+                $backup_options[1] = get_string("yes");
+                $var = "backup_".$modname;
+                choose_from_menu($backup_options, $var, $var, "");
+                $backup_user_options[0] = get_string("withoutuserdata"); 
+                $backup_user_options[1] = get_string("withuserdata");
+                $var = "backup_user_info_".$modname;
+                choose_from_menu($backup_user_options, $var, $var, "");
+                echo "</td></tr>";
+            }
+        }
+        //Line
+        echo "<tr><td colspan=\"2\"><hr noshade size=\"1\"></td></tr>";
+
+        //Now print the Users tr
+        echo "<tr>";
+        echo "<td align=\"right\"><P><B>";
+        echo get_string("users").":";
+        echo "</td><td>";
+        $user_options[0] = get_string("all");
+        $user_options[1] = get_string("course");
+        $user_options[2] = get_string("needed");
+        choose_from_menu($user_options, "backup_users", $ackup_users, "");
+        echo "</td></tr>";
+
+        //Now print the Logs tr
+        echo "<tr>";
+        echo "<td align=\"right\"><P><B>";
+        echo get_string("logs").":";                                               
+        echo "</td><td>";
+        $log_options[0] = get_string("no");
+        $log_options[1] = get_string("yes"); 
+        choose_from_menu($log_options, "backup_logs", $ackup_logs, ""); 
+        echo "</td></tr>";
+
+        //Now print the User Files tr
+        echo "<tr>";
+        echo "<td align=\"right\"><P><B>";
+        echo get_string ("userfiles").":";
+        echo "</td><td>";
+        $user_file_options[0] = get_string("no"); 
+        $user_file_options[1] = get_string("yes"); 
+        choose_from_menu($user_file_options, "backup_user_files", $ackup_user_files, "");
+        echo "</td></tr>";
+
+        //Now print the Course Files tr
+        echo "<tr>";
+        echo "<td align=\"right\"><P><B>";
+        echo get_string ("coursefiles").":";
+        echo "</td><td>";
+        $course_file_options[0] = get_string("no");
+        $course_file_options[1] = get_string("yes");
+        choose_from_menu($course_file_options, "backup_course_files", $ackup_course_files, "");
+        echo "</td></tr>";
+    }
+?>
+</table>
+<BR>
+<CENTER>
+<input type="hidden" name=id     value="<? p($id) ?>">
+<input type="hidden" name=launch value="1">
+<input type="submit" value="<? print_string("savechanges") ?>">
+<input type="submit" name=cancel value="<? print_string("cancel") ?>">
+</CENTER>
+</FORM>
diff --git a/backup/backup.php b/backup/backup.php
new file mode 100644 (file)
index 0000000..1ed99e0
--- /dev/null
@@ -0,0 +1,77 @@
+<?PHP //$Id$
+    //This script is used to configure and execute the backup proccess.
+
+    //Define some globals for all the script
+
+    //MUST CHANGE WITH FINAL BACKUP LOCATION !! WITHOUT TRAILING SLASH !!
+    //ALL RELATIVE FROM THE LOCATION OF THE backup.php SCRIPT !!!
+
+    $moodle_home = "../../..";
+    $mods_home = "mod";
+
+    //END MUST CHANGE
+
+    //Units used
+    require_once ("$moodle_home/config.php");
+
+    //Optional variables    
+    optional_variable($id);       // course id
+
+    //Check login       
+    require_login();
+
+    //Check admin
+    //Check admin
+    if (!isadmin()) {
+    }
+
+    //Check site
+    if (!$site = get_site()) {
+        error("Site not found!");
+    }
+
+    //Get strings
+    $strcoursebackup = get_string("coursebackup");
+    $stradministration = get_string("administration");
+
+    //If no course has been selected
+    if (!$id) {
+        print_header("$site->shortname: $strcoursebackup", $site->fullname,
+                     "<A HREF=\"$moodle_home/$CFG->admin/index.php\">$stradministration</A> -> $strcoursebackup");
+
+        if ($courses = get_courses()) {
+            print_heading(get_string("choosecourse"));
+            print_simple_box_start("CENTER");
+            foreach ($courses as $course) {
+            echo "<A HREF=\"backup.php?id=$course->id\">$course->fullname ($course->shortname)</A><BR>";
+            }
+            print_simple_box_end();
+        } else {
+            print_heading(get_string("nocoursesyet"));
+            print_continue("../$CFG->admin/index.php");
+        }
+        print_footer();
+        exit;
+    }
+
+    //Get and check course
+    if (! $course = get_record("course", "id", $id)) {
+        error("Course ID was incorrect (can't find it)");
+    }
+    //Print header
+    print_header("$site->shortname: $strcoursebackup", $site->fullname,
+                 "<A HREF=\"$moodle_home/$CFG->admin/index.php\">$stradministration</A> ->
+                  <A HREF=\"backup.php\">$strcoursebackup</A> -> $course->fullname ($course->shortname)");
+
+    //Print form     
+    print_heading("$strcoursebackup: $course->fullname ($course->shortname)");
+    print_simple_box_start("center", "", "$THEME->cellheading");
+    //Set form initial values
+    //Call the form     
+    include_once("backup.html");
+    print_simple_box_end();
+
+    //Print footer  
+    print_footer();
+?>
+