Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
core_availability\capability_checker Class Reference

Used while evaluating conditions in bulk. More...

Public Member Functions

 __construct (\context $context)
 Constructs for given context.
 
 get_users_by_capability ($capability)
 Gets users on course who have the specified capability.
 

Protected Attributes

array $cache = array()
 Associative array of capability => result.
 
context $context
 Course or module context.
 

Detailed Description

Used while evaluating conditions in bulk.

This object caches get_users_by_capability results in case they are needed by multiple conditions.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

core_availability\capability_checker::__construct ( \context $context)

Constructs for given context.

Parameters
context$contextContext

Member Function Documentation

◆ get_users_by_capability()

core_availability\capability_checker::get_users_by_capability ( $capability)

Gets users on course who have the specified capability.

Returns an array of user objects which only contain the 'id' field. If the same capability has already been checked (e.g. by another condition) then a cached result will be used.

More fields are not necessary because this code is only used to filter users from an existing list.

Parameters
string$capabilityRequired capability
Return values
arrayAssociative array of user id => objects containing only id

The documentation for this class was generated from the following file: