Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
core_reportbuilder\system_report Class Reference

Base class for system reports. More...

Inheritance diagram for core_reportbuilder\system_report:

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.
 
 add_attributes (array $attributes)
 Add report attributes (data-, class, etc.) that will be included in HTML when report is displayed.
 
 add_base_condition_simple (string $fieldname, $fieldvalue)
 Define simple "field = value" clause to apply to the report query.
 
 add_base_condition_sql (string $where, array $params=[])
 Define more complex/non-empty clause to apply to the report query.
 
 can_be_downloaded ()
 Validates access to download this report.
 
 get_actions ()
 Return report actions.
 
 get_active_columns ()
 Return all active report columns (by default, all available columns)
 
 get_active_columns_by_alias ()
 Return all active report columns, keyed by their alias (only active columns in a report would have a valid alias/index)
 
 get_active_conditions ()
 Return all active report conditions (by default, all available conditions)
 
 get_active_filters ()
 Return all active report filters (by default, all available filters)
 
 get_applied_filter_count ()
 Return the number of filter instances that are being applied based on the report's filter values (i.e.
 
 get_attributes ()
 Returns the report HTML attributes.
 
 get_base_condition ()
 Return base select/params for the report query.
 
 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_column (string $uniqueidentifier)
 Return report column by unique identifier.
 
 get_columns ()
 Return all available report columns.
 
 get_condition (string $uniqueidentifier)
 Return report condition by unique identifier.
 
 get_condition_instances ()
 Return all active report condition instances.
 
 get_condition_values ()
 Get the condition values of the report.
 
 get_conditions ()
 Return all available report conditions.
 
 get_context ()
 Returns the report context.
 
 get_default_no_results_notice ()
 Get the default lang string for the notice used when no results are found.
 
 get_default_per_page ()
 Default 'per page' size.
 
 get_downloadfilename ()
 Return the downloadable report filename.
 
 get_entity_title (string $name)
 Returns title of given report entity.
 
 get_exclude_columns_for_download ()
 Return list of column names that will be excluded when table is downloaded.
 
 get_filter (string $uniqueidentifier)
 Return report filter by unique identifier.
 
 get_filter_form_default ()
 Whether to use the default filters form.
 
 get_filter_instances ()
 Return all active report filter instances.
 
 get_filter_values ()
 Get the filter values of the report.
 
 get_filters ()
 Return all available report filters.
 
 get_initial_sort_column ()
 Get initial sort column.
 
 get_initial_sort_direction ()
 Get initial sort column direction.
 
 get_joins ()
 Return report JOIN clauses.
 
 get_main_table ()
 Get the main table name.
 
 get_main_table_alias ()
 Get the alias for the main table.
 
 get_parameter (string $param, $default, string $type)
 Return specific report parameter.
 
 get_parameters ()
 Return all report parameters.
 
 get_report_persistent ()
 Returns persistent class used when initialising this report.
 
 get_row_class (stdClass $row)
 CSS classes to add to the row.
 
 get_settings_values ()
 Get the settings values of the report.
 
 has_actions ()
 Whether report has any actions.
 
 is_downloadable ()
 Get if the report can be downloaded.
 
 output ()
 Output the report.
 
 require_can_view ()
 Validate access to the report.
 
 row_callback (stdClass $row)
 Called before rendering each row.
 
 set_condition_values (array $values)
 Set the condition values of the report.
 
 set_default_no_results_notice (?lang_string $notice)
 Set the default lang string for the notice used when no results are found.
 
 set_default_per_page (int $defaultperpage)
 Set the default 'per page' size.
 
 set_downloadable (bool $downloadable, ?string $downloadfilename=null)
 Set if the report can be downloaded.
 
 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_filter_values (array $values)
 Set the filter values of the report.
 
 set_initial_sort_column (string $uniqueidentifier, int $sortdirection)
 Set initial sort column and sort direction for the report.
 
 set_main_table (string $tablename, string $tablealias='')
 Set the main table and alias for the SQL query.
 
 set_parameters (array $parameters)
 Set all report parameters.
 
 set_settings_values (array $values)
 Set the settings values of the report.
 

Static Public Member Functions

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

Public Attributes

int const DEFAULT_PAGESIZE = 30
 Default paging limit.
 
int const TYPE_CUSTOM_REPORT = 0
 Custom report type value.
 
int const TYPE_SYSTEM_REPORT = 1
 System report type value.
 

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.
 
 add_column (column $column)
 Adds a column to the report.
 
 add_column_from_entity (string $uniqueidentifier)
 Add given column to the report from an entity.
 
 add_columns_from_entities (array $columns)
 Add given columns to the report from one or more entities.
 
 add_condition (filter $condition)
 Adds a condition to the report.
 
 add_condition_from_entity (string $uniqueidentifier)
 Add given condition to the report from an entity.
 
 add_conditions_from_entities (array $conditions)
 Add given conditions to the report from one or more entities.
 
 add_entity (entity_base $entity)
 Adds given entity, along with it's columns and filters, to the report.
 
 add_filter (filter $filter)
 Adds a filter to the report.
 
 add_filter_from_entity (string $uniqueidentifier)
 Add given filter to the report from an entity.
 
 add_filters_from_entities (array $filters)
 Add given filters to the report from one or more entities.
 
 add_join (string $join, array $params=[], bool $validateparams=true)
 Adds report JOIN clause that is always added.
 
 annotate_entity (string $name, lang_string $title)
 Define a new entity for the report.
 
 can_view ()
 Validates access to view this report.
 
 get_entities ()
 Returns the list of all the entities added to the report.
 
 get_entity (string $name)
 Returns the entity added to the report from the given entity name.
 
 initialise ()
 Initialise report.
 
 set_checkbox_toggleall (callable $callback)
 Define toggle all checkbox for the report, required row data should be defined by calling {.
 
 validate ()
 Report validation.
 

Detailed Description

Base class for system reports.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

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_attributes()

core_reportbuilder\local\report\base::add_attributes ( array $attributes)
inherited

Add report attributes (data-, class, etc.) that will be included in HTML when report is displayed.

Parameters
array$attributes
Return values
self

◆ add_base_condition_simple()

core_reportbuilder\local\report\base::add_base_condition_simple ( string $fieldname,
$fieldvalue )
finalinherited

Define simple "field = value" clause to apply to the report query.

Parameters
string$fieldname
mixed$fieldvalue

◆ add_base_condition_sql()

core_reportbuilder\local\report\base::add_base_condition_sql ( string $where,
array $params = [] )
finalinherited

Define more complex/non-empty clause to apply to the report query.

Parameters
string$where
array$paramsNote that the param names should be generated by {
See also
database\generate_param_name}

◆ 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.

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

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

◆ add_column()

core_reportbuilder\local\report\base::add_column ( column $column)
finalprotectedinherited

Adds a column to the report.

Parameters
column$column
Return values
column
Exceptions
coding_exception

◆ add_column_from_entity()

core_reportbuilder\local\report\base::add_column_from_entity ( string $uniqueidentifier)
finalprotectedinherited

Add given column to the report from an entity.

The entity must have already been added to the report before calling this method

Parameters
string$uniqueidentifier
Return values
column

◆ add_columns_from_entities()

core_reportbuilder\local\report\base::add_columns_from_entities ( array $columns)
finalprotectedinherited

Add given columns to the report from one or more entities.

Each entity must have already been added to the report before calling this method

Parameters
string[]$columnsUnique identifier of each entity column

◆ add_condition()

core_reportbuilder\local\report\base::add_condition ( filter $condition)
finalprotectedinherited

Adds a condition to the report.

Parameters
filter$condition
Return values
filter
Exceptions
coding_exception

◆ add_condition_from_entity()

core_reportbuilder\local\report\base::add_condition_from_entity ( string $uniqueidentifier)
finalprotectedinherited

Add given condition to the report from an entity.

The entity must have already been added to the report before calling this method

Parameters
string$uniqueidentifier
Return values
filter

◆ add_conditions_from_entities()

core_reportbuilder\local\report\base::add_conditions_from_entities ( array $conditions)
finalprotectedinherited

Add given conditions to the report from one or more entities.

Each entity must have already been added to the report before calling this method

Parameters
string[]$conditionsUnique identifier of each entity condition

◆ add_entity()

core_reportbuilder\local\report\base::add_entity ( entity_base $entity)
finalprotectedinherited

Adds given entity, along with it's columns and filters, to the report.

Parameters
entity_base$entity

◆ add_filter()

core_reportbuilder\local\report\base::add_filter ( filter $filter)
finalprotectedinherited

Adds a filter to the report.

Parameters
filter$filter
Return values
filter
Exceptions
coding_exception

◆ add_filter_from_entity()

core_reportbuilder\local\report\base::add_filter_from_entity ( string $uniqueidentifier)
finalprotectedinherited

Add given filter to the report from an entity.

The entity must have already been added to the report before calling this method

Parameters
string$uniqueidentifier
Return values
filter

◆ add_filters_from_entities()

core_reportbuilder\local\report\base::add_filters_from_entities ( array $filters)
finalprotectedinherited

Add given filters to the report from one or more entities.

Each entity must have already been added to the report before calling this method

Parameters
string[]$filtersUnique identifier of each entity filter

◆ add_join()

core_reportbuilder\local\report\base::add_join ( string $join,
array $params = [],
bool $validateparams = true )
protectedinherited

Adds report JOIN clause that is always added.

Parameters
string$join
array$params
bool$validateparamsSome queries might add non-standard params and validation could fail

◆ annotate_entity()

core_reportbuilder\local\report\base::annotate_entity ( string $name,
lang_string $title )
finalprotectedinherited

Define a new entity for the report.

Parameters
string$name
lang_string$title
Exceptions
coding_exception

◆ can_be_downloaded()

core_reportbuilder\system_report::can_be_downloaded ( )
final

Validates access to download this report.

Return values
bool

◆ can_view()

◆ get_actions()

core_reportbuilder\system_report::get_actions ( )
final

Return report actions.

Return values
action|action_menu_filler[]

◆ get_active_columns()

core_reportbuilder\local\report\base::get_active_columns ( )
inherited

Return all active report columns (by default, all available columns)

Return values
column[]

Reimplemented in core_reportbuilder\datasource.

◆ get_active_columns_by_alias()

core_reportbuilder\local\report\base::get_active_columns_by_alias ( )
finalinherited

Return all active report columns, keyed by their alias (only active columns in a report would have a valid alias/index)

Return values
column[]

◆ get_active_conditions()

core_reportbuilder\local\report\base::get_active_conditions ( )
inherited

Return all active report conditions (by default, all available conditions)

Return values
filter[]

Reimplemented in core_reportbuilder\datasource.

◆ get_active_filters()

core_reportbuilder\local\report\base::get_active_filters ( )
inherited

Return all active report filters (by default, all available filters)

Return values
filter[]

Reimplemented in core_reportbuilder\datasource.

◆ get_applied_filter_count()

core_reportbuilder\local\report\base::get_applied_filter_count ( )
finalinherited

Return the number of filter instances that are being applied based on the report's filter values (i.e.

user has configured them from their initial "Any value" state)

Return values
int

◆ get_attributes()

core_reportbuilder\local\report\base::get_attributes ( )
inherited

Returns the report HTML attributes.

Return values
array

◆ get_base_condition()

core_reportbuilder\local\report\base::get_base_condition ( )
finalinherited

Return base select/params for the report query.

Return values
array[string $select, array $params]

◆ 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_column()

core_reportbuilder\local\report\base::get_column ( string $uniqueidentifier)
finalinherited

Return report column by unique identifier.

Parameters
string$uniqueidentifier
Return values
column|null

◆ get_columns()

core_reportbuilder\local\report\base::get_columns ( )
finalinherited

Return all available report columns.

Return values
column[]

◆ get_condition()

core_reportbuilder\local\report\base::get_condition ( string $uniqueidentifier)
finalinherited

Return report condition by unique identifier.

Parameters
string$uniqueidentifier
Return values
filter|null

◆ get_condition_instances()

core_reportbuilder\local\report\base::get_condition_instances ( )
finalinherited

Return all active report condition instances.

Return values
filter_base[]

◆ get_condition_values()

core_reportbuilder\local\report\base::get_condition_values ( )
finalinherited

Get the condition values of the report.

Return values
array

◆ get_conditions()

core_reportbuilder\local\report\base::get_conditions ( )
finalinherited

Return all available report conditions.

Return values
filter[]

◆ get_context()

core_reportbuilder\local\report\base::get_context ( )
inherited

Returns the report context.

Return values
context

◆ get_default_no_results_notice()

core_reportbuilder\local\report\base::get_default_no_results_notice ( )
inherited

Get the default lang string for the notice used when no results are found.

Return values
lang_string|nullthe lang_string instance or null if the report prefers not to use one.

◆ get_default_per_page()

core_reportbuilder\local\report\base::get_default_per_page ( )
inherited

Default 'per page' size.

Return values
int

◆ get_downloadfilename()

core_reportbuilder\local\report\base::get_downloadfilename ( )
finalinherited

Return the downloadable report filename.

Return values
string

◆ get_entities()

core_reportbuilder\local\report\base::get_entities ( )
finalprotectedinherited

Returns the list of all the entities added to the report.

Return values
entity_base[]

◆ get_entity()

core_reportbuilder\local\report\base::get_entity ( string $name)
finalprotectedinherited

Returns the entity added to the report from the given entity name.

Parameters
string$name
Return values
entity_base
Exceptions
coding_exception

◆ get_entity_title()

core_reportbuilder\local\report\base::get_entity_title ( string $name)
finalinherited

Returns title of given report entity.

Parameters
string$name
Return values
lang_string
Exceptions
coding_exception

◆ 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_filter()

core_reportbuilder\local\report\base::get_filter ( string $uniqueidentifier)
finalinherited

Return report filter by unique identifier.

Parameters
string$uniqueidentifier
Return values
filter|null

◆ get_filter_form_default()

core_reportbuilder\system_report::get_filter_form_default ( )
final

Whether to use the default filters form.

Return values
bool

◆ get_filter_instances()

core_reportbuilder\local\report\base::get_filter_instances ( )
finalinherited

Return all active report filter instances.

Return values
filter_base[]

◆ get_filter_values()

core_reportbuilder\local\report\base::get_filter_values ( )
finalinherited

Get the filter values of the report.

Return values
array

◆ get_filters()

core_reportbuilder\local\report\base::get_filters ( )
finalinherited

Return all available report filters.

Return values
filter[]

◆ 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_joins()

core_reportbuilder\local\report\base::get_joins ( )
inherited

Return report JOIN clauses.

Return values
array

◆ get_main_table()

core_reportbuilder\local\report\base::get_main_table ( )
finalinherited

Get the main table name.

Return values
string

◆ get_main_table_alias()

core_reportbuilder\local\report\base::get_main_table_alias ( )
finalinherited

Get the alias for the main table.

Return values
string

◆ 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 from core_reportbuilder\local\report\base.

Reimplemented in core_admin\reportbuilder\local\systemreports\task_logs.

◆ get_parameter()

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

Return specific report parameter.

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_report_persistent()

core_reportbuilder\local\report\base::get_report_persistent ( )
finalinherited

Returns persistent class used when initialising this report.

Return values
report

◆ 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, and core_reportbuilder\local\systemreports\reports_list.

◆ get_settings_values()

core_reportbuilder\local\report\base::get_settings_values ( )
finalinherited

Get the settings values of the report.

Return values
array

◆ has_actions()

core_reportbuilder\system_report::has_actions ( )
final

Whether report has any actions.

Return values
bool

◆ initialise()

core_reportbuilder\local\report\base::initialise ( )
abstractprotectedinherited

Initialise report.

Specify which columns, filters, etc should be present

To set the base query use:

  • {
    See also
    set_main_table}
  • {
    See also
    add_base_condition_simple} or {
    add_base_condition_sql}
  • {
    See also
    add_join}
    To add content to the report use:
  • {
    See also
    add_entity}
  • {
    See also
    add_column}
  • {
    See also
    add_filter}
  • etc

Reimplemented in core_admin\reportbuilder\datasource\task_logs, core_admin\reportbuilder\local\systemreports\task_logs, core_badges\reportbuilder\datasource\badges, core_badges\reportbuilder\datasource\users, core_badges\reportbuilder\local\systemreports\badges, core_blog\reportbuilder\datasource\blogs, core_cohort\reportbuilder\datasource\cohorts, core_cohort\reportbuilder\local\systemreports\cohorts, core_comment\reportbuilder\datasource\comments, core_comment\reportbuilder\local\systemreports\comments, core_course\reportbuilder\datasource\categories, core_course\reportbuilder\datasource\courses, core_course\reportbuilder\datasource\participants, core_files\reportbuilder\datasource\files, core_group\reportbuilder\datasource\groups, core_notes\reportbuilder\datasource\notes, core_reportbuilder\local\systemreports\report_access_list, core_reportbuilder\local\systemreports\report_schedules, core_reportbuilder\local\systemreports\reports_list, core_tag\reportbuilder\datasource\tags, core_user\reportbuilder\datasource\users, gradereport_summary\local\systemreports\summary, mod_lti\reportbuilder\local\systemreports\course_external_tools_list, and report_configlog\reportbuilder\local\systemreports\config_changes.

◆ is_available()

static core_reportbuilder\local\report\base::is_available ( )
staticinherited

Get the report availability.

Sub-classes should override this method to declare themselves unavailable, for example if they require classes that aren't present due to missing plugin

Return values
bool

◆ is_downloadable()

core_reportbuilder\local\report\base::is_downloadable ( )
finalinherited

Get if the report can be downloaded.

Return values
bool

◆ output()

core_reportbuilder\system_report::output ( )
final

Output the report.

@uses core_reportbuilder\output\renderer\render_system_report()

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

◆ 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

◆ set_condition_values()

core_reportbuilder\local\report\base::set_condition_values ( array $values)
finalinherited

Set the condition values of the report.

Parameters
array$values
Return values
bool

◆ set_default_no_results_notice()

core_reportbuilder\local\report\base::set_default_no_results_notice ( ?lang_string $notice)
inherited

Set the default lang string for the notice used when no results are found.

Parameters
lang_string | null$noticestring, or null to tell the report to omit the notice entirely.
Return values
void

◆ set_default_per_page()

core_reportbuilder\local\report\base::set_default_per_page ( int $defaultperpage)
inherited

Set the default 'per page' size.

Parameters
int$defaultperpage

◆ set_downloadable()

core_reportbuilder\local\report\base::set_downloadable ( bool $downloadable,
?string $downloadfilename = null )
finalinherited

Set if the report can be downloaded.

Parameters
bool$downloadable
string | null$downloadfilenameIf downloadable, then the name of the file (defaults to the name of the current report)

◆ 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_filter_values()

core_reportbuilder\local\report\base::set_filter_values ( array $values)
finalinherited

Set the filter values of the report.

Parameters
array$values
Return values
bool

◆ 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_main_table()

core_reportbuilder\local\report\base::set_main_table ( string $tablename,
string $tablealias = '' )
finalinherited

Set the main table and alias for the SQL query.

Parameters
string$tablename
string$tablealias

◆ set_parameters()

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

Set all report parameters.

Parameters
array$parameters

◆ set_settings_values()

core_reportbuilder\local\report\base::set_settings_values ( array $values)
finalinherited

Set the settings values of the report.

Parameters
array$values
Return values
bool

◆ 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

Reimplemented from core_reportbuilder\local\report\base.


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