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 402] [Versions 400 and 403]

(no description)

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

Defines 1 class


Class: base  - X-Ref

Audience base class

__construct()   X-Ref
Protected constructor, please use the static instance method.


instance(int $id = 0, ?stdClass $record = null)   X-Ref
Loads an existing instance of audience with persistent

return: self|null
param: int $id
param: null|stdClass $record

create(int $reportid, array $configdata)   X-Ref
Creates a new audience and saves it to database

return: self
param: int $reportid
param: array $configdata

get_category()   X-Ref
Returns string for audience category.

return: string

is_available()   X-Ref
If the current user is able to use this audience type

This method needs to return true if audience type is available to user for
reasons other than permission check, which is done in {@see user_can_add}.
(e.g. user can add cohort audience type only if there is at least one cohort
they can access).

return: bool

format_description_for_multiselect(array $elements)   X-Ref
Helper to format descriptions for audience types that may contain many selected elements, limiting number show according
to {@see MULTI_SELECT_LIMIT} constant value

return: string
param: array $elements

validate_config_form(array $data)   X-Ref
Validates the configform of the condition.

return: array Array with errors for each element
param: array $data Data from the form

get_configdata()   X-Ref
Returns configdata as an associative array

return: array decoded configdata

update_configdata(array $configdata)   X-Ref
Update configdata in audience persistent

param: array $configdata

retrieve_configdata(stdClass $data)   X-Ref
Returns $configdata from form data suitable for use in DB record.

return: array $configdata
param: stdClass $data data obtained from $mform->get_data()

get_persistent()   X-Ref
Return audience persistent.

return: audience

require_user_can_add()   X-Ref
Require current user is able to add this audience type


require_user_can_edit()   X-Ref
Require current user is able to edit this audience type