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.

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

(no description)

File Size: 317 lines (12 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_audiences_for_report_schedules(int $reportid)   X-Ref
Return a list of audiences that are used by any schedule of the given report

param: int $reportid
return: int[] Array of audience IDs

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