MDL-32508 course: turn editting on/off stays on current page
authorDan Poltawski <dan@moodle.com>
Mon, 30 Apr 2012 03:23:37 +0000 (11:23 +0800)
committerDan Poltawski <dan@moodle.com>
Fri, 4 May 2012 02:53:01 +0000 (10:53 +0800)
Rather than always going to the index page, we can edit on section page

course/view.php
lib/navigationlib.php

index a817865..7a4d7aa 100644 (file)
     // what to do, even though the link also appears in the course admin block.  It also
     // means you can back out of a situation where you removed the admin block. :)
     if ($PAGE->user_allowed_editing()) {
-        $buttons = $OUTPUT->edit_button(new moodle_url('/course/view.php', array('id' => $course->id)));
+        $buttons = $OUTPUT->edit_button($PAGE->url);
         $PAGE->set_button($buttons);
     }
 
index 0336362..d2e7ed5 100644 (file)
@@ -3282,7 +3282,15 @@ class settings_navigation extends navigation_node {
 
         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()));
+
+            if ($this->page->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) {
+                // We are on the course page, retain the current page params e.g. section.
+                $url = clone($this->page->url);
+                $url->param('sesskey', sesskey());
+            } else {
+                // Edit on the main course page.
+                $url = new moodle_url('/course/view.php', array('id'=>$course->id, 'sesskey'=>sesskey()));
+            }
             if ($this->page->user_is_editing()) {
                 $url->param('edit', 'off');
                 $editstring = get_string('turneditingoff');