Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.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