From 52fc56a79d409f12414b233903798f3f132df2ad Mon Sep 17 00:00:00 2001 From: Jason Fowler Date: Thu, 13 Sep 2012 12:30:32 +0800 Subject: [PATCH] MDL-32184 - Course - Fixing incorrect redirect when toggling course edit while inside an activity -- Patch provided by Kanika Goyal --- course/view.php | 5 +++++ lib/navigationlib.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/course/view.php b/course/view.php index f0c307983ed..e6b0d4b1a1e 100644 --- a/course/view.php +++ b/course/view.php @@ -20,6 +20,7 @@ $marker = optional_param('marker',-1 , PARAM_INT); $switchrole = optional_param('switchrole',-1, PARAM_INT); $modchooser = optional_param('modchooser', -1, PARAM_BOOL); + $return = optional_param('return', 0, PARAM_LOCALURL); $params = array(); if (!empty($name)) { @@ -139,6 +140,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 { $url = new moodle_url($PAGE->url, array('notifyeditingon' => 1)); redirect($url); @@ -152,6 +155,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); } diff --git a/lib/navigationlib.php b/lib/navigationlib.php index d781b6f9626..8cad8a2705e 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -3562,7 +3562,7 @@ class settings_navigation extends navigation_node { $baseurl->param('sesskey', sesskey()); } else { // Edit on the main course page. - $baseurl = new moodle_url('/course/view.php', array('id'=>$course->id, 'sesskey'=>sesskey())); + $baseurl = new moodle_url('/course/view.php', array('id'=>$course->id, 'return'=>$this->page->url->out_as_local_url(false), 'sesskey'=>sesskey())); } $editurl = clone($baseurl);