MDL-71912 mod_book: Restore hastily removed editing setting.

This commit is contained in:
abgreeve 2021-11-10 16:07:50 +08:00
parent 7b935ca87b
commit e5b0be3192
3 changed files with 21 additions and 2 deletions

View File

@ -335,6 +335,26 @@ function book_extend_settings_navigation(settings_navigation $settingsnav, navig
$firstkey = null;
}
$params = $PAGE->url->params();
if ($PAGE->cm->modname === 'book' and !empty($params['id']) and !empty($params['chapterid'])
and has_capability('mod/book:edit', $PAGE->cm->context)) {
if (!empty($USER->editing)) {
$string = get_string("turneditingoff");
$edit = '0';
} else {
$string = get_string("turneditingon");
$edit = '1';
}
$url = new moodle_url('/mod/book/view.php', array('id'=>$params['id'], 'chapterid'=>$params['chapterid'], 'edit'=>$edit, 'sesskey'=>sesskey()));
$editnode = navigation_node::create($string, $url, navigation_node::TYPE_SETTING);
$editnode->set_show_in_secondary_navigation(false);
$booknode->add_node($editnode, $firstkey);
if (!$PAGE->theme->haseditswitch) {
$PAGE->set_button($OUTPUT->single_button($url, $string));
}
}
$plugins = core_component::get_plugin_list('booktool');
foreach ($plugins as $plugin => $dir) {
if (file_exists("$dir/lib.php")) {

View File

@ -61,7 +61,6 @@ Feature: In a book, create chapters and sub chapters
And I should see "1. Dummy first chapter" in the ".book_content" "css_element"
And I should see "1. Dummy first chapter" in the "strong" "css_element"
@skip_interim
Scenario: Change editing mode for an individual chapter
Given I am on the "Test book" Activity page
And I should see "Add new chapter"

View File

@ -1,4 +1,4 @@
@mod @mod_book @core_tag @javascript @skip_interim
@mod @mod_book @core_tag @javascript
Feature: Edited book chapters handle tags correctly
In order to get book chapters properly labelled
As a user