You can now use Richtext editor to edit section texts, plus the page is a
[moodle.git] / course / editsection.php
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     if (! $section = get_record("course_sections", "id", $id)) {
10         error("Course section is incorrect");
11     }
13     if (! $course = get_record("course", "id", $section->course)) {
14         error("Could not find the course!");
15     }
17     require_login($course->id);
18     
19     if (!isteacher($course->id)) {
20         error("Only teachers can edit this!");
21     }
24 /// If data submitted, then process and store.
26     if ($form = data_submitted()) {
28         $timenow = time();
30         if (! set_field("course_sections", "summary", $form->summary, "id", $section->id)) {
31             error("Could not update the summary!");
32         }
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     }
40 /// Otherwise fill and print the form.
42     if (empty($form)) {
43         $form = $section;
44     }
46     if ($usehtmleditor = can_use_richtext_editor()) {
47         $onsubmit = "onsubmit=\"copyrichtext(theform.summary);\"";
48     } else {
49         $onsubmit = "";
50     }
52     $sectionname = get_string("name$course->format");
53     $stredit = get_string("edit", "", " $sectionname $section->section");
55         print_header("$course->shortname: $stredit", "$course->fullname", 
56                  "<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> 
57                   -> $stredit", "form.summary");
59     include("editsection.html");
61     print_footer($course);
63 ?>