moodle/course/editsection.php

73 lines
2.1 KiB
PHP
Raw Normal View History

2004-09-12 12:21:27 +00:00
<?php // $Id$
// Edit the introduction of a section
2002-06-25 11:46:12 +00:00
require_once("../config.php");
require_once("lib.php");
2002-06-25 11:46:12 +00:00
$id = required_param('id',PARAM_INT); // Week ID
2002-06-25 11:46:12 +00:00
if (! $section = get_record("course_sections", "id", $id)) {
print_error("sectionnotexist");
2002-06-25 11:46:12 +00:00
}
if (! $course = get_record("course", "id", $section->course)) {
print_error("invalidcourseid");
2002-06-25 11:46:12 +00:00
}
require_login($course->id);
2006-10-01 09:26:50 +00:00
require_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id));
2002-06-25 11:46:12 +00:00
/// If data submitted, then process and store.
if ($form = data_submitted() and confirm_sesskey()) {
2002-06-25 11:46:12 +00:00
$timenow = time();
if (! set_field("course_sections", "summary", $form->summary, "id", $section->id)) {
print_error("cannotupdatesummary");
2002-06-25 11:46:12 +00:00
}
add_to_log($course->id, "course", "editsection", "editsection.php?id=$section->id", "$section->section");
2002-06-25 11:46:12 +00:00
redirect("view.php?id=$course->id");
exit;
}
/// Otherwise fill and print the form.
2003-01-02 15:25:51 +00:00
if (empty($form)) {
2002-06-25 11:46:12 +00:00
$form = $section;
} else {
$form = stripslashes_safe($form);
2002-06-25 11:46:12 +00:00
}
// !! no db access using data from $form beyond this point !!
$usehtmleditor = can_use_html_editor();
2005-06-03 14:43:43 +00:00
/// Inelegant hack for bug 3408
if ($course->format == 'site') {
$sectionname = get_string('site');
$stredit = get_string('edit', '', " $sectionname");
$strsummaryof = get_string('summaryof', '', " $sectionname");
} else {
$sectionname = get_string("name$course->format");
$stredit = get_string('edit', '', " $sectionname $section->section");
$strsummaryof = get_string('summaryof', '', " $sectionname $form->section");
}
2002-06-25 11:46:12 +00:00
print_header_simple($stredit, '', build_navigation(array(array('name' => $stredit, 'link' => null, 'type' => 'misc'))), 'theform.summary' );
2002-06-25 11:46:12 +00:00
2005-06-03 14:43:43 +00:00
print_heading($strsummaryof);
print_simple_box_start('center');
include('editsection.html');
print_simple_box_end();
2002-06-25 11:46:12 +00:00
if ($usehtmleditor) {
use_html_editor("summary");
}
2002-06-25 11:46:12 +00:00
print_footer($course);
?>