# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
Index: moodle/lib/adminlib.php
--- moodle/lib/adminlib.php Base (1.313)
+++ moodle/lib/adminlib.php Locally Modified (Based On 1.313)
@@ -1794,7 +1794,7 @@
  * Admin settings class. Only exists on setting pages.
  * Read & write happens at this level; no authentication.
  */
-class admin_setting {
+abstract class admin_setting {
 
     public $name;
     public $visiblename;
@@ -1865,18 +1865,46 @@
         }
     }
 
+    /**
+     *
+     * @param <type> $name
+     * @param <type> $value
+     * @return <type> Write setting to confix table
+     */
     public function config_write($name, $value) {
-        return (boolean)set_config($name, $value, $this->plugin);
+        global $DB, $USER, $CFG;
+
+        // make sure it is a real change
+        $oldvalue = get_config($this->plugin, $name);
+        $oldvalue = ($oldvalue === false) ? null : $oldvalue; // normalise
+        $value = is_null($value) ? null : (string)$value;
+
+        if ($oldvalue === $value) {
+            return true;
+        }
+
+        // store change
+        set_config($name, $value, $this->plugin);
+
+
+        // log change
+        $log = new object();
+        $log->userid       = empty($CFG->rolesactive) ? 0 :$USER->id; // 0 as user id during install
+        $log->timemodified = time();
+        $log->plugin       = $this->plugin;
+        $log->name         = $name;
+        $log->value        = $value;
+        $log->oldvalue     = $oldvalue;
+        $DB->insert_record('log_config', $log);
+
+        return true; // BC only
     }
 
     /**
      * Returns current value of this setting
      * @return mixed array or string depending on instance, NULL means not set yet
      */
-    public function get_setting() {
-        // has to be overridden
-        return NULL;
-    }
+    public abstract function get_setting();
 
     /**
      * Returns default setting if exists
@@ -1891,10 +1919,7 @@
      * @param mixed string or array, must not be NULL
      * @return '' if ok, string error message otherwise
      */
-    public function write_setting($data) {
-        // should be overridden
-        return '';
-    }
+    public abstract function write_setting($data);
 
     /**
      * Return part of form with setting
@@ -4533,6 +4558,10 @@
         return true;
     }
 
+    public function write_setting($data) {
+        return '';
+    }
+
     public function is_related($query) {
         if (parent::is_related($query)) {
             return true;
@@ -4931,7 +4960,7 @@
 
     // now update $SITE - it might have been changed
     $SITE = $DB->get_record('course', array('id'=>$SITE->id));
-    $COURSE = clone($SITE);
+    course_setup($SITE);
 
     // now reload all settings - some of them might depend on the changed
     admin_get_root(true);
@@ -5427,6 +5456,7 @@
 
     public function write_setting($data) {
         $url = $this->baseurl . '&amp;new=' . $data;
+        return '';
         // TODO
         // Should not use redirect and exit here
         // Find a better way to do this.
Index: moodle/lib/db/install.xml
--- moodle/lib/db/install.xml Base (1.187)
+++ moodle/lib/db/install.xml Locally Modified (Based On 1.187)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="lib/db" VERSION="20090111" COMMENT="XMLDB file for core Moodle tables"
+<XMLDB PATH="lib/db" VERSION="20090113" COMMENT="XMLDB file for core Moodle tables"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
 >
@@ -331,7 +331,7 @@
         <INDEX NAME="cmid" UNIQUE="false" FIELDS="cmid" PREVIOUS="userid-course"/>
       </INDEXES>
     </TABLE>
-    <TABLE NAME="log_display" COMMENT="For a particular module/action, specifies a moodle table/field" PREVIOUS="log" NEXT="message">
+    <TABLE NAME="log_display" COMMENT="For a particular module/action, specifies a moodle table/field" PREVIOUS="log" NEXT="log_config">
       <FIELDS>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="module"/>
         <FIELD NAME="module" TYPE="char" LENGTH="20" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="action"/>
@@ -346,8 +346,26 @@
         <INDEX NAME="module-action" UNIQUE="true" FIELDS="module, action"/>
       </INDEXES>
     </TABLE>
-    <TABLE NAME="message" COMMENT="Stores all unread messages" PREVIOUS="log_display" NEXT="message_read">
+    <TABLE NAME="log_config" COMMENT="Changes done in server configuration through admin UI" PREVIOUS="log_display" NEXT="message">
       <FIELDS>
+        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="userid"/>
+        <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="timemodified"/>
+        <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="userid" NEXT="plugin"/>
+        <FIELD NAME="plugin" TYPE="char" LENGTH="100" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="timemodified" NEXT="name"/>
+        <FIELD NAME="name" TYPE="char" LENGTH="100" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="plugin" NEXT="value"/>
+        <FIELD NAME="value" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="oldvalue"/>
+        <FIELD NAME="oldvalue" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="value"/>
+      </FIELDS>
+      <KEYS>
+        <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="userid"/>
+        <KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id" PREVIOUS="primary"/>
+      </KEYS>
+      <INDEXES>
+        <INDEX NAME="timemodified" UNIQUE="false" FIELDS="timemodified"/>
+      </INDEXES>
+    </TABLE>
+    <TABLE NAME="message" COMMENT="Stores all unread messages" PREVIOUS="log_config" NEXT="message_read">
+      <FIELDS>
\ No newline at end of file
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="useridfrom"/>
         <FIELD NAME="useridfrom" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="useridto"/>
         <FIELD NAME="useridto" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="useridfrom" NEXT="subject"/>
Index: moodle/lib/db/upgrade.php
--- moodle/lib/db/upgrade.php Base (1.265)
+++ moodle/lib/db/upgrade.php Locally Modified (Based On 1.265)
@@ -1350,7 +1350,35 @@
         upgrade_main_savepoint($result, 2009011101);
     }
 
+    if ($result && $oldversion < 2009011302) {
 
+    /// Define table log_config to be created
+        $table = new xmldb_table('log_config');
+
+    /// Adding fields to table log_config
+        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
+        $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
+        $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
+        $table->add_field('plugin', XMLDB_TYPE_CHAR, '100', null, null, null, null, null, null);
+        $table->add_field('name', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, null, null);
+        $table->add_field('value', XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null);
+        $table->add_field('oldvalue', XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null);
+
+    /// Adding keys to table log_config
+        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
+        $table->add_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
+
+    /// Adding indexes to table log_config
+        $table->add_index('timemodified', XMLDB_INDEX_NOTUNIQUE, array('timemodified'));
+
+    /// Launch create table for log_config
+        $dbman->create_table($table);
+
+    /// Main savepoint reached
+        upgrade_main_savepoint($result, 2009011302);
+    }
+
+
     return $result;
 }
 
Index: moodle/version.php
--- moodle/version.php Base (1.961)
+++ moodle/version.php Locally Modified (Based On 1.961)
@@ -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 = 2009011301;  // YYYYMMDD   = date of the last version bump
+    $version = 2009011302;  // YYYYMMDD   = date of the last version bump
                             //         XX = daily increments
 
     $release = '2.0 dev (Build: 20090113)';  // Human-friendly version name
