Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are 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