Permalink
Browse files

MDL-32508 course/editsection: add a sectionreturn param

This is used so that when editing on a section page you
are returned to the section in question.
  • Loading branch information...
danpoltawski committed Apr 28, 2012
1 parent d9e1326 commit a5a38c9473b06261f0cb33368390a48d106fe576
Showing with 11 additions and 4 deletions.
  1. +11 −4 course/editsection.php
View
@@ -29,8 +29,9 @@
require_once('editsection_form.php');
$id = required_param('id',PARAM_INT); // Week/topic ID
$sectionreturn = optional_param('sectionreturn', 0, PARAM_BOOL);
$PAGE->set_url('/course/editsection.php', array('id'=>$id));
$PAGE->set_url('/course/editsection.php', array('id'=>$id, 'sectionreturn'=> $sectionreturn));
$section = $DB->get_record('course_sections', array('id' => $id), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id' => $section->course), '*', MUST_EXIST);
@@ -42,12 +43,18 @@
$editoroptions = array('context'=>$context ,'maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes'=>$CFG->maxbytes, 'trusttext'=>false, 'noclean'=>true);
$section = file_prepare_standard_editor($section, 'summary', $editoroptions, $context, 'course', 'section', $section->id);
$section->usedefaultname = (is_null($section->name));
$mform = new editsection_form(null, array('course'=>$course, 'editoroptions'=>$editoroptions));
$mform = new editsection_form($PAGE->url, array('course'=>$course, 'editoroptions'=>$editoroptions));
$mform->set_data($section); // set current value
if ($sectionreturn) {
$returnurl = course_get_url($course, $section->section);
} else {
$returnurl = course_get_url($course);
}
/// If data submitted, then process and store.
if ($mform->is_cancelled()){
redirect(course_get_url($course, $section->section));
redirect($returnurl);
} else if ($data = $mform->get_data()) {
if (empty($data->usedefaultname)) {
@@ -61,7 +68,7 @@
$DB->update_record('course_sections', $section);
add_to_log($course->id, "course", "editsection", "editsection.php?id=$section->id", "$section->section");
$PAGE->navigation->clear_cache();
redirect(course_get_url($course, $section->section));
redirect($returnurl);
}
$sectionname = get_section_name($course, $section);

0 comments on commit a5a38c9

Please sign in to comment.