Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'MDL-60960-master' of git://github.com/ryanwyllie/moodle
  • Loading branch information
David Monllao committed Jan 15, 2018
2 parents c1dd6af + 9aeb909 commit 2692af9
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions calendar/classes/local/event/container.php
Expand Up @@ -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;
}

Expand Down

0 comments on commit 2692af9

Please sign in to comment.