// 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
}
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 />');
-
}
}
<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"/>
}
}
+ 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 ;-)
// 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