MDL-33916 Ensure that capabilities are checked for cached user enrolments
authorAndrew Robert Nicols <andrew.nicols@luns.net.uk>
Wed, 20 Jun 2012 16:02:00 +0000 (17:02 +0100)
committerDan Poltawski <dan@moodle.com>
Mon, 2 Jul 2012 09:36:51 +0000 (17:36 +0800)
lib/accesslib.php

index fcd91b8..de180b4 100644 (file)
@@ -1961,6 +1961,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;
                 }
             }