3 // This file is part of Moodle - http://moodle.org/
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
19 * Edit the introduction of a section
21 * @copyright 1999 Martin Dougiamas http://dougiamas.com
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 require_once("../config.php");
27 require_once("lib.php");
28 require_once($CFG->libdir
.'/filelib.php');
29 require_once('editsection_form.php');
31 $id = required_param('id',PARAM_INT
); // Week/topic ID
33 $PAGE->set_url('/course/editsection.php', array('id'=>$id));
35 $section = $DB->get_record('course_sections', array('id' => $id), '*', MUST_EXIST
);
36 $course = $DB->get_record('course', array('id' => $section->course
), '*', MUST_EXIST
);
38 require_login($course);
39 $context = get_context_instance(CONTEXT_COURSE
, $course->id
);
40 require_capability('moodle/course:update', $context);
42 $editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES
, 'maxbytes'=>$CFG->maxbytes
, 'trusttext'=>false, 'noclean'=>true);
43 $section = file_prepare_standard_editor($section, 'summary', $editoroptions, $context, 'course', 'section', $section->id
);
44 $section->usedefaultname
= (is_null($section->name
));
45 $mform = new editsection_form(null, array('course'=>$course, 'editoroptions'=>$editoroptions));
46 $mform->set_data($section); // set current value
48 /// If data submitted, then process and store.
49 if ($mform->is_cancelled()){
50 redirect($CFG->wwwroot
.'/course/view.php?id='.$course->id
);
52 } else if ($data = $mform->get_data()) {
53 if (empty($data->usedefaultname
)) {
54 $section->name
= $data->name
;
56 $section->name
= null;
58 $data = file_postupdate_standard_editor($data, 'summary', $editoroptions, $context, 'course', 'section', $section->id
);
59 $section->summary
= $data->summary
;
60 $section->summaryformat
= $data->summaryformat
;
61 $DB->update_record('course_sections', $section);
62 add_to_log($course->id
, "course", "editsection", "editsection.php?id=$section->id", "$section->section");
63 redirect("view.php?id=$course->id");
66 $sectionname = get_section_name($course, $section);
67 $stredit = get_string('edita', '', " $sectionname");
68 $strsummaryof = get_string('summaryof', '', " $sectionname");
70 $PAGE->set_title($stredit);
71 $PAGE->set_heading($course->fullname
);
72 $PAGE->navbar
->add($stredit);
73 echo $OUTPUT->header();
75 echo $OUTPUT->heading($strsummaryof);
78 echo $OUTPUT->footer();