diff --git a/backup/moodle2/backup_stepslib.php b/backup/moodle2/backup_stepslib.php index c9b834fd0cf..2698b0f5f7f 100644 --- a/backup/moodle2/backup_stepslib.php +++ b/backup/moodle2/backup_stepslib.php @@ -184,7 +184,7 @@ class backup_section_structure_step extends backup_structure_step { // Define each element separated $section = new backup_nested_element('section', array('id'), array( - 'number', 'name', 'summary', 'sequence', 'visible')); + 'number', 'name', 'summary', 'summaryformat', 'sequence', 'visible')); // Define sources diff --git a/course/editsection.php b/course/editsection.php index cc61e615061..b44072de309 100644 --- a/course/editsection.php +++ b/course/editsection.php @@ -44,18 +44,11 @@ require_login($course); $context = get_context_instance(CONTEXT_COURSE, $course->id); require_capability('moodle/course:update', $context); -$draftitemid = file_get_submitted_draft_itemid('summary'); -$currenttext = file_prepare_draft_area($draftitemid, $context->id, 'course_section', $section->id, array('subdirs'=>true), $section->summary); - -$mform = new editsection_form(null, $course); -$data = array( - 'id'=>$section->id, - 'usedefaultname'=>(is_null($section->name)), - 'name'=>$section->name, - 'summary'=>array('text'=>$currenttext, 'format'=>FORMAT_HTML, 'itemid'=>$draftitemid) -); - -$mform->set_data($data); // set defaults +$editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes'=>$CFG->maxbytes, 'trusttext'=>false, 'noclean'=>true); +$section = file_prepare_standard_editor($section, 'summary', $editoroptions, $context, 'course_section', $section->id); +$section->usedefaultname = (is_null($section->name)); +$mform = new editsection_form(null, array('course'=>$course, 'editoroptions'=>$editoroptions)); +$mform->set_data($section); // set defaults /// If data submitted, then process and store. if ($mform->is_cancelled()){ @@ -85,6 +78,7 @@ if ($course->format == 'site') { } $PAGE->set_title($stredit); +$PAGE->set_heading($course->fullname); $PAGE->navbar->add($stredit); echo $OUTPUT->header(); diff --git a/course/editsection_form.php b/course/editsection_form.php index 09c20c4687c..5d036628a8f 100644 --- a/course/editsection_form.php +++ b/course/editsection_form.php @@ -12,7 +12,7 @@ class editsection_form extends moodleform { global $CFG, $DB; $mform = $this->_form; - $course = $this->_customdata; + $course = $this->_customdata['course']; $mform->addElement('checkbox', 'usedefaultname', get_string('sectionusedefaultname')); $mform->setDefault('usedefaultname', true); @@ -21,7 +21,9 @@ class editsection_form extends moodleform { $mform->setType('name', PARAM_TEXT); $mform->disabledIf('name','usedefaultname','checked'); - $mform->addElement('editor', 'summary', get_string('summary'), null, array('changeformat'=>false, 'maxfiles'=>-1)); + /// Prepare course and the editor + + $mform->addElement('editor', 'summary', get_string('summary'), null, $this->_customdata['editoroptions']); $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); diff --git a/course/format/topics/format.php b/course/format/topics/format.php index f6b3bfbf0c7..c568fb176dd 100644 --- a/course/format/topics/format.php +++ b/course/format/topics/format.php @@ -106,7 +106,7 @@ if ($thissection->summary or $thissection->sequence or $PAGE->user_is_editing()) $summarytext = file_rewrite_pluginfile_urls($thissection->summary, 'pluginfile.php', $coursecontext->id, 'course_section', $thissection->id); $summaryformatoptions = new object(); $summaryformatoptions->noclean = true; - echo format_text($summarytext, FORMAT_HTML, $summaryformatoptions); + echo format_text($summarytext, $thissection->summaryformat, $summaryformatoptions); if ($PAGE->user_is_editing() && has_capability('moodle/course:update', $coursecontext)) { echo 'numsections) { $summarytext = file_rewrite_pluginfile_urls($thissection->summary, 'pluginfile.php', $coursecontext->id, 'course_section', $thissection->id); $summaryformatoptions = new object(); $summaryformatoptions->noclean = true; - echo format_text($summarytext, FORMAT_HTML, $summaryformatoptions); + echo format_text($summarytext, $thissection->summaryformat, $summaryformatoptions); } else { echo ' '; } diff --git a/course/format/weeks/format.php b/course/format/weeks/format.php index 9f0eec52337..5f864253067 100644 --- a/course/format/weeks/format.php +++ b/course/format/weeks/format.php @@ -97,7 +97,7 @@ $summarytext = file_rewrite_pluginfile_urls($thissection->summary, 'pluginfile.php', $coursecontext->id, 'course_section', $thissection->id); $summaryformatoptions = new object(); $summaryformatoptions->noclean = true; - echo format_text($summarytext, FORMAT_HTML, $summaryformatoptions); + echo format_text($summarytext, $thissection->summaryformat, $summaryformatoptions); if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) { echo '

summary, 'pluginfile.php', $coursecontext->id, 'course_section', $thissection->id); $summaryformatoptions = new object(); $summaryformatoptions->noclean = true; - echo format_text($summarytext, FORMAT_HTML, $summaryformatoptions); + echo format_text($summarytext, $thissection->summaryformat, $summaryformatoptions); if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) { echo ' '. diff --git a/course/lib.php b/course/lib.php index 39ca44004d4..e5bf23bd90b 100644 --- a/course/lib.php +++ b/course/lib.php @@ -1177,7 +1177,7 @@ function get_all_mods($courseid, &$mods, &$modnames, &$modnamesplural, &$modname function get_all_sections($courseid) { global $DB; return $DB->get_records("course_sections", array("course"=>"$courseid"), "section", - "section, id, course, name, summary, sequence, visible"); + "section, id, course, name, summary, summaryformat, sequence, visible"); } function course_set_display($courseid, $display=0) { @@ -2498,6 +2498,7 @@ function get_course_section($section, $courseid) { $cw->course = $courseid; $cw->section = $section; $cw->summary = ""; + $cw->summaryformat = FORMAT_MOODLE; $cw->sequence = ""; $id = $DB->insert_record("course_sections", $cw); return $DB->get_record("course_sections", array("id"=>$id)); @@ -2545,6 +2546,7 @@ function add_mod_to_section($mod, $beforemod=NULL) { $section->course = $mod->course; $section->section = $mod->section; $section->summary = ""; + $section->summaryformat = FORMAT_MOODLE; $section->sequence = $mod->coursemodule; return $DB->insert_record("course_sections", $section); } diff --git a/index.php b/index.php index 5da3ee2a975..de079800518 100644 --- a/index.php +++ b/index.php @@ -98,6 +98,7 @@ $section->course = $SITE->id; $section->section = 1; $section->summary = ''; + $section->summaryformat = '0'; $section->sequence = ''; $section->visible = 1; $section->id = $DB->insert_record('course_sections', $section); @@ -119,7 +120,7 @@ $summaryformatoptions = new object(); $summaryformatoptions->noclean = true; - echo format_text($summarytext, FORMAT_HTML, $summaryformatoptions); + echo format_text($summarytext, $section->summaryformat, $summaryformatoptions); if ($editing) { $streditsummary = get_string('editsummary'); diff --git a/lib/db/install.xml b/lib/db/install.xml index 8c019e01e8d..4ddd3d9417a 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -1,5 +1,5 @@ - @@ -341,8 +341,9 @@ - - + + + diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 3cd603aa954..044f7409b92 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -4142,6 +4142,21 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL"); upgrade_main_savepoint($result, 2010052401); } + if ($result && $oldversion < 2010052700) { + + /// Define field summaryformat to be added to course sections table + $table = new xmldb_table('course_sections'); + $field = new xmldb_field('summaryformat', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'summary'); + + /// Conditionally launch add field summaryformat + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + } + + /// Main savepoint reached + upgrade_main_savepoint($result, 2010052700); + } + return $result; } diff --git a/version.php b/version.php index 0fe2fe60c70..2881d1209db 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 = 2010052401; // YYYYMMDD = date of the last version bump + $version = 2010052700; // YYYYMMDD = date of the last version bump // XX = daily increments $release = '2.0 Preview 2 (Build: 20100527)'; // Human-friendly version name