modified instructions for uploading to "lang" directory, to reflect the fact that...
[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
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
116ae3b2 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");
59 }
578fdd0a 60
2b38a593 61 print_header_simple($stredit, '', $stredit);
578fdd0a 62
116ae3b2 63 print_heading($strsummaryof);
64 print_simple_box_start('center');
65 include('editsection.html');
404cfbb8 66 print_simple_box_end();
578fdd0a 67
bae53097 68 if ($usehtmleditor) {
76138908 69 use_html_editor("summary");
bae53097 70 }
578fdd0a 71 print_footer($course);
72
73?>