Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

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

(no description)

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

Defines 1 class


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

return: base[]
param: int $reportid

get_allowed_reports(?int $userid = null)   X-Ref
Returns list of reports that the specified user can access. Note this is potentially very expensive to calculate if a
site has lots of reports, with lots of audiences, so we cache the result for the duration of the users session

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

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

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

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

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

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

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

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