Merge branch 'MDL-68498-master' of git://github.com/mihailges/moodle
This commit is contained in:
+13
-7
@@ -2845,8 +2845,8 @@ class global_navigation extends navigation_node {
|
||||
return true;
|
||||
}
|
||||
|
||||
$sitecontext = context_system::instance();
|
||||
$navoptions = course_get_user_navigation_options($sitecontext, $course);
|
||||
$systemcontext = context_system::instance();
|
||||
$navoptions = course_get_user_navigation_options($systemcontext, $course);
|
||||
|
||||
// Hidden node that we use to determine if the front page navigation is loaded.
|
||||
// This required as there are not other guaranteed nodes that may be loaded.
|
||||
@@ -2918,23 +2918,29 @@ class global_navigation extends navigation_node {
|
||||
$context = $this->page->context;
|
||||
switch ($context->contextlevel) {
|
||||
case CONTEXT_COURSECAT:
|
||||
$type = self::TYPE_CATEGORY;
|
||||
// OK, expected context level.
|
||||
break;
|
||||
case CONTEXT_COURSE:
|
||||
$type = self::TYPE_COURSE;
|
||||
// OK, expected context level if not on frontpage.
|
||||
if ($COURSE->id != $SITE->id) {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
$type = self::TYPE_CUSTOM;
|
||||
$context = $sitecontext;
|
||||
// If this context is part of a course (excluding frontpage), use the course context.
|
||||
// Otherwise, use the system context.
|
||||
$coursecontext = $context->get_course_context(false);
|
||||
if ($coursecontext && $coursecontext->instanceid !== $SITE->id) {
|
||||
$context = $coursecontext;
|
||||
} else {
|
||||
$context = $systemcontext;
|
||||
}
|
||||
}
|
||||
|
||||
$params = ['contextid' => $context->id];
|
||||
if (has_capability('moodle/contentbank:access', $context)) {
|
||||
$url = new moodle_url('/contentbank/index.php', $params);
|
||||
$node = $coursenode->add(get_string('contentbank'), $url,
|
||||
$type, null, 'contentbank', new pix_icon('i/contentbank', ''));
|
||||
self::TYPE_CUSTOM, null, 'contentbank', new pix_icon('i/contentbank', ''));
|
||||
$node->showinflatnavigation = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user