Browse files

Merge branch 'MDL-31122-m22' of git://github.com/sammarshallou/moodle…

… into MOODLE_22_STABLE
  • Loading branch information...
2 parents fe3130a + 54b1dc4 commit b292cea475d1d0a3a2b7dbf67cd56782b14f0230 @stronk7 stronk7 committed Jan 25, 2012
Showing with 25 additions and 4 deletions.
  1. +25 −4 lib/navigationlib.php
View
29 lib/navigationlib.php
@@ -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
@@ -1172,13 +1174,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) {
@@ -1629,7 +1647,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);
@@ -1677,7 +1697,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) {

0 comments on commit b292cea

Please sign in to comment.