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

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

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

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

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

param: array $elements
return: string

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

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

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.

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

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