Binary files old/.DS_Store and new/.DS_Store differ diff -rupN old/course/edit.php new/course/edit.php --- old/course/edit.php 2008-07-07 09:16:38.000000000 -0500 +++ new/course/edit.php 2010-02-26 13:56:39.000000000 -0600 @@ -9,8 +9,20 @@ $id = optional_param('id', 0, PARAM_INT); // course id $categoryid = optional_param('category', 0, PARAM_INT); // course category - can be changed in edit form + $returnurl = optional_param('returnurl', '', PARAM_LOCALURL); - + if (!empty($returnurl)) { + if (!confirm_sesskey()) { + // Ensure that the session key is defined and matches the key for the current logged in user. + $returnurl = ''; + } else { + // Remove wwwroot from $returnurl if it's included + if (substr($returnurl, 0, strlen($CFG->wwwroot)) == $CFG->wwwroot) { + $returnurl = substr($returnurl, strlen($CFG->wwwroot)); + } + } + } + /// basic access control checks if ($id) { // editing course @@ -69,6 +81,7 @@ // now override defaults if course already exists if (!empty($course)) { $course->enrolpassword = $course->password; // we need some other name for password field MDL-9929 + $course->returnurl = $returnurl; $editform->set_data($course); } if ($editform->is_cancelled()){ @@ -122,7 +135,12 @@ if (!update_course($data)) { print_error('coursenotupdated'); } - redirect($CFG->wwwroot."/course/view.php?id=$course->id"); + // Allows redirecting to different locations after save if defined + if (!empty($data->returnurl)) { + redirect($CFG->wwwroot.$data->returnurl); + } else { + redirect($CFG->wwwroot."/course/view.php?id=$course->id"); + } } } diff -rupN old/course/edit_form.php new/course/edit_form.php --- old/course/edit_form.php 2009-10-02 09:05:36.000000000 -0500 +++ new/course/edit_form.php 2010-02-25 09:46:13.000000000 -0600 @@ -67,6 +67,10 @@ class course_edit_form extends moodlefor $mform->addElement('hidden', 'category', null); $mform->setType('category', PARAM_INT); } + + // Allows redirecting to different locations after save if defined + $mform->addElement('hidden','returnurl'); + $mform->setHelpButton('category', array('coursecategory', get_string('category'))); $mform->setDefault('category', $category->id); $mform->setType('category', PARAM_INT);