diff --git a/lib/weblib.php b/lib/weblib.php index 9ce7bb8a83f..214d12d3b1a 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -6160,7 +6160,21 @@ function convert_tabrows_to_tree($tabrows, $selected, $inactive, $activated) { * @param string $iconpath The path to the icon to be displayed */ function page_doc_link($text='', $iconpath='') { - global $ME, $CFG; + global $ME, $COURSE, $CFG; + + if (empty($CFG->docroot)) { + return ''; + } + + if (empty($COURSE->id)) { + $context = get_context_instance(CONTEXT_SYSTEM); + } else { + $context = get_context_instance(CONTEXT_COURSE, $COURSE->id); + } + + if (!has_capability('moodle/site:doclinks', $context)) { + return ''; + } if (empty($CFG->pagepath)) { $CFG->pagepath = $ME; @@ -6187,7 +6201,7 @@ function page_doc_link($text='', $iconpath='') { function doc_link($path='', $text='', $iconpath='') { global $CFG; - if (empty($CFG->docroot) || !has_capability('moodle/site:doclinks')) { + if (empty($CFG->docroot)) { return ''; }