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: 284 lines (11 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

custom_fields:: (9 methods):
  __construct()
  add_join()
  add_joins()
  get_joins()
  get_columns()
  get_column_type()
  get_filters()
  get_filter_class_type()
  customfield_value()


Class: custom_fields  - X-Ref

Helper class for course custom fields.

__construct(string $tablefieldalias, string $entityname, string $component, string $area, int $itemid = 0)   X-Ref
Class customfields constructor.

param: string $tablefieldalias table alias and the field name (table.field) that matches the customfield instanceid.
param: string $entityname name of the entity in the report where we add custom fields.
param: string $component component name of full frankenstyle plugin name.
param: string $area name of the area (each component/plugin may define handlers for multiple areas).
param: int $itemid item id if the area uses them (usually not used).

add_join(string $join)   X-Ref
Additional join that is needed.

return: self
param: string $join

add_joins(array $joins)   X-Ref
Additional joins that are needed.

return: self
param: array $joins

get_joins()   X-Ref
Return joins

return: string[]

get_columns()   X-Ref
Gets the custom fields columns for the report.

Column will be named as 'customfield_' + customfield shortname.

return: column[]

get_column_type(field_controller $field, string $datafield)   X-Ref
Returns the column type

return: int
param: field_controller $field
param: string $datafield

get_filters()   X-Ref
Returns all available filters on custom fields.

Filter will be named as 'customfield_' + customfield shortname.

return: filter[]

get_filter_class_type(data_controller $datacontroller)   X-Ref
Returns class for the filter element that should be used for the field

In some situation we can assume what kind of data is stored in the customfield plugin and we can
display appropriate filter form element. For all others assume text filter.

return: string
param: data_controller $datacontroller

customfield_value($value, stdClass $row, field_controller $field)   X-Ref
Format for custom fields value. We get the correct custom field value using export_value method.

return: mixed|null
param: mixed $value Current value.
param: stdClass $row Full row.
param: field_controller $field Field controller object.