]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-11566 site summary now optional
authorskodak <skodak>
Wed, 3 Oct 2007 10:35:34 +0000 (10:35 +0000)
committerskodak <skodak>
Wed, 3 Oct 2007 10:35:34 +0000 (10:35 +0000)
admin/index.php
lib/adminlib.php
lib/db/install.xml
lib/db/upgrade.php
version.php

index 037c52e8a71f36a1f1557239c2c66dd9aebfcde8..c597fbe9922a1fff833fe14042ccbc0803be11b9 100644 (file)
         // We are about to create the site "course"
         require_once($CFG->libdir.'/blocklib.php');
 
-        $newsite = new Object();
+        $newsite = new object();
         $newsite->fullname = "";
         $newsite->shortname = "";
-        $newsite->summary = "";
+        $newsite->summary = NULL;
         $newsite->newsitems = 3;
         $newsite->numsections = 0;
         $newsite->category = 0;
         $newsite->students = get_string("defaultcoursestudents");
         $newsite->timemodified = time();
 
-        if ($newid = insert_record('course', $newsite)) {
-            // Site created, add blocks for it
-            $page = page_create_object(PAGE_COURSE_VIEW, $newid);
-            blocks_repopulate_page($page); // Return value not checked because you can always edit later
+        if (!$newid = insert_record('course', $newsite)) {
+            error("Serious Error! Could not set up the site!");
+        }
+        // make sure course context exists
+        get_context_instance(CONTEXT_COURSE, $newid);
 
-            $cat = new Object();
-            $cat->name = get_string('miscellaneous');
-            if ($cat->id = insert_record('course_categories', $cat)) {
-                $cat->context = get_context_instance(CONTEXT_COURSECAT, $cat->id);
-                 mark_context_dirty('/'.SYSCONTEXTID);
+        // Site created, add blocks for it
+        $page = page_create_object(PAGE_COURSE_VIEW, $newid);
+        blocks_repopulate_page($page); // Return value not checked because you can always edit later
 
-                redirect('index.php');
-            } else {
-                error("Serious Error! Could not set up a default course category!");
-            }
-        } else {
-            error("Serious Error! Could not set up the site!");
+        $cat = new object();
+        $cat->name = get_string('miscellaneous');
+        if (!$catid = insert_record('course_categories', $cat)) {
+            error("Serious Error! Could not set up a default course category!");
         }
+        // make sure category context exists
+        get_context_instance(CONTEXT_COURSECAT, $catid);
+        mark_context_dirty('/'.SYSCONTEXTID);
+
+        redirect('index.php');
     }
 
     // initialise default blocks on admin and site page if needed
index cf6e3142b2b2ad44f557512e03c20e46a29d2768..45f39fde7836afca7eb50f4ca612fd11a398e58f 100644 (file)
@@ -1862,41 +1862,30 @@ class admin_setting_special_frontpagedesc extends admin_setting {
     }
 
     function output_html() {
-
         global $CFG;
 
-        if ($this->get_setting() === NULL) {
-            $currentsetting = $this->defaultsetting;
-        } else {
-            $currentsetting = $this->get_setting();
-        }
-
         $CFG->adminusehtmleditor = can_use_html_editor();
-
-        $return = print_textarea($CFG->adminusehtmleditor, 15, 60, 0, 0, 's_' . $this->name, $currentsetting, 0, true);
+        $return = print_textarea($CFG->adminusehtmleditor, 15, 60, 0, 0, 's_' . $this->name, $this->get_setting(), 0, true);
 
         return format_admin_setting($this->name, $this->visiblename, $return, $this->description, false);
     }
 
     function get_setting() {
-
         $site = get_site();
-        return $site->{$this->name} != '' ? $site->{$this->name} : NULL;
+        return $site->{$this->name};
+    }
 
+    function get_defaultsetting() {
+        return NULL;
     }
 
     function write_setting($data) {
-
-        $data = addslashes(clean_param($data, PARAM_CLEANHTML));
-
-        $record = new stdClass();
-        $record->id = $this->id;
-        $temp = $this->name;
-        $record->$temp = $data;
-        $record->timemodified = time();
+        $record = new object();
+        $record->id            = $this->id;
+        $record->{$this->name} = addslashes($data);
+        $record->timemodified  = time();
 
         return(update_record('course', $record) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
-
     }
 
 }
index 84a7cf83c11d5c2180bc5e4d7845ee25276d7036..38995d47a009f30ceea89e3e4a6718ee8854875b 100644 (file)
@@ -36,7 +36,7 @@
         <FIELD NAME="fullname" TYPE="char" LENGTH="254" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="password" NEXT="shortname"/>
         <FIELD NAME="shortname" TYPE="char" LENGTH="100" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="fullname" NEXT="idnumber"/>
         <FIELD NAME="idnumber" TYPE="char" LENGTH="100" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="shortname" NEXT="summary"/>
-        <FIELD NAME="summary" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="idnumber" NEXT="format"/>
+        <FIELD NAME="summary" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="idnumber" NEXT="format"/>
         <FIELD NAME="format" TYPE="char" LENGTH="10" NOTNULL="true" DEFAULT="topics" SEQUENCE="false" ENUM="false" PREVIOUS="summary" NEXT="showgrades"/>
         <FIELD NAME="showgrades" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="format" NEXT="modinfo"/>
         <FIELD NAME="modinfo" TYPE="text" LENGTH="big" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="showgrades" NEXT="newsitems"/>
index e097f93c25d2c4e4c6b747abaa6dce9f968c543f..723bb643391825ae2a6c17db26d056ae6a77631d 100644 (file)
@@ -2330,6 +2330,16 @@ function xmldb_main_upgrade($oldversion=0) {
         }
     }
 
+    if ($result && $oldversion < 2007100303) {
+
+    /// Changing nullability of field summary on table course to null
+        $table = new XMLDBTable('course');
+        $field = new XMLDBField('summary');
+        $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'idnumber');
+
+    /// Launch change of nullability for field summary
+        $result = $result && change_field_notnull($table, $field);
+    }
 
 
 /* NOTE: please keep this at the end of upgrade file for now ;-)
index 69209bf1758de46148a750e3d6593b3e1d996e51..7e801aafdd6d45d071d59a47747c62f52873400f 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 = 2007100301;  // YYYYMMDD = date
+    $version = 2007100303;  // YYYYMMDD = date
                             //       XY = increments within a single day
 
     $release = '1.9 Beta +';   // Human-friendly version name