Skip to content
Browse files

MDL-32184 - Course - Fixing incorrect redirect when toggling course e…

…dit while inside an activity – Patch provided by Kanika Goyal
  • Loading branch information...
1 parent c5575c6 commit 04c1d5a34218f017944b1cbbb654cf6f92a2242e @jsnfwlr jsnfwlr committed Sep 13, 2012
Showing with 6 additions and 1 deletion.
  1. +5 −0 course/view.php
  2. +1 −1 lib/navigationlib.php
View
5 course/view.php
@@ -17,6 +17,7 @@
$move = optional_param('move', 0, PARAM_INT);
$marker = optional_param('marker',-1 , PARAM_INT);
$switchrole = optional_param('switchrole',-1, PARAM_INT);
+ $return = optional_param('return', 0, PARAM_LOCALURL);
if (empty($id) && empty($name) && empty($idnumber)) {
print_error('unspecifycourseid', 'error');
@@ -110,6 +111,8 @@
// Redirect to site root if Editing is toggled on frontpage
if ($course->id == SITEID) {
redirect($CFG->wwwroot .'/?redirect=0');
+ } else if (!empty($return)) {
+ redirect($CFG->wwwroot . $return);
} else {
redirect($PAGE->url);
}
@@ -122,6 +125,8 @@
// Redirect to site root if Editing is toggled on frontpage
if ($course->id == SITEID) {
redirect($CFG->wwwroot .'/?redirect=0');
+ } else if (!empty($return)) {
+ redirect($CFG->wwwroot . $return);
} else {
redirect($PAGE->url);
}
View
2 lib/navigationlib.php
@@ -3177,7 +3177,7 @@ protected function load_course_settings($forceopen = false) {
if (has_capability('moodle/course:update', $coursecontext)) {
// Add the turn on/off settings
- $url = new moodle_url('/course/view.php', array('id'=>$course->id, 'sesskey'=>sesskey()));
+ $url = new moodle_url('/course/view.php', array('id'=>$course->id, 'return'=>str_replace($CFG->wwwroot, '', $this->page->url->out(false)), 'sesskey'=>sesskey()));
if ($this->page->user_is_editing()) {
$url->param('edit', 'off');
$editstring = get_string('turneditingoff');

0 comments on commit 04c1d5a

Please sign in to comment.
Something went wrong with that request. Please try again.