Skip to content

Commit

Permalink
MDL-60115 mod_book: Book Resource Cancel Button Redirect Bug
Browse files Browse the repository at this point in the history
When the user creates a book but adds no chapters, hitting cancel on
 the chapter creation page would redirect you right back to the same
 page with no explanation. This solution redirects to the course page
 when canceling chapter creation when no chapters are present.
  • Loading branch information
Michael Brown committed Apr 2, 2018
1 parent 6a643e9 commit 06a28cd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mod/book/edit.php
Expand Up @@ -61,6 +61,12 @@

// If data submitted, then process and store.
if ($mform->is_cancelled()) {
// Make sure at least one chapter exists.
$chapters = book_preload_chapters($book);
if (!$chapters) {
redirect(new moodle_url('/course/view.php', array('id' => $course->id))); // Back to course view.
}

if (empty($chapter->id)) {
redirect("view.php?id=$cm->id");
} else {
Expand Down

0 comments on commit 06a28cd

Please sign in to comment.