2009-09-25 05:24:13 +00:00
|
|
|
<?php
|
2002-06-25 11:46:12 +00:00
|
|
|
|
2009-09-25 05:24:13 +00:00
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
|
|
//
|
|
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
2002-06-25 11:46:12 +00:00
|
|
|
|
2009-09-25 05:24:13 +00:00
|
|
|
/**
|
|
|
|
* Edit the introduction of a section
|
|
|
|
*
|
|
|
|
* @copyright 1999 Martin Dougiamas http://dougiamas.com
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
* @package course
|
|
|
|
*/
|
2002-06-25 11:46:12 +00:00
|
|
|
|
2009-09-25 05:24:13 +00:00
|
|
|
require_once("../config.php");
|
|
|
|
require_once("lib.php");
|
|
|
|
require_once($CFG->libdir.'/filelib.php');
|
|
|
|
require_once('editsection_form.php');
|
2002-06-25 11:46:12 +00:00
|
|
|
|
2009-09-25 05:24:13 +00:00
|
|
|
$id = required_param('id',PARAM_INT); // Week/topic ID
|
2002-06-25 11:46:12 +00:00
|
|
|
|
2010-01-16 15:39:56 +00:00
|
|
|
$PAGE->set_url('/course/editsection.php', array('id'=>$id));
|
2006-10-01 09:31:49 +00:00
|
|
|
|
2009-09-25 05:24:13 +00:00
|
|
|
if (! $section = $DB->get_record("course_sections", array("id"=>$id))) {
|
|
|
|
print_error("sectionnotexist");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! $course = $DB->get_record("course", array("id"=>$section->course))) {
|
|
|
|
print_error("invalidcourseid");
|
|
|
|
}
|
|
|
|
|
|
|
|
require_login($course);
|
|
|
|
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
|
|
|
require_capability('moodle/course:update', $context);
|
|
|
|
|
2010-05-27 03:07:54 +00:00
|
|
|
$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
|
2002-06-25 11:46:12 +00:00
|
|
|
|
|
|
|
/// If data submitted, then process and store.
|
2009-09-25 05:24:13 +00:00
|
|
|
if ($mform->is_cancelled()){
|
|
|
|
redirect($CFG->wwwroot.'/course/view.php?id='.$course->id);
|
2002-06-25 11:46:12 +00:00
|
|
|
|
2009-09-25 05:24:13 +00:00
|
|
|
} else if ($data = $mform->get_data()) {
|
2010-04-23 07:17:21 +00:00
|
|
|
if (empty($data->usedefaultname)) {
|
|
|
|
$section->name = $data->name;
|
|
|
|
} else {
|
|
|
|
$section->name = null;
|
|
|
|
}
|
|
|
|
$section->summary = file_save_draft_area_files($data->summary['itemid'], $context->id, 'course_section', $section->id, array('subdirs'=>true), $data->summary['text']);
|
|
|
|
$DB->update_record('course_sections', $section);
|
2009-09-25 05:24:13 +00:00
|
|
|
add_to_log($course->id, "course", "editsection", "editsection.php?id=$section->id", "$section->section");
|
|
|
|
redirect("view.php?id=$course->id");
|
|
|
|
}
|
2002-06-25 11:46:12 +00:00
|
|
|
|
2005-06-03 14:43:43 +00:00
|
|
|
/// Inelegant hack for bug 3408
|
2009-09-25 05:24:13 +00:00
|
|
|
if ($course->format == 'site') {
|
|
|
|
$sectionname = get_string('site');
|
2010-04-20 17:57:12 +00:00
|
|
|
$stredit = get_string('edita', '', " $sectionname");
|
2009-09-25 05:24:13 +00:00
|
|
|
$strsummaryof = get_string('summaryof', '', " $sectionname");
|
|
|
|
} else {
|
|
|
|
$sectionname = get_section_name($course->format);
|
2010-04-20 17:57:12 +00:00
|
|
|
$stredit = get_string('edita', '', " $sectionname $section->section");
|
2009-09-25 05:24:13 +00:00
|
|
|
$strsummaryof = get_string('summaryof', '', " $sectionname $section->section");
|
|
|
|
}
|
|
|
|
|
|
|
|
$PAGE->set_title($stredit);
|
2010-05-27 03:07:54 +00:00
|
|
|
$PAGE->set_heading($course->fullname);
|
2009-09-25 05:24:13 +00:00
|
|
|
$PAGE->navbar->add($stredit);
|
|
|
|
echo $OUTPUT->header();
|
2002-06-25 11:46:12 +00:00
|
|
|
|
2009-12-30 15:19:55 +00:00
|
|
|
echo $OUTPUT->heading_with_help($strsummaryof, 'summaries');
|
2009-05-18 19:04:06 +00:00
|
|
|
|
2009-09-25 05:24:13 +00:00
|
|
|
$mform->display();
|
2010-04-20 17:57:12 +00:00
|
|
|
echo $OUTPUT->footer();
|