Merge branch 'MDL-56293-master' of git://github.com/andrewnicols/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2016-10-18 19:08:08 +02:00
commit 05e588a056
3 changed files with 28 additions and 9 deletions

View File

@ -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("<strong>$title</strong><p>$strconfirm</p>", $continue, $cancel);
echo $OUTPUT->footer();
echo $OUTPUT->footer();

View File

@ -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);

View File

@ -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);