Permalink
Browse files

Merge branch 'wip-MDL-40191-m24' of git://github.com/marinaglancy/moo…

…dle into MOODLE_24_STABLE
  • Loading branch information...
2 parents d8d43cd + 60aae88 commit 838a2120fb72703cb22c6699f4c3525d769b84e2 @danpoltawski danpoltawski committed Dec 2, 2013
Showing with 14 additions and 14 deletions.
  1. +14 −14 lib/navigationlib.php
View
@@ -1201,12 +1201,14 @@ public function initialise() {
// Load the course sections into the page
$this->load_course_sections($course, $coursenode, null, $cm);
$activity = $coursenode->find($cm->id, navigation_node::TYPE_ACTIVITY);
- // Finally load the cm specific navigaton information
- $this->load_activity($cm, $course, $activity);
- // Check if we have an active ndoe
- if (!$activity->contains_active_node() && !$activity->search_for_active_node()) {
- // And make the activity node active.
- $activity->make_active();
+ if (!empty($activity)) {
+ // Finally load the cm specific navigaton information
+ $this->load_activity($cm, $course, $activity);
+ // Check if we have an active ndoe
+ if (!$activity->contains_active_node() && !$activity->search_for_active_node()) {
+ // And make the activity node active.
+ $activity->make_active();
+ }
}
break;
case CONTEXT_USER :
@@ -1822,9 +1824,6 @@ protected function generate_sections_and_activities(stdClass $course) {
}
foreach ($modinfo->sections[$section->section] as $cmid) {
$cm = $modinfo->cms[$cmid];
- if (!$cm->uservisible) {
- continue;
- }
$activity = new stdClass;
$activity->id = $cm->id;
$activity->course = $course->id;
@@ -1842,7 +1841,7 @@ protected function generate_sections_and_activities(stdClass $course) {
$activity->display = false;
} else {
$activity->url = $cm->get_url()->out();
- $activity->display = true;
+ $activity->display = $cm->uservisible ? true : false;
if (self::module_extends_navigation($cm->modname)) {
$activity->nodetype = navigation_node::NODETYPE_BRANCH;
}
@@ -1981,9 +1980,6 @@ protected function load_stealth_activity(navigation_node $coursenode, $modinfo)
return null;
}
$cm = $modinfo->cms[$this->page->cm->id];
- if (!$cm->uservisible) {
- return null;
- }
if ($cm->icon) {
$icon = new pix_icon($cm->icon, get_string('modulename', $cm->modname), $cm->iconcomponent);
} else {
@@ -1993,7 +1989,11 @@ protected function load_stealth_activity(navigation_node $coursenode, $modinfo)
$activitynode = $coursenode->add(format_string($cm->name), $url, navigation_node::TYPE_ACTIVITY, null, $cm->id, $icon);
$activitynode->title(get_string('modulename', $cm->modname));
$activitynode->hidden = (!$cm->visible);
- if (!$url) {
+ if (!$cm->uservisible) {
+ // Do not show any error here, let the page handle exception that activity is not visible for the current user.
+ // Also there may be no exception at all in case when teacher is logged in as student.
+ $activitynode->display = false;
+ } else if (!$url) {
// Don't show activities that don't have links!
$activitynode->display = false;
} else if (self::module_extends_navigation($cm->modname)) {

0 comments on commit 838a212

Please sign in to comment.