From 83d3858b1637e5a10a63210986a1b1ad8de8b6b5 Mon Sep 17 00:00:00 2001 From: Andrew Robert Nicols Date: Wed, 20 Jun 2012 17:02:00 +0100 Subject: [PATCH] MDL-33916 Ensure that capabilities are checked for cached user enrolments --- lib/accesslib.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/accesslib.php b/lib/accesslib.php index dd7f5b074e2..084c4d5ccff 100644 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -1935,6 +1935,9 @@ function is_enrolled(context $context, $user = null, $withcapability = '', $only $coursecontext->reload_if_dirty(); if (isset($USER->enrol['enrolled'][$coursecontext->instanceid])) { if ($USER->enrol['enrolled'][$coursecontext->instanceid] > time()) { + if ($withcapability and !has_capability($withcapability, $context, $userid)) { + return false; + } return true; } }