MDL-57457 mod_book: Fix bug with edit form when tagging disabled

This commit is contained in:
Andrew Hancox 2017-04-19 11:27:26 +01:00 committed by Marina Glancy
parent 4282634fcd
commit 0e8c334eb5

View File

@ -75,7 +75,10 @@ if ($mform->is_cancelled()) {
$DB->update_record('book_chapters', $data);
$DB->set_field('book', 'revision', $book->revision+1, array('id'=>$book->id));
$chapter = $DB->get_record('book_chapters', array('id' => $data->id));
core_tag_tag::set_item_tags('mod_book', 'book_chapters', $chapter->id, $context, $data->tags);
if (core_tag_tag::is_enabled('mod_book', 'book_chapters')) {
core_tag_tag::set_item_tags('mod_book', 'book_chapters', $chapter->id, $context, $data->tags);
}
\mod_book\event\chapter_updated::create_from_chapter($book, $context, $chapter)->trigger();
} else {
@ -127,8 +130,8 @@ echo $OUTPUT->heading($book->name);
if (core_tag_tag::is_enabled('mod_book', 'book_chapters')) {
$data = new StdClass();
$data->tags = core_tag_tag::get_item_tags_array('mod_book', 'book_chapters', $chapter->id);
$mform->set_data($data);
$mform->display();
}
$mform->set_data($data);
$mform->display();
echo $OUTPUT->footer();