Fixed a typo causing MDL-6758
[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
783da262 9 require_login();
10
578fdd0a 11 if (! $section = get_record("course_sections", "id", $id)) {
12 error("Course section is incorrect");
13 }
14
15 if (! $course = get_record("course", "id", $section->course)) {
16 error("Could not find the course!");
17 }
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
676eb5e8 23 if ($form = data_submitted() and confirm_sesskey()) {
578fdd0a 24
25 $timenow = time();
26
36b4f985 27 if (! set_field("course_sections", "summary", $form->summary, "id", $section->id)) {
578fdd0a 28 error("Could not update the summary!");
29 }
30
31 add_to_log($course->id, "course", "editsection", "editsection.php?id=$section->id", "$section->section");
32
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;
f8a5159a 41 } else {
42 $form = stripslashes_safe($form);
578fdd0a 43 }
44
f8a5159a 45 // !! no db access using data from $form beyond this point !!
676eb5e8 46
bae53097 47 $usehtmleditor = can_use_html_editor();
1e5a2bf5 48
116ae3b2 49/// Inelegant hack for bug 3408
50 if ($course->format == 'site') {
51 $sectionname = get_string('site');
52 $stredit = get_string('edit', '', " $sectionname");
53 $strsummaryof = get_string('summaryof', '', " $sectionname");
54 } else {
55 $sectionname = get_string("name$course->format");
56 $stredit = get_string('edit', '', " $sectionname $section->section");
57 $strsummaryof = get_string('summaryof', '', " $sectionname $form->section");
58 }
578fdd0a 59
2b38a593 60 print_header_simple($stredit, '', $stredit);
578fdd0a 61
116ae3b2 62 print_heading($strsummaryof);
63 print_simple_box_start('center');
64 include('editsection.html');
404cfbb8 65 print_simple_box_end();
578fdd0a 66
bae53097 67 if ($usehtmleditor) {
76138908 68 use_html_editor("summary");
bae53097 69 }
578fdd0a 70 print_footer($course);
71
72?>