MDL-21695 Removing sitefilesused.html, not used any more
[moodle.git] / course / editsection.php
CommitLineData
d9cb06dc 1<?php
578fdd0a 2
d9cb06dc 3// This file is part of Moodle - http://moodle.org/
4//
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.
9//
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.
14//
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/>.
578fdd0a 17
d9cb06dc 18/**
19 * Edit the introduction of a section
20 *
21 * @copyright 1999 Martin Dougiamas http://dougiamas.com
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 * @package course
24 */
578fdd0a 25
d9cb06dc 26require_once("../config.php");
27require_once("lib.php");
28require_once($CFG->libdir.'/filelib.php');
29require_once('editsection_form.php');
578fdd0a 30
d9cb06dc 31$id = required_param('id',PARAM_INT); // Week/topic ID
578fdd0a 32
a6855934 33$PAGE->set_url('/course/editsection.php', array('id'=>$id));
2fdcf5e3 34
09eb2151
DM
35$section = $DB->get_record('course_sections', array('id' => $id), '*', MUST_EXIST);
36$course = $DB->get_record('course', array('id' => $section->course), '*', MUST_EXIST);
d9cb06dc 37
38require_login($course);
39$context = get_context_instance(CONTEXT_COURSE, $course->id);
40require_capability('moodle/course:update', $context);
41
e34a326f
SH
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));
09eb2151 46$mform->set_data($section); // set current value
578fdd0a 47
48/// If data submitted, then process and store.
d9cb06dc 49if ($mform->is_cancelled()){
50 redirect($CFG->wwwroot.'/course/view.php?id='.$course->id);
578fdd0a 51
d9cb06dc 52} else if ($data = $mform->get_data()) {
0f4ab67d
SH
53 if (empty($data->usedefaultname)) {
54 $section->name = $data->name;
55 } else {
56 $section->name = null;
57 }
09eb2151
DM
58 $data = file_postupdate_standard_editor($data, 'summary', $editoroptions, $context, 'course_section', $section->id);
59 $section->summary = $data->summary;
60 $section->summaryformat = $data->summaryformat;
0f4ab67d 61 $DB->update_record('course_sections', $section);
d9cb06dc 62 add_to_log($course->id, "course", "editsection", "editsection.php?id=$section->id", "$section->section");
63 redirect("view.php?id=$course->id");
64}
578fdd0a 65
7487c856
SH
66$sectionname = get_section_name($course, $section);
67$stredit = get_string('edita', '', " $sectionname");
68$strsummaryof = get_string('summaryof', '', " $sectionname");
d9cb06dc 69
70$PAGE->set_title($stredit);
e34a326f 71$PAGE->set_heading($course->fullname);
d9cb06dc 72$PAGE->navbar->add($stredit);
d9cb06dc 73echo $OUTPUT->header();
578fdd0a 74
4bcc5118 75echo $OUTPUT->heading_with_help($strsummaryof, 'summaries');
a19a06d0 76
d9cb06dc 77$mform->display();
0831fd78 78echo $OUTPUT->footer();