From: skodak Date: Sun, 11 Jan 2009 15:49:35 +0000 (+0000) Subject: MDL-17847 moev backup_config to config_plugin table X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=eb6a973cdfd00aef6b490d7049d23180d3ebdc1f;p=moodle.git MDL-17847 moev backup_config to config_plugin table --- diff --git a/backup/lib.php b/backup/lib.php index f794d71417..e6c668bb0f 100644 --- a/backup/lib.php +++ b/backup/lib.php @@ -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; } diff --git a/lib/adminlib.php b/lib/adminlib.php index 90b2ee35b7..78e351dd55 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -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); } /** diff --git a/lib/db/install.xml b/lib/db/install.xml index 41cd35ec05..cc5939ade6 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -1,5 +1,5 @@ - @@ -2003,7 +2003,7 @@ - +
@@ -2014,20 +2014,7 @@
- - - - - - - - - - - - -
- +
diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index cf47f0efe6..6476c2fa8a 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -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; } diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 93417191d2..c37176c795 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -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); } } } diff --git a/version.php b/version.php index 70c097648e..234cf5e5c1 100644 --- a/version.php +++ b/version.php @@ -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