Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Used while evaluating conditions in bulk. This object caches get_users_by_capability results in case they are needed by multiple conditions.

Copyright: 2014 The Open University
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 77 lines (3 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

capability_checker:: (2 methods):
  __construct()
  get_users_by_capability()


Class: capability_checker  - X-Ref

Used while evaluating conditions in bulk.

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

__construct(\context $context)   X-Ref
Constructs for given context.

param: \context $context Context

get_users_by_capability($capability)   X-Ref
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.

param: string $capability Required capability
return: array Associative array of user id => objects containing only id