Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250711) (9addea9f0ac)
core_reportbuilder\system_report Class Reference
Inheritance diagram for core_reportbuilder\system_report:
core\dataformat\base core_admin\reportbuilder\local\systemreports\task_logs core_admin\reportbuilder\local\systemreports\users core_ai\reportbuilder\local\systemreports\policy_acceptance core_ai\reportbuilder\local\systemreports\usage core_badges\reportbuilder\local\systemreports\badges core_badges\reportbuilder\local\systemreports\course_badges core_badges\reportbuilder\local\systemreports\recipients core_cohort\reportbuilder\local\systemreports\cohorts core_comment\reportbuilder\local\systemreports\comments core_reportbuilder\local\systemreports\report_access_list core_reportbuilder\local\systemreports\report_schedules core_reportbuilder\local\systemreports\reports_list core_tag\reportbuilder\local\systemreports\tags core_webservice\reportbuilder\local\systemreports\tokens gradereport_summary\local\systemreports\summary mod_lti\reportbuilder\local\systemreports\course_external_tools_list report_configlog\reportbuilder\local\systemreports\config_changes report_themeusage\reportbuilder\local\systemreports\theme_usage_report tool_admin_presets\reportbuilder\local\systemreports\admin_presets

Public Member Functions

 __construct (report $report, array $parameters)
 System report constructor.
 
 add_action (action $action)
 Adds an action to the report.
 
 add_action_divider ()
 Adds action divider to the report.
 
 can_be_downloaded ()
 Validates access to download this report.
 
 close_output ()
 Write the end of the file.
 
 close_output_to_file ()
 Write the data to disk.
 
 close_sheet ($columns)
 Write the end of the sheet containing the data.
 
 get_actions ()
 Return report actions.
 
 get_base_fields ()
 Return report base fields.
 
 get_checkbox_toggleall (bool $ismaster, ?stdClass $row=null)
 Return instance of toggle all checkbox, if previously defined by {.
 
 get_exclude_columns_for_download ()
 Return list of column names that will be excluded when table is downloaded.
 
 get_extension ()
 Get the file extension.
 
 get_filter_form_default ()
 Whether to use the default filters form.
 
 get_initial_sort_column ()
 Get initial sort column.
 
 get_initial_sort_direction ()
 Get initial sort column direction.
 
 get_parameter (string $param, $default, string $type)
 Return specific report parameter.
 
 get_parameters ()
 Return all report parameters.
 
 get_row_class (stdClass $row)
 CSS classes to add to the row.
 
 has_actions ()
 Whether report has any actions.
 
 output ()
 Output the report.
 
 require_can_view ()
 Validate access to the report.
 
 row_callback (stdClass $row)
 Called before rendering each row.
 
 send_http_headers ()
 Output file headers to initialise the download of the file.
 
 set_filename ($filename)
 Set download filename base.
 
 set_filepath (string $filepath)
 Set file path when writing to file.
 
 set_filter_form_default (bool $filterformdefault=true)
 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.
 
 set_initial_sort_column (string $uniqueidentifier, int $sortdirection)
 Set initial sort column and sort direction for the report.
 
 set_parameters (array $parameters)
 Set all report parameters.
 
 set_sheettitle ($title)
 Set the title of the worksheet inside a spreadsheet.
 
 start_output ()
 Write the start of the file.
 
 start_output_to_file ()
 Set the dataformat to be output to current file.
 
 start_sheet ($columns)
 Write the start of the sheet we will be adding data to.
 
 supports_html ()
 Method to define whether the dataformat supports export of HTML.
 
 write_record ($record, $rownum)
 Write a single record.
 

Static Public Member Functions

static get_name ()
 Provide default implementation of the report name.
 

Protected Member Functions

 add_base_fields (string $sql)
 Add list of fields that have to be always included in SQL query for actions and row classes.
 
 can_view ()
 Validates access to view this report.
 
 export_html_image_source (\stored_file $file)
 Given a stored_file, return a suitable source attribute for an img element in the export (or null to use the original)
 
 format_record ($record)
 Apply formatting to the cells of a given record.
 
 replace_pluginfile_images (?string $content)
 We need to locate all img tags within a given cell that match pluginfile URL's.
 
 set_checkbox_toggleall (callable $callback)
 Define toggle all checkbox for the report, required row data should be defined by calling {.
 
 validate ()
 Report validation.
 

Protected Attributes

$extension $extension = ".txt"
 
$filename $filename = ''
 
string $filepath = ''
 The location to store the output content.
 
$mimetype $mimetype = "text/plain"
 

Constructor & Destructor Documentation

◆ __construct()

core_reportbuilder\system_report::__construct ( report $report,
array $parameters )
final

System report constructor.

Parameters
report$report
array$parameters

Member Function Documentation

◆ add_action()

core_reportbuilder\system_report::add_action ( action $action)
final

Adds an action to the report.

Parameters
action$action

◆ add_base_fields()

core_reportbuilder\system_report::add_base_fields ( string $sql)
finalprotected

Add list of fields that have to be always included in SQL query for actions and row classes.

Parameters
string$sqlSQL clause for the list of fields that only uses main table or base joins

◆ can_be_downloaded()

core_reportbuilder\system_report::can_be_downloaded ( )
final

Validates access to download this report.

Return values
bool

◆ can_view()

core_reportbuilder\system_report::can_view ( )
abstractprotected

◆ close_output()

core\dataformat\base::close_output ( )
inherited

◆ close_output_to_file()

core\dataformat\base::close_output_to_file ( )
inherited

Write the data to disk.

Calling code should have previously called {

See also
base::start_output_to_file()}
Return values
boolWhether the write succeeded

Reimplemented in core\dataformat\spout_base, and dataformat_pdf\writer.

◆ close_sheet()

core\dataformat\base::close_sheet ( $columns)
inherited

Write the end of the sheet containing the data.

Parameters
array$columns

Reimplemented in dataformat_html\writer, and dataformat_json\writer.

◆ export_html_image_source()

core\dataformat\base::export_html_image_source ( \stored_file $file)
protectedinherited

Given a stored_file, return a suitable source attribute for an img element in the export (or null to use the original)

Parameters
stored_file$file
Return values
string|null

Reimplemented in dataformat_pdf\writer.

◆ format_record()

core\dataformat\base::format_record ( $record)
protectedinherited

Apply formatting to the cells of a given record.

Parameters
array | stdClass$record
Return values
array

◆ get_actions()

core_reportbuilder\system_report::get_actions ( )
final

Return report actions.

Return values
action|action_menu_filler[]

◆ get_base_fields()

core_reportbuilder\system_report::get_base_fields ( )
final

Return report base fields.

Return values
array

◆ get_checkbox_toggleall()

core_reportbuilder\system_report::get_checkbox_toggleall ( bool $ismaster,
?stdClass $row = null )
final

Return instance of toggle all checkbox, if previously defined by {.

See also
set_checkbox_toggleall}
Parameters
bool$ismaster
stdClass | null$row
Return values
checkbox_toggleall|null

◆ get_exclude_columns_for_download()

core_reportbuilder\system_report::get_exclude_columns_for_download ( )

Return list of column names that will be excluded when table is downloaded.

Extending classes should override this method as appropriate

Return values
string[]Array of column unique identifiers

◆ get_extension()

core\dataformat\base::get_extension ( )
inherited

Get the file extension.

Return values
stringfile extension

◆ get_filter_form_default()

core_reportbuilder\system_report::get_filter_form_default ( )
final

Whether to use the default filters form.

Return values
bool

◆ get_initial_sort_column()

core_reportbuilder\system_report::get_initial_sort_column ( )

Get initial sort column.

Return values
column|null

◆ get_initial_sort_direction()

core_reportbuilder\system_report::get_initial_sort_direction ( )

Get initial sort column direction.

Return values
int

◆ get_name()

static core_reportbuilder\system_report::get_name ( )
static

Provide default implementation of the report name.

Extending classes can implement this method to provide their own name

Return values
string

Reimplemented in core_admin\reportbuilder\local\systemreports\task_logs, core_ai\reportbuilder\local\systemreports\policy_acceptance, and core_ai\reportbuilder\local\systemreports\usage.

◆ get_parameter()

core_reportbuilder\system_report::get_parameter ( string $param,
$default,
string $type )
final

Return specific report parameter.

Capability/permission checks relating to parameters retrieved here should also be considered in your {

See also
can_view} method
Parameters
string$param
mixed$default
string$type
Return values
mixed

◆ get_parameters()

core_reportbuilder\system_report::get_parameters ( )
final

Return all report parameters.

Return values
array

◆ get_row_class()

core_reportbuilder\system_report::get_row_class ( stdClass $row)

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

Parameters
stdClass$row
Return values
string

Reimplemented in core_badges\reportbuilder\local\systemreports\badges, core_cohort\reportbuilder\local\systemreports\cohorts, core_reportbuilder\local\systemreports\report_schedules, core_reportbuilder\local\systemreports\reports_list, and core_tag\reportbuilder\local\systemreports\tags.

◆ has_actions()

core_reportbuilder\system_report::has_actions ( )
final

Whether report has any actions.

Return values
bool

◆ output()

core_reportbuilder\system_report::output ( )
final

Output the report.

@uses core_reportbuilder\output\renderer\render_system_report()

Return values
string

◆ replace_pluginfile_images()

core\dataformat\base::replace_pluginfile_images ( ?string $content)
protectedinherited

We need to locate all img tags within a given cell that match pluginfile URL's.

Partly so the exported file will show the image without requiring the user is logged in; and also to prevent some of the dataformats requesting the file themselves, which is likely to fail due to them not having an active session

Parameters
string | null$content
Return values
string

◆ require_can_view()

core_reportbuilder\system_report::require_can_view ( )
final

Validate access to the report.

Exceptions
report_access_exception

◆ row_callback()

core_reportbuilder\system_report::row_callback ( stdClass $row)

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

Parameters
stdClass$row

Reimplemented in core_badges\reportbuilder\local\systemreports\badges.

◆ send_http_headers()

core\dataformat\base::send_http_headers ( )
inherited

Output file headers to initialise the download of the file.

Reimplemented in core\dataformat\spout_base, and dataformat_pdf\writer.

◆ set_checkbox_toggleall()

core_reportbuilder\system_report::set_checkbox_toggleall ( callable $callback)
finalprotected

Define toggle all checkbox for the report, required row data should be defined by calling {.

See also
add_base_fields}
Parameters
callable$callbackCallback to return value/label for each checkbox, implementing the following signature: function(stdClass $row): ?array containing value/label pair, or null if the checkbox should not be shown for the row

◆ set_filename()

core\dataformat\base::set_filename ( $filename)
inherited

Set download filename base.

Parameters
string$filename

◆ set_filepath()

core\dataformat\base::set_filepath ( string $filepath)
inherited

Set file path when writing to file.

Parameters
string$filepath
Exceptions
coding_exception

◆ set_filter_form_default()

core_reportbuilder\system_report::set_filter_form_default ( bool $filterformdefault = true)
final

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.

Parameters
bool$filterformdefault

◆ set_initial_sort_column()

core_reportbuilder\system_report::set_initial_sort_column ( string $uniqueidentifier,
int $sortdirection )

Set initial sort column and sort direction for the report.

Parameters
string$uniqueidentifier
int$sortdirectionOne of SORT_ASC or SORT_DESC
Exceptions
coding_exception

◆ set_parameters()

core_reportbuilder\system_report::set_parameters ( array $parameters)
final

Set all report parameters.

Parameters
array$parameters

◆ set_sheettitle()

core\dataformat\base::set_sheettitle ( $title)
inherited

Set the title of the worksheet inside a spreadsheet.

For some formats this will be ignored.

Parameters
string$title

Reimplemented in core\dataformat\spout_base, dataformat_excel\writer, and dataformat_ods\writer.

◆ start_output()

core\dataformat\base::start_output ( )
inherited

Write the start of the file.

Reimplemented in dataformat_html\writer, dataformat_json\writer, and dataformat_pdf\writer.

◆ start_output_to_file()

core\dataformat\base::start_output_to_file ( )
inherited

Set the dataformat to be output to current file.

Calling code must call {

See also
base::close_output_to_file()} when finished

Reimplemented in core\dataformat\spout_base, and dataformat_pdf\writer.

◆ start_sheet()

core\dataformat\base::start_sheet ( $columns)
inherited

Write the start of the sheet we will be adding data to.

Parameters
array$columns

Reimplemented in core\dataformat\spout_base, dataformat_html\writer, dataformat_json\writer, and dataformat_pdf\writer.

◆ supports_html()

core\dataformat\base::supports_html ( )
inherited

Method to define whether the dataformat supports export of HTML.

Return values
bool

Reimplemented in dataformat_html\writer, and dataformat_pdf\writer.

◆ validate()

core_reportbuilder\system_report::validate ( )
protected

Report validation.

Exceptions
report_access_exceptionIf user cannot access the report
coding_exceptionIf no default column are specified

◆ write_record()

core\dataformat\base::write_record ( $record,
$rownum )
abstractinherited

Write a single record.

Parameters
array$record
int$rownum

Reimplemented in core\dataformat\spout_base, dataformat_html\writer, dataformat_json\writer, and dataformat_pdf\writer.


The documentation for this class was generated from the following file: