diff --git a/mod/book/delete.php b/mod/book/delete.php index afd1bc1f1bf..fcac77772ef 100644 --- a/mod/book/delete.php +++ b/mod/book/delete.php @@ -78,6 +78,9 @@ if ($confirm) { // the operation was confirmed. redirect('view.php?id='.$cm->id); } +$chapters = book_preload_chapters($book); +book_add_fake_block($chapters, $chapter, $book, $cm); + echo $OUTPUT->header(); echo $OUTPUT->heading($book->name); @@ -93,4 +96,4 @@ $cancel = new moodle_url('/mod/book/view.php', array('id'=>$cm->id, 'chapterid'= $title = format_string($chapter->title); echo $OUTPUT->confirm("$title

$strconfirm

", $continue, $cancel); -echo $OUTPUT->footer(); \ No newline at end of file +echo $OUTPUT->footer(); diff --git a/mod/book/edit.php b/mod/book/edit.php index ce89704eaae..f3133532285 100644 --- a/mod/book/edit.php +++ b/mod/book/edit.php @@ -113,6 +113,10 @@ if ($mform->is_cancelled()) { $PAGE->set_title($book->name); $PAGE->set_heading($course->fullname); +if ($chapters = book_preload_chapters($book)) { + book_add_fake_block($chapters, $chapter, $book, $cm); +} + echo $OUTPUT->header(); echo $OUTPUT->heading($book->name); diff --git a/mod/book/locallib.php b/mod/book/locallib.php index 0cfe1921b7e..c80a4f54d5c 100644 --- a/mod/book/locallib.php +++ b/mod/book/locallib.php @@ -161,16 +161,28 @@ function book_get_chapter_title($chid, $chapters, $book, $context) { } /** - * Add the book TOC sticky block to the default region + * Add the book TOC sticky block to the default region. * - * @param array $chapters - * @param stdClass $chapter - * @param stdClass $book - * @param stdClass $cm - * @param bool $edit + * @param array $chapters The Chapters in the book + * @param stdClass $chapter The current chapter + * @param stdClass $book The book + * @param stdClass $cm The course module + * @param bool $edit Whether the user is editing */ -function book_add_fake_block($chapters, $chapter, $book, $cm, $edit) { - global $OUTPUT, $PAGE; +function book_add_fake_block($chapters, $chapter, $book, $cm, $edit = null) { + global $PAGE, $USER; + + if ($edit === null) { + if (has_capability('mod/book:edit', context_module::instance($cm->id))) { + if (isset($USER->editing)) { + $edit = $USER->editing; + } else { + $edit = 0; + } + } else { + $edit = 0; + } + } $toc = book_get_toc($chapters, $chapter, $book, $cm, $edit, 0);