Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

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

(no description)

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

Defines 1 class


Class: system_report  - X-Ref

Base class for system reports

__construct(report $report, array $parameters)   X-Ref
System report constructor.

param: report $report
param: array $parameters

require_can_view()   X-Ref
Validate access to the report


validate()   X-Ref
Report validation


add_base_fields(string $sql)   X-Ref
Add list of fields that have to be always included in SQL query for actions and row classes

Base fields are only available in system reports because they are not compatible with aggregation

param: string $sql SQL clause for the list of fields that only uses main table or base joins

get_base_fields()   X-Ref
Return report base fields

return: array

set_checkbox_toggleall(callable $callback)   X-Ref
Define toggle all checkbox for the report, required row data should be defined by calling {@see add_base_fields}

param: callable $callback Callback to return value/label for each checkbox, implementing the following signature:

get_checkbox_toggleall(bool $ismaster, ?stdClass $row = null)   X-Ref
Return instance of toggle all checkbox, if previously defined by {@see set_checkbox_toggleall}

param: bool $ismaster
param: stdClass|null $row
return: checkbox_toggleall|null

set_filter_form_default(bool $filterformdefault = true)   X-Ref
Override whether to use the default system report filters form, for instance this can be disabled if the UI requires
it's own custom filter management form for a specific report

param: bool $filterformdefault

get_filter_form_default()   X-Ref
Whether to use the default filters form

return: bool

add_action(action $action)   X-Ref
Adds an action to the report

param: action $action

add_action_divider()   X-Ref
Adds action divider to the report


has_actions()   X-Ref
Whether report has any actions

return: bool

get_actions()   X-Ref
Return report actions

return: action|action_menu_filler[]

set_parameters(array $parameters)   X-Ref
Set all report parameters

param: array $parameters

get_parameters()   X-Ref
Return all report parameters

return: array

get_parameter(string $param, $default, string $type)   X-Ref
Return specific report parameter

param: string $param
param: mixed $default
param: string $type
return: mixed

output()   X-Ref
Output the report

return: string

get_row_class(stdClass $row)   X-Ref
CSS classes to add to the row. Can be overridden by system reports do define class to be added to output according to
content of each row

param: stdClass $row
return: string

row_callback(stdClass $row)   X-Ref
Called before rendering each row. Can be overridden to pre-fetch/create objects and store them in the class, which can
later be used in column and action callbacks

param: stdClass $row

can_be_downloaded()   X-Ref
Validates access to download this report.

return: bool

get_exclude_columns_for_download()   X-Ref
Return list of column names that will be excluded when table is downloaded. Extending classes should override this method
as appropriate

return: string[] Array of column unique identifiers

set_initial_sort_column(string $uniqueidentifier, int $sortdirection)   X-Ref
Set initial sort column and sort direction for the report

param: string $uniqueidentifier
param: int $sortdirection One of SORT_ASC or SORT_DESC

get_initial_sort_column()   X-Ref
Get initial sort column

return: column|null

get_initial_sort_direction()   X-Ref
Get initial sort column direction

return: int