From: skodak Date: Wed, 3 Oct 2007 10:35:34 +0000 (+0000) Subject: MDL-11566 site summary now optional X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=c626c2f4607b8289f022ee61e44a640e74d7f2d3;p=moodle.git MDL-11566 site summary now optional --- diff --git a/admin/index.php b/admin/index.php index 037c52e8a7..c597fbe992 100644 --- a/admin/index.php +++ b/admin/index.php @@ -446,10 +446,10 @@ // 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; @@ -460,24 +460,26 @@ $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 diff --git a/lib/adminlib.php b/lib/adminlib.php index cf6e3142b2..45f39fde78 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -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 . '
'); - } } diff --git a/lib/db/install.xml b/lib/db/install.xml index 84a7cf83c1..38995d47a0 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -36,7 +36,7 @@ - + diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index e097f93c25..723bb64339 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -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 ;-) diff --git a/version.php b/version.php index 69209bf175..7e801aafdd 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 = 2007100301; // YYYYMMDD = date + $version = 2007100303; // YYYYMMDD = date // XY = increments within a single day $release = '1.9 Beta +'; // Human-friendly version name