From 67e56c0a3c0cb412066b6960dabd106502890452 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Thu, 11 Oct 2007 11:52:34 +0000 Subject: [PATCH] MDL-11699 - Addendum - rewrite the other half of the function too, so I can understand what it is doing, and fix a couple of minor logic errors along the way. Merged from MOODLE_19_STABLE. --- lib/weblib.php | 57 ++++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/lib/weblib.php b/lib/weblib.php index ecc8af12ab..50d7cfde67 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -3451,52 +3451,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)); -- 2.39.5