Skip to content

Commit

Permalink
MDL-31122 Navigation: Do not show week in navigation if it contains o…
Browse files Browse the repository at this point in the history
…nly labels
  • Loading branch information
sammarshallou committed Jan 19, 2012
1 parent 1aff7bb commit c59e5f0
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions lib/navigationlib.php
Expand Up @@ -127,6 +127,8 @@ class navigation_node implements renderable {
protected static $fullmeurl = null;
/** @var bool toogles auto matching of active node */
public static $autofindactive = true;
/** @var mixed If set to an int, that section will be included even if it has no activities */
public $includesectionnum = false;

/**
* Constructs a new navigation_node
Expand Down Expand Up @@ -1176,13 +1178,29 @@ public function initialise() {
}

$this->add_course_essentials($coursenode, $course);

// Get section number from $cm (if provided) - we need this
// before loading sections in order to tell it to load this section
// even if it would not normally display (=> it contains only
// a label, which we are now editing)
$sectionnum = isset($cm->sectionnum) ? $cm->sectionnum : 0;
if ($sectionnum) {
// This value has to be stored in a member variable because
// otherwise we would have to pass it through a public API
// to course formats and they would need to change their
// functions to pass it along again...
$this->includesectionnum = $sectionnum;
} else {
$this->includesectionnum = false;
}

// Load the course sections into the page
$sections = $this->load_course_sections($course, $coursenode);
if ($course->id != SITEID) {
// Find the section for the $CM associated with the page and collect
// its section number.
if (isset($cm->sectionnum)) {
$cm->sectionnumber = $cm->sectionnum;
if ($sectionnum) {
$cm->sectionnumber = $sectionnum;
} else {
foreach ($sections as $section) {
if ($section->id == $cm->section) {
Expand Down Expand Up @@ -1639,7 +1657,9 @@ protected function generate_sections_and_activities(stdClass $course) {
}
}
$activities[$cmid] = $activity;
$sections[$key]->hasactivites = true;
if ($activity->display) {
$sections[$key]->hasactivites = true;
}
}
}
$this->cache->set('course_sections_'.$course->id, $sections);
Expand Down Expand Up @@ -1676,7 +1696,8 @@ public function load_generic_course_sections(stdClass $course, navigation_node $
if ($course->id == SITEID) {
$this->load_section_activities($coursenode, $section->section, $activities);
} else {
if ((!$viewhiddensections && !$section->visible) || (!$this->showemptysections && !$section->hasactivites)) {
if ((!$viewhiddensections && !$section->visible) || (!$this->showemptysections &&
!$section->hasactivites && $this->includesectionnum !== $section->section)) {
continue;
}
if ($namingfunctionexists) {
Expand Down

0 comments on commit c59e5f0

Please sign in to comment.