diff --git a/lib/weblib.php b/lib/weblib.php index ecc8af12ab7..921db0fe68e 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -2582,14 +2582,12 @@ function print_header_simple($title='', $heading='', $navigation='', $focus='', global $COURSE, $CFG; - $shortname =''; - if ($COURSE->id != SITEID) { - $shortname = ''. $COURSE->shortname .' ->'; - } - // If old style nav prepend course short name otherwise leave $navigation object alone if (!is_newnav($navigation)) { - $navigation = $shortname.' '.$navigation; + if ($COURSE->id != SITEID) { + $shortname = ''. $COURSE->shortname .' ->'; + $navigation = $shortname.' '.$navigation; + } } $output = print_header($COURSE->shortname .': '. $title, $COURSE->fullname .' '. $heading, $navigation, $focus, $meta, @@ -3451,52 +3449,55 @@ function build_navigation($extranavlinks, $cm = null) { //Merge in extra navigation links $navlinks = array_merge($navlinks, $extranavlinks); + // Work out whether we should be showing the activity (e.g. Forums) link. + // Note: build_navigation() is called from many places -- + // install & upgrade for example -- where we cannot count on the + // roles infrastructure to be defined. Hence the $CFG->rolesactive check. + if (!isset($CFG->hideactivitytypenavlink)) { + $CFG->hideactivitytypenavlink == 0; + } + if ($CFG->hideactivitytypenavlink == 2) { + $hideactivitylink = true; + } else if ($CFG->hideactivitytypenavlink == 1 && $CFG->rolesactive && + !empty($COURSE->id) && $COURSE->id != SITEID) { + if (!isset($COURSE->context)) { + $COURSE->context = get_context_instance(CONTEXT_COURSE, $COURSE->id); + } + $hideactivitylink = !has_capability('moodle/course:manageactivities', $COURSE->context); + } else { + $hideactivitylink = false; + } + //Construct an unordered list from $navlinks //Accessibility: heading hidden from visual browsers by default. $navigation = '

'.get_string('youarehere','access')."

"; return(array('newnav' => true, 'navlinks' => $navigation));