]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-17847 moev backup_config to config_plugin table
authorskodak <skodak>
Sun, 11 Jan 2009 15:49:35 +0000 (15:49 +0000)
committerskodak <skodak>
Sun, 11 Jan 2009 15:49:35 +0000 (15:49 +0000)
backup/lib.php
lib/adminlib.php
lib/db/install.xml
lib/db/upgrade.php
lib/moodlelib.php
version.php

index f794d7141781d9bb3e5cedb38056ac239d8e964b..e6c668bb0f81515594e35376da8c67314cbec0da 100644 (file)
@@ -4,30 +4,14 @@
 
     require_once($CFG->dirroot.'/lib/uploadlib.php');
 
-    //Sets a name/value pair in backup_config table
+    //Sets a name/value pair in config_plugin table
     function backup_set_config($name, $value) {
-        global $DB;
-
-        if ($DB->get_field("backup_config", "name", array("name"=>$name))) {
-            return $DB->set_field("backup_config", "value", $value, array("name"=>$name));
-        } else {
-            $config = new object();
-            $config->name  = $name;
-            $config->value = $value;
-            return $DB->insert_record("backup_config", $config);
-        }
+        return set_config($name, $value, 'backup');
     }
 
-    //Gets all the information from backup_config table
+    //Gets all the information from config_plugin table
     function backup_get_config() {
-        global $DB;
-
-        $backup_config = null;
-        if ($configs = $DB->get_records("backup_config")) {
-            foreach ($configs as $config) {
-                $backup_config[$config->name] = $config->value;
-            }
-        }
+        $backup_config = get_config('backup');
         return (object)$backup_config;
     }
 
index 90b2ee35b7b125eca4255556d8767e3646835b36..78e351dd5558b8f3f7767797ae4d1a1e28d79e12 100644 (file)
@@ -1830,16 +1830,7 @@ class admin_setting {
 
     function config_read($name) {
         global $CFG;
-        if ($this->plugin === 'backup') {
-            require_once($CFG->dirroot.'/backup/lib.php');
-            $backupconfig = backup_get_config();
-            if (isset($backupconfig->$name)) {
-                return $backupconfig->$name;
-            } else {
-                return NULL;
-            }
-
-        } else if (!empty($this->plugin)) {
+        if (!empty($this->plugin)) {
             $value = get_config($this->plugin, $name);
             return $value === false ? NULL : $value;
 
@@ -1853,13 +1844,7 @@ class admin_setting {
     }
 
     function config_write($name, $value) {
-        global $CFG;
-        if ($this->plugin === 'backup') {
-            require_once($CFG->dirroot.'/backup/lib.php');
-            return (boolean)backup_set_config($name, $value);
-        } else {
-            return (boolean)set_config($name, $value, $this->plugin);
-        }
+        return (boolean)set_config($name, $value, $this->plugin);
     }
 
     /**
index 41cd35ec05a463cb07b1d0822213e3fac5b6247e..cc5939ade6986016b57b53dd413ede7571960dfd 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="lib/db" VERSION="20090110" COMMENT="XMLDB file for core Moodle tables"
+<XMLDB PATH="lib/db" VERSION="20090111" COMMENT="XMLDB file for core Moodle tables"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
 >
         <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
       </KEYS>
     </TABLE>
-    <TABLE NAME="repository_instance_config" COMMENT="The config for intances" PREVIOUS="repository_instances" NEXT="backup_config">
+    <TABLE NAME="repository_instance_config" COMMENT="The config for intances" PREVIOUS="repository_instances" NEXT="backup_files">
       <FIELDS>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="instanceid"/>
         <FIELD NAME="instanceid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="name"/>
         <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
       </KEYS>
     </TABLE>
-    <TABLE NAME="backup_config" COMMENT="To store backup configuration variables" PREVIOUS="repository_instance_config" NEXT="backup_files">
-      <FIELDS>
-        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="name"/>
-        <FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="value"/>
-        <FIELD NAME="value" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="name"/>
-      </FIELDS>
-      <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
-      </KEYS>
-      <INDEXES>
-        <INDEX NAME="name" UNIQUE="true" FIELDS="name"/>
-      </INDEXES>
-    </TABLE>
-    <TABLE NAME="backup_files" COMMENT="To store and recode ids to user and course files" PREVIOUS="backup_config" NEXT="backup_ids">
+    <TABLE NAME="backup_files" COMMENT="To store and recode ids to user and course files" PREVIOUS="repository_instance_config" NEXT="backup_ids">
       <FIELDS>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="backup_code"/>
         <FIELD NAME="backup_code" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="file_type"/>
index cf47f0efe6b34c6c9535b9237e68870cb88def6c..6476c2fa8a2109d30c9f21d05eee7ac46ac90e56 100644 (file)
@@ -1333,6 +1333,23 @@ function xmldb_main_upgrade($oldversion) {
         upgrade_main_savepoint($result, 2009011100);
     }
 
+    if ($result && $oldversion < 2009011101) {
+    /// Migrate backup settings to core plugin config table
+        $configs = $DB->get_records('backup_config');
+        foreach ($configs as $config) {
+            set_config($config->name, $config->value, 'backup');
+        }
+
+    /// Define table to be dropped
+        $table = new xmldb_table('backup_config');
+
+    /// Launch drop table for old backup config
+        $dbman->drop_table($table);
+
+    /// Main savepoint reached
+        upgrade_main_savepoint($result, 2009011101);
+    }
+
 
     return $result;
 }
index 93417191d27abb8cb1824c21eef0dfdfe7ac61a2..c37176c7953cb6589b7199d6ed4844a58769a683 100644 (file)
@@ -702,7 +702,7 @@ function set_config($name, $value, $plugin=NULL) {
             $config = new object();
             $config->name  = $name;
             $config->value = $value;
-            return $DB->insert_record('config', $config);
+            return $DB->insert_record('config', $config, false);
         }
 
     } else { // plugin scope
@@ -720,7 +720,7 @@ function set_config($name, $value, $plugin=NULL) {
             $config->plugin = $plugin;
             $config->name   = $name;
             $config->value  = $value;
-            return $DB->insert_record('config_plugins', $config);
+            return $DB->insert_record('config_plugins', $config, false);
         }
     }
 }
index 70c097648e029357cef2a4918316e30eee0e25cf..234cf5e5c1f58c27f2d552392615e74b02710407 100644 (file)
@@ -6,7 +6,7 @@
 // This is compared against the values stored in the database to determine
 // whether upgrades should be performed (see lib/db/*.php)
 
-    $version = 2009011100;  // YYYYMMDD   = date of the last version bump
+    $version = 2009011101;  // YYYYMMDD   = date of the last version bump
                             //         XX = daily increments
 
     $release = '2.0 dev (Build: 20090111)';  // Human-friendly version name