]> git.mjollnir.org Git - moodle.git/commitdiff
Initial release of the configure backup.
authorstronk7 <stronk7>
Thu, 27 Nov 2003 23:28:29 +0000 (23:28 +0000)
committerstronk7 <stronk7>
Thu, 27 Nov 2003 23:28:29 +0000 (23:28 +0000)
It now uses backup_config instead of config.
Not finished !!

admin/backup.php [new file with mode: 0644]
admin/configure.php
admin/index.php
backup/config.html [new file with mode: 0644]
backup/lib.php
backup/version.php

diff --git a/admin/backup.php b/admin/backup.php
new file mode 100644 (file)
index 0000000..fdab034
--- /dev/null
@@ -0,0 +1,51 @@
+<?PHP  // $Id$
+       // backup.php - allows admin to edit all configuration variables for scheduled backups
+
+    require_once("../config.php");
+    require_once("../backup/lib.php");
+
+    require_login();
+
+    if (!isadmin()) {
+        error("Only an admin can use this page");
+    }
+
+    if (!$site = get_site()) {
+        error("Site isn't defined!");
+    }
+
+
+/// If data submitted, then process and store.
+
+    if ($config = data_submitted()) {
+        print_header();
+        foreach ($config as $name => $value) {
+            backup_set_config($name, $value);
+        }
+        redirect("$CFG->wwwroot/$CFG->admin/index.php", get_string("changessaved"), 1);
+        exit;
+    }
+
+/// Otherwise print the form.
+
+    $stradmin = get_string("administration");
+    $strconfiguration = get_string("configuration");
+    $strbackup = get_string("backup");
+
+    print_header("$site->shortname: $strconfiguration: $strbackup", $site->fullname,
+                  "<a href=\"index.php\">$stradmin</a> -> ".
+                  "<a href=\"configure.php\">$strconfiguration</a> -> ".
+                  "<a href=\"backup.php\">$strbackup</a>");
+
+    print_heading($strbackup);
+
+    print_simple_box("<center>".get_string("adminhelpbackup")."</center>", "center", "50%");
+    echo "<br />";
+
+    print_simple_box_start("center", "", "$THEME->cellheading");
+    include("$CFG->dirroot/backup/config.html");
+    print_simple_box_end();
+
+    print_footer();
+
+?>
index 79809452a32a574616ba14d9c33278a057c5cc9f..d4e4d7e8d8c948d4a7ff8281ddabaa7f55867ded 100644 (file)
@@ -32,6 +32,8 @@
                            get_string("adminhelplanguage"));
     $table->data[] = array("<b><a href=\"modules.php\">".get_string("managemodules")."</a></b>",
                            get_string("adminhelpmanagemodules"));
+    $table->data[] = array("<b><a href=\"backup.php\">".get_string("backup")."</a></b>",
+                           get_string("adminhelpbackup"));
 
     print_table($table);
     
index 02427c1567f695211c96a8815f4fed9d3c33e87b..b0cffd92f447d44f89b82ce2523cb82e6c1dbb07 100644 (file)
                     get_string("adminhelplanguage")."</font><br />";
     $configdata .= "<font size=+1>&nbsp;</font><a href=\"modules.php\">".get_string("managemodules")."</a> - <font size=1>".
                     get_string("adminhelpmanagemodules")."</font><br />";
+    $configdata .= "<font size=+1>&nbsp;</font><a href=\"backup.php\">".get_string("backup")."</a> - <font size=1>".
+                    get_string("adminhelpbackup")."</font><br />";
 
     $table->data[] = array("<font size=+1><b><a href=\"configure.php\">".get_string("configuration")."</a></b>", 
                             $configdata);
diff --git a/backup/config.html b/backup/config.html
new file mode 100644 (file)
index 0000000..baa21a3
--- /dev/null
@@ -0,0 +1,146 @@
+<?php 
+    //Get some strings
+
+    $yes = get_string("yes");
+    $no  = get_string("no");
+    $withuserdata = get_string("withuserdata");
+    $withoutuserdata = get_string("withoutuserdata");
+    $course = get_string("course");
+    $all = get_string("all");
+    $include = get_string("include");
+    $modules = get_string("modules");
+    //Get backup_config pairs
+    $backup_config =  backup_get_config();
+
+    //Checks backup_config pairs exist
+    if (empty($backup_config->backup_sche_modules)) {
+        $backup_config->backup_sche_modules = 1;
+    }
+    if (empty($backup_config->backup_sche_withuserdata)) {
+        $backup_config->backup_sche_withuserdata = 1;
+    }
+    if (empty($backup_config->backup_sche_users)) {
+        $backup_config->backup_sche_users = 1;
+    }
+    if (empty($backup_config->backup_sche_logs)) {
+        $backup_config->backup_sche_logs = 0;
+    }
+    if (empty($backup_config->backup_sche_userfiles)) {
+        $backup_config->backup_sche_userfiles = 1;
+    }
+    if (empty($backup_config->backup_sche_coursefiles)) {
+        $backup_config->backup_sche_coursefiles = 1;
+    }
+    if (empty($backup_config->backup_sche_weekdays)) {
+        $backup_config->backup_sche_weekdays = "0000000";
+    }
+
+print_object($backup_config);
+
+    //Yes/no array for use in yes/no menu
+    $yesno_array[0] = $no;
+    $yesno_array[1] = $yes;
+
+    //With user data/without user data array for use in menu
+    $withwithout_array[0] = $withoutuserdata;
+    $withwithout_array[1] = $withuserdata;
+
+    //Course/alla array for use in course/all menu
+    $courseall_array[0] = $all;
+    $courseall_array[1] = $course;
+?>
+<form method="post" action="backup.php" name="form">
+
+<table cellpadding=9 cellspacing=0 >
+<tr valign=top>
+    <td colspan = 3 align=center><strong><?php print_string("settings") ?></strong></td>
+</tr>
+<tr valign=top>
+    <td align=right><p><?php print_string("includemodules") ?>:</td>
+    <td nowrap>
+    <?php choose_from_menu($yesno_array, "backup_sche_modules", $backup_config->backup_sche_modules, "") ?>
+    <?php choose_from_menu($withwithout_array, "backup_sche_withuserdata", $backup_config->backup_sche_withuserdata, "") ?>
+    </td>
+    <td>
+    <?php print_string("backupincludemoduleshelp") ?>
+    </td>
+</tr>
+<tr valign=top>
+    <td align=right><p><?php print_string("users") ?>:</td>
+    <td>
+    <?php choose_from_menu($courseall_array, "backup_sche_users", $backup_config->backup_sche_users, "") ?>
+    </td>
+    <td>
+    <?php print_string("backupusershelp") ?>
+    </td>
+</tr>
+<tr valign=top>
+    <td align=right><p><?php print_string("logs") ?>:</td>
+    <td>
+    <?php choose_from_menu($yesno_array, "backup_sche_logs", $backup_config->backup_sche_logs, "") ?>
+    </td>
+    <td>
+    <?php print_string("backuplogshelp") ?>  
+    </td>
+</tr>
+<tr valign=top>
+    <td align=right><p><?php print_string("userfiles") ?>:</td>
+    <td>
+    <?php choose_from_menu($yesno_array, "backup_sche_userfiles", $backup_config->backup_sche_userfiles, "") ?>
+    </td>
+    <td>
+    <?php print_string("backupuserfileshelp") ?>
+    </td>
+</tr>
+<tr valign=top>
+    <td align=right><p><?php print_string("coursefiles") ?>:</td>
+    <td>
+    <?php choose_from_menu($yesno_array, "backup_sche_coursefiles", $backup_config->backup_sche_coursefiles, "") ?>
+    </td>
+    <td>
+    <?php print_string("backupcuoursefileshelp") ?>
+    </td>
+</tr>
+<tr valign=top>
+    <td colspan = 3 align=center><strong><?php print_string("schedule") ?></strong></td>
+</tr>
+<tr>
+    <td colspan=3 align=center>
+        <?php 
+            //Get first day of week from languaje files
+            //after searching the web I haven't find a sytem to retrieve it in php from locale info
+            $firstdayofweek = get_string("firstdayofweek");
+            //If it is empty ot it is different of 1, default to 0
+            if (empty($firstdayofweek) || $firstdayofweek != 1) {
+                $firstdayofweek = 0;
+            }
+            //Now create the timestamp of a well-know sunday (02/25/2001, my 31th birthday !!)
+            $onesunday = make_timestamp(2001,2,25);
+            $i = 0;
+            $day_names = "";
+            $check_names = "";
+            while ($i<7) {
+                $day_names[] = strftime("%A",$onesunday + (($firstdayofweek+$i)*86400));
+                if (substr($backup_config->backup_sche_weekdays,$i,1) == "1") {
+                    $strchecked = " checked";
+                } else {
+                    $strchecked = "";
+                }
+                $check_names[] = "<input type=\"checkbox\" name=\"dayofweek_$i\" value=\"1\"$strchecked>";
+                $i++;
+            }
+            $table->align = array("center","center","center","center","center","center","center");
+            $table->head = $day_names;
+            $table->data[] = $check_names;
+            print_table($table);
+        ?>
+    </td>
+</tr>
+<tr>
+    <td colspan=3 align=center>
+        <input type="submit" value="<?php print_string("savechanges") ?>"></td>
+</tr>
+</table>
+
+</form>
index b2d270fd51f59f9595d9b88ca9116f11822ca20c..cfec8597f6adeff0b96109beddcd77922817b309 100644 (file)
@@ -2,6 +2,28 @@
     //This file contains all the general function needed (file manipulation...)
     //not directly part of the backup/restore utility
 
+    //Sets a name/value pair in backup_config table
+    function backup_set_config($name, $value) {
+        if (get_field("backup_config", "name", "name", $name)) {
+            return set_field("backup_config", "value", $value, "name", $name);
+        } else {
+            $config->name = $name;
+            $config->value = $value;
+            return insert_record("backup_config", $config);
+        }
+    }
+
+    //Gets all the information from backup_config table
+    function backup_get_config() {
+        $backup_config = null;
+        if ($configs = get_records('backup_config')) {
+            foreach ($configs as $config) {
+                $backup_config[$config->name] = $config->value;
+            }
+        }
+        return $backup_config;
+    }
+
     //Delete old data in backup tables (if exists)
     //Two days seems to be apropiate
     function backup_delete_old_data() {
index ad7fcf707d7f22463590984b15b7bfbd1ac44eee..3bec877a676b6bf31a7dd5af268b373f8ac6a40f 100644 (file)
@@ -5,6 +5,6 @@
 // database (backup_version) to determine whether upgrades should
 // be performed (see db/backup_*.php)
 
-$backup_version = 2003112200;   // The current version is a date (YYYYMMDDXX)
+$backup_version = 2003112700;   // The current version is a date (YYYYMMDDXX)
 
 $backup_release = "1.2 development";  // User-friendly version number