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

Defines 1 class

custom_fields:: (10 methods):
  __construct()
  add_join()
  add_joins()
  get_joins()
  get_table_alias()
  get_table_join()
  get_columns()
  get_column_type()
  get_filters()
  get_filter_class_type()


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.

param: string $join
return: self

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

param: array $joins
return: self

get_joins()   X-Ref
Return joins

return: string[]

get_table_alias(field_controller $field)   X-Ref
Get table alias for given custom field

The entity name is used to ensure the alias differs when the entity is used multiple times within the same report, each
having their own table alias/join

param: field_controller $field
return: string

get_table_join(field_controller $field)   X-Ref
Get table join for given custom field

param: field_controller $field
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

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

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.

param: data_controller $datacontroller
return: string