MDL-87671 core: Add restricted sections to navigation

This commit is contained in:
Amaia Anabitarte
2026-02-06 11:56:58 +01:00
parent dbf9b2bc1f
commit 218655f035
2 changed files with 10 additions and 1 deletions
@@ -0,0 +1,7 @@
issueNumber: MDL-87671
notes:
core:
- message: >-
Nodes from sections with visible restrictions have been added to the
navigation tree
type: improved
@@ -1027,6 +1027,7 @@ class global_navigation extends navigation_node {
unset($sections[$key]->summary);
$sections[$key]->hasactivites = false;
if (!array_key_exists($section->sectionnum, $modinfo->sections)) {
// It may be because the section is not available for the user.
continue;
}
foreach ($section->get_sequence_cm_infos() as $cm) {
@@ -1083,6 +1084,7 @@ class global_navigation extends navigation_node {
global $CFG, $DB, $USER, $SITE;
require_once($CFG->dirroot . '/course/lib.php');
$format = course_get_format($course->id);
[$sections, $activities] = $this->generate_sections_and_activities($course);
$navigationsections = [];
@@ -1093,7 +1095,7 @@ class global_navigation extends navigation_node {
}
if (
!$section->uservisible
!$format->is_section_visible($section)
|| (
!$this->showemptysections
&& !$section->hasactivites