mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-40191 navigation: do not throw an error if activity is not visible
navigationlib is not the place to check it, let the page itself decide what to do in this case
This commit is contained in:
parent
f7434db109
commit
4fd2a16e35
@ -1850,9 +1850,6 @@ class global_navigation extends navigation_node {
|
|||||||
}
|
}
|
||||||
foreach ($modinfo->sections[$section->section] as $cmid) {
|
foreach ($modinfo->sections[$section->section] as $cmid) {
|
||||||
$cm = $modinfo->cms[$cmid];
|
$cm = $modinfo->cms[$cmid];
|
||||||
if (!$cm->uservisible) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$activity = new stdClass;
|
$activity = new stdClass;
|
||||||
$activity->id = $cm->id;
|
$activity->id = $cm->id;
|
||||||
$activity->course = $course->id;
|
$activity->course = $course->id;
|
||||||
@ -1870,7 +1867,7 @@ class global_navigation extends navigation_node {
|
|||||||
$activity->display = false;
|
$activity->display = false;
|
||||||
} else {
|
} else {
|
||||||
$activity->url = $cm->get_url()->out();
|
$activity->url = $cm->get_url()->out();
|
||||||
$activity->display = true;
|
$activity->display = $cm->uservisible ? true : false;
|
||||||
if (self::module_extends_navigation($cm->modname)) {
|
if (self::module_extends_navigation($cm->modname)) {
|
||||||
$activity->nodetype = navigation_node::NODETYPE_BRANCH;
|
$activity->nodetype = navigation_node::NODETYPE_BRANCH;
|
||||||
}
|
}
|
||||||
@ -2009,9 +2006,6 @@ class global_navigation extends navigation_node {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$cm = $modinfo->cms[$this->page->cm->id];
|
$cm = $modinfo->cms[$this->page->cm->id];
|
||||||
if (!$cm->uservisible) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if ($cm->icon) {
|
if ($cm->icon) {
|
||||||
$icon = new pix_icon($cm->icon, get_string('modulename', $cm->modname), $cm->iconcomponent);
|
$icon = new pix_icon($cm->icon, get_string('modulename', $cm->modname), $cm->iconcomponent);
|
||||||
} else {
|
} else {
|
||||||
@ -2021,7 +2015,11 @@ class global_navigation extends navigation_node {
|
|||||||
$activitynode = $coursenode->add(format_string($cm->name), $url, navigation_node::TYPE_ACTIVITY, null, $cm->id, $icon);
|
$activitynode = $coursenode->add(format_string($cm->name), $url, navigation_node::TYPE_ACTIVITY, null, $cm->id, $icon);
|
||||||
$activitynode->title(get_string('modulename', $cm->modname));
|
$activitynode->title(get_string('modulename', $cm->modname));
|
||||||
$activitynode->hidden = (!$cm->visible);
|
$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!
|
// Don't show activities that don't have links!
|
||||||
$activitynode->display = false;
|
$activitynode->display = false;
|
||||||
} else if (self::module_extends_navigation($cm->modname)) {
|
} else if (self::module_extends_navigation($cm->modname)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user