Commit 63d7b1ac authored by Andrew Nicols's avatar Andrew Nicols
Browse files

MDL-42041 mod_book: Add Turn Editing On to page body

parent 5c33a0db
......@@ -291,7 +291,7 @@ function book_supports($feature) {
* @return void
*/
function book_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $booknode) {
global $USER, $PAGE;
global $USER, $PAGE, $OUTPUT;
$plugins = core_component::get_plugin_list('booktool');
foreach ($plugins as $plugin => $dir) {
......@@ -306,7 +306,8 @@ function book_extend_settings_navigation(settings_navigation $settingsnav, navig
$params = $PAGE->url->params();
if (!empty($params['id']) and !empty($params['chapterid']) and has_capability('mod/book:edit', $PAGE->cm->context)) {
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';
......@@ -316,6 +317,7 @@ function book_extend_settings_navigation(settings_navigation $settingsnav, navig
}
$url = new moodle_url('/mod/book/view.php', array('id'=>$params['id'], 'chapterid'=>$params['chapterid'], 'edit'=>$edit, 'sesskey'=>sesskey()));
$booknode->add($string, $url, navigation_node::TYPE_SETTING);
$PAGE->set_button($OUTPUT->single_button($url, $string));
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment