file width.html was added on branch MOODLE_15_STABLE on 2005-07-07 16:14:37 +0000
[moodle.git] / course / editsection.php
blobb576a20152257b4ffaab0d3a3a94e730eaf853e3
1 <?php // $Id$
2 // Edit the introduction of a section
4 require_once("../config.php");
5 require_once("lib.php");
7 require_variable($id); // Week ID
9 require_login();
11 if (! $section = get_record("course_sections", "id", $id)) {
12 error("Course section is incorrect");
15 if (! $course = get_record("course", "id", $section->course)) {
16 error("Could not find the course!");
19 if (!isteacher($course->id)) {
20 error("Only teachers can edit this!");
24 /// If data submitted, then process and store.
26 if ($form = data_submitted() and confirm_sesskey()) {
28 $timenow = time();
30 if (! set_field("course_sections", "summary", $form->summary, "id", $section->id)) {
31 error("Could not update the summary!");
34 add_to_log($course->id, "course", "editsection", "editsection.php?id=$section->id", "$section->section");
36 redirect("view.php?id=$course->id");
37 exit;
40 /// Otherwise fill and print the form.
42 if (empty($form)) {
43 $form = $section;
46 $form->sesskey = !empty($USER->id) ? $USER->sesskey : '';
48 $usehtmleditor = can_use_html_editor();
50 /// Inelegant hack for bug 3408
51 if ($course->format == 'site') {
52 $sectionname = get_string('site');
53 $stredit = get_string('edit', '', " $sectionname");
54 $strsummaryof = get_string('summaryof', '', " $sectionname");
55 } else {
56 $sectionname = get_string("name$course->format");
57 $stredit = get_string('edit', '', " $sectionname $section->section");
58 $strsummaryof = get_string('summaryof', '', " $sectionname $form->section");
61 print_header("$course->shortname: $stredit", "$course->fullname",
62 "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a>
63 -> $stredit");
65 print_heading($strsummaryof);
66 print_simple_box_start('center');
67 include('editsection.html');
68 print_simple_box_end();
70 if ($usehtmleditor) {
71 use_html_editor("summary");
73 print_footer($course);