MDL-18286 fixed incorrect version number bump - thanks Anthony
[moodle.git] / course / editsection.php
CommitLineData
24f2b65a 1<?php // $Id$
97c270e9 2 // Edit the introduction of a section
578fdd0a 3
b0e3a925 4 require_once("../config.php");
5 require_once("lib.php");
578fdd0a 6
59518de1 7 $id = required_param('id',PARAM_INT); // Week ID
578fdd0a 8
579d45b4 9 if (! $section = $DB->get_record("course_sections", array("id"=>$id))) {
ba6018a9 10 print_error("sectionnotexist");
578fdd0a 11 }
12
579d45b4 13 if (! $course = $DB->get_record("course", array("id"=>$section->course))) {
ba6018a9 14 print_error("invalidcourseid");
578fdd0a 15 }
16
2fdcf5e3 17 require_login($course->id);
18
1a5a5b0e 19 require_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id));
578fdd0a 20
21/// If data submitted, then process and store.
22
294ce987 23 if ($form = data_submitted() and confirm_sesskey()) {
578fdd0a 24
25 $timenow = time();
26
1101dac0 27 if (!$DB->set_field("course_sections", "summary", $form->summary, array("id"=>$section->id))) {
ba6018a9 28 print_error("cannotupdatesummary");
578fdd0a 29 }
30
31 add_to_log($course->id, "course", "editsection", "editsection.php?id=$section->id", "$section->section");
0be6f678 32
578fdd0a 33 redirect("view.php?id=$course->id");
34 exit;
35 }
36
37/// Otherwise fill and print the form.
38
14217044 39 if (empty($form)) {
578fdd0a 40 $form = $section;
41 }
42
f8a5159a 43 // !! no db access using data from $form beyond this point !!
676eb5e8 44
bae53097 45 $usehtmleditor = can_use_html_editor();
1e5a2bf5 46
116ae3b2 47/// Inelegant hack for bug 3408
48 if ($course->format == 'site') {
49 $sectionname = get_string('site');
50 $stredit = get_string('edit', '', " $sectionname");
51 $strsummaryof = get_string('summaryof', '', " $sectionname");
52 } else {
dfd74b5a 53 $sectionname = get_section_name($course->format);
116ae3b2 54 $stredit = get_string('edit', '', " $sectionname $section->section");
55 $strsummaryof = get_string('summaryof', '', " $sectionname $form->section");
56 }
578fdd0a 57
0be6f678 58 print_header_simple($stredit, '', build_navigation(array(array('name' => $stredit, 'link' => null, 'type' => 'misc'))), 'theform.summary' );
578fdd0a 59
116ae3b2 60 print_heading($strsummaryof);
61 print_simple_box_start('center');
62 include('editsection.html');
404cfbb8 63 print_simple_box_end();
578fdd0a 64 print_footer($course);
65
66?>