MDL-32508 course: turn editting on/off stays on current page

Rather than always going to the index page, we can edit on section page
This commit is contained in:
Dan Poltawski
2012-05-04 10:53:01 +08:00
parent 1abf12532d
commit d628215d49
2 changed files with 10 additions and 2 deletions
+1 -1
View File
@@ -177,7 +177,7 @@
// 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);
}
+9 -1
View 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');