Some cleanup
[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
7 require_variable($id); // Week ID
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
578fdd0a 19 if (!isteacher($course->id)) {
20 error("Only teachers can edit this!");
21 }
22
23
24/// If data submitted, then process and store.
25
676eb5e8 26 if ($form = data_submitted() and confirm_sesskey()) {
578fdd0a 27
28 $timenow = time();
29
36b4f985 30 if (! set_field("course_sections", "summary", $form->summary, "id", $section->id)) {
578fdd0a 31 error("Could not update the summary!");
32 }
33
34 add_to_log($course->id, "course", "editsection", "editsection.php?id=$section->id", "$section->section");
35
36 redirect("view.php?id=$course->id");
37 exit;
38 }
39
40/// Otherwise fill and print the form.
41
14217044 42 if (empty($form)) {
578fdd0a 43 $form = $section;
44 }
45
676eb5e8 46 $form->sesskey = !empty($USER->id) ? $USER->sesskey : '';
47
bae53097 48 $usehtmleditor = can_use_html_editor();
1e5a2bf5 49
97c270e9 50 $sectionname = get_string("name$course->format");
e20217b3 51 $stredit = get_string("edit", "", " $sectionname $section->section");
578fdd0a 52
ef9b35a0 53 print_header("$course->shortname: $stredit", "$course->fullname",
24f2b65a 54 "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a>
bae53097 55 -> $stredit");
578fdd0a 56
404cfbb8 57 print_heading(get_string("summaryof", "", "$sectionname $form->section"));
810393c8 58 print_simple_box_start("center");
578fdd0a 59 include("editsection.html");
404cfbb8 60 print_simple_box_end();
578fdd0a 61
bae53097 62 if ($usehtmleditor) {
76138908 63 use_html_editor("summary");
bae53097 64 }
578fdd0a 65 print_footer($course);
66
67?>