MDL-60115 mod_book: Book Resource Cancel Button Redirect Bug

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.
This commit is contained in:
Michael Brown 2018-04-02 04:01:34 +00:00
parent 39fab18e27
commit 37fdff573b

View File

@ -61,6 +61,12 @@ $mform = new book_chapter_edit_form(null, array('chapter'=>$chapter, 'options'=>
// 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 {