Skip to content

Commit 2692af9

Browse files
author
David Monllao
committed
Merge branch 'MDL-60960-master' of git://github.com/ryanwyllie/moodle
2 parents c1dd6af + 9aeb909 commit 2692af9

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

calendar/classes/local/event/container.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,16 @@ function ($dbrow) {
151151
// 2) Only process modules for courses a user has the capability to view OR they are enrolled in.
152152
// 3) Only process modules for courses that are visible OR if the course is not visible, the user
153153
// has the capability to view hidden courses.
154+
if (!$cm->uservisible) {
155+
return true;
156+
}
157+
154158
$coursecontext = \context_course::instance($dbrow->courseid);
155-
$canseecourse = has_capability('moodle/course:view', $coursecontext) || is_enrolled($coursecontext);
156-
$canseecourse = $canseecourse &&
157-
($cm->get_course()->visible || has_capability('moodle/course:viewhiddencourses', $coursecontext));
158-
if (!$cm->uservisible || !$canseecourse) {
159+
if (!$cm->get_course()->visible && !has_capability('moodle/course:viewhiddencourses', $coursecontext)) {
160+
return true;
161+
}
162+
163+
if (!has_capability('moodle/course:view', $coursecontext) && !is_enrolled($coursecontext)) {
159164
return true;
160165
}
161166

0 commit comments

Comments
 (0)