Permalink
Browse files

Merge branch 'MDL-60960-master' of git://github.com/ryanwyllie/moodle

  • Loading branch information...
dmonllao committed Jan 15, 2018
2 parents c1dd6af + 9aeb909 commit 2692af90323f717b164739fab55c20412538491e
Showing with 9 additions and 4 deletions.
  1. +9 −4 calendar/classes/local/event/container.php
@@ -151,11 +151,16 @@ function ($dbrow) {
// 2) Only process modules for courses a user has the capability to view OR they are enrolled in.
// 3) Only process modules for courses that are visible OR if the course is not visible, the user
// has the capability to view hidden courses.
if (!$cm->uservisible) {
return true;
}
$coursecontext = \context_course::instance($dbrow->courseid);
$canseecourse = has_capability('moodle/course:view', $coursecontext) || is_enrolled($coursecontext);
$canseecourse = $canseecourse &&
($cm->get_course()->visible || has_capability('moodle/course:viewhiddencourses', $coursecontext));
if (!$cm->uservisible || !$canseecourse) {
if (!$cm->get_course()->visible && !has_capability('moodle/course:viewhiddencourses', $coursecontext)) {
return true;
}
if (!has_capability('moodle/course:view', $coursecontext) && !is_enrolled($coursecontext)) {
return true;
}

0 comments on commit 2692af9

Please sign in to comment.