CONTRIB-3616 Book module do not display icon for book and chapter print
Credit goes to Peter Svec, thanks.
This commit is contained in:
+18
-18
@@ -26,32 +26,32 @@
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
function booktool_print_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $booknode) {
|
||||
global $USER, $PAGE, $CFG, $DB, $OUTPUT;
|
||||
global $USER, $PAGE, $CFG, $DB, $OUTPUT;
|
||||
|
||||
if ($PAGE->cm->modname !== 'book') {
|
||||
return;
|
||||
}
|
||||
if ($PAGE->cm->modname !== 'book') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($PAGE->cm->context)) {
|
||||
if (empty($PAGE->cm->context)) {
|
||||
$PAGE->cm->context = get_context_instance(CONTEXT_MODULE, $PAGE->cm->instance);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$params = $PAGE->url->params();
|
||||
$params = $PAGE->url->params();
|
||||
|
||||
if (empty($params['id']) or empty($params['chapterid'])) {
|
||||
return;
|
||||
}
|
||||
if (empty($params['id']) or empty($params['chapterid'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (has_capability('booktool/print:print', $PAGE->cm->context)) {
|
||||
$url1 = new moodle_url('/mod/book/tool/print/index.php', array('id'=>$params['id']));
|
||||
$url2 = new moodle_url('/mod/book/tool/print/index.php', array('id'=>$params['id'], 'chapterid'=>$params['chapterid']));
|
||||
$action = new action_link($url1, get_string('printbook', 'booktool_print'), new popup_action('click', $url1));
|
||||
$booknode->add('', $action, navigation_node::TYPE_SETTING, null, null, new pix_icon('book', '', 'booktool_print', array('class'=>'icon')));
|
||||
$action = new action_link($url2, get_string('printchapter', 'booktool_print'), new popup_action('click', $url2));
|
||||
$booknode->add('', $action, navigation_node::TYPE_SETTING, null, null, new pix_icon('chapter', '', 'booktool_print', array('class'=>'icon')));
|
||||
}
|
||||
if (has_capability('booktool/print:print', $PAGE->cm->context)) {
|
||||
$url1 = new moodle_url('/mod/book/tool/print/index.php', array('id'=>$params['id']));
|
||||
$url2 = new moodle_url('/mod/book/tool/print/index.php', array('id'=>$params['id'], 'chapterid'=>$params['chapterid']));
|
||||
$action = new action_link($url1, get_string('printbook', 'booktool_print'), new popup_action('click', $url1));
|
||||
$booknode->add(get_string('printbook', 'booktool_print'), $action, navigation_node::TYPE_SETTING, null, null, new pix_icon('book', '', 'booktool_print', array('class'=>'icon')));
|
||||
$action = new action_link($url2, get_string('printchapter', 'booktool_print'), new popup_action('click', $url2));
|
||||
$booknode->add(get_string('printchapter', 'booktool_print'), $action, navigation_node::TYPE_SETTING, null, null, new pix_icon('chapter', '', 'booktool_print', array('class'=>'icon')));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user