Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 400 and 401] [Versions 401 and 402] [Versions 401 and 403]

(no description)

File Size: 306 lines (11 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes


Class: audience  - X-Ref

Class containing report audience helper methods

get_base_records(int $reportid)   X-Ref
Return audience instances for a given report. Note that any records pointing to invalid audience types will be excluded

param: int $reportid
return: base[]

get_allowed_reports(?int $userid = null)   X-Ref
Returns list of report IDs that the specified user can access, based on audience configuration. This can be expensive if the
site has lots of reports, with lots of audiences, so we cache the result for the duration of the users session

param: int|null $userid User ID to check, or the current user if omitted
return: int[]

purge_caches()   X-Ref
Purge the audience cache of allowed reports


user_reports_list_sql(string $reporttablealias, ?int $userid = null)   X-Ref
Generate SQL select clause and params for selecting reports specified user can access, based on audience configuration

param: string $reporttablealias
param: int|null $userid User ID to check, or the current user if omitted
return: array

user_reports_list(?int $userid = null)   X-Ref
Return list of report ID's specified user can access, based on audience configuration

param: int|null $userid User ID to check, or the current user if omitted
return: int[]

user_reports_list_access_sql(string $reporttablealias,?int $userid = null,?context $context = null)   X-Ref
Returns SQL to limit the list of reports to those that the given user has access to

- A user with 'editall' capability will have access to all reports
- A user with 'edit' capability will have access to:
- Those reports this user has created
- Those reports this user is in audience of
- A user with 'view' capability will have access to:
- Those reports this user is in audience of

param: string $reporttablealias
param: int|null $userid User ID to check, or the current user if omitted
param: context|null $context
return: array

user_audience_sql(array $audiences, string $usertablealias = 'u')   X-Ref
Return appropriate list of where clauses and params for given audiences

param: audience_model[] $audiences
param: string $usertablealias
return: array[] [$wheres, $params]

get_audience_types()   X-Ref
Returns the list of audiences types in the system.

return: array

get_all_audiences_menu_types()   X-Ref
Get all the audiences types the current user can add to, organised by categories.

return: array

Class: for  - X-Ref