Merge branch 'MDL-56295-master' of git://github.com/andrewnicols/moodle
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 18 Oct 2016 18:02:22 +0000 (20:02 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 18 Oct 2016 18:02:22 +0000 (20:02 +0200)
1  2 
mod/book/delete.php
mod/book/lang/en/book.php
mod/book/locallib.php

@@@ -72,28 -81,25 +81,27 @@@ if ($confirm) 
  
      \mod_book\event\chapter_deleted::create_from_chapter($book, $context, $chapter)->trigger();
  
-     book_preload_chapters($book); // Fix structure.
-     $DB->set_field('book', 'revision', $book->revision+1, array('id'=>$book->id));
+     // Ensure that the book structure is correct.
+     // book_preload_chapters will fix parts including the pagenum.
 -    book_preload_chapters($book);
++    $chapters = book_preload_chapters($book);
 +
-     redirect('view.php?id='.$cm->id);
- }
++    book_add_fake_block($chapters, $chapter, $book, $cm);
  
- $chapters = book_preload_chapters($book);
book_add_fake_block($chapters, $chapter, $book, $cm);
+     // Bump the book revision.
    $DB->set_field('book', 'revision', $book->revision + 1, ['id' => $book->id]);
  
- echo $OUTPUT->header();
- echo $OUTPUT->heading($book->name);
+     if ($subchaptercount) {
+         $message = get_string('chapterandsubchaptersdeleted', 'mod_book', (object) [
+             'title' => format_string($chapter->title),
+             'subchapters' => $subchaptercount,
+         ]);
+     } else {
+         $message = get_string('chapterdeleted', 'mod_book', (object) [
+             'title' => format_string($chapter->title),
+         ]);
+     }
  
- // The operation has not been confirmed yet so ask the user to do so.
- if ($chapter->subchapter) {
-     $strconfirm = get_string('confchapterdelete', 'mod_book');
- } else {
-     $strconfirm = get_string('confchapterdeleteall', 'mod_book');
+     redirect(new moodle_url('/mod/book/view.php', ['id' => $cm->id]), $message);
  }
- echo '<br />';
- $continue = new moodle_url('/mod/book/delete.php', array('id'=>$cm->id, 'chapterid'=>$chapter->id, 'confirm'=>1));
- $cancel = new moodle_url('/mod/book/view.php', array('id'=>$cm->id, 'chapterid'=>$chapter->id));
- $title = format_string($chapter->title);
- echo $OUTPUT->confirm("<strong>$title</strong><p>$strconfirm</p>", $continue, $cancel);
  
echo $OUTPUT->footer();
redirect(new moodle_url('/mod/book/view.php', ['id' => $cm->id]));
Simple merge
Simple merge