Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250706) (a6b17d8f6bd)
core_reportbuilder\datasource Class Reference
Inheritance diagram for core_reportbuilder\datasource:
core\dataformat\base core_admin\reportbuilder\datasource\task_logs core_badges\reportbuilder\datasource\badges core_badges\reportbuilder\datasource\users core_blog\reportbuilder\datasource\blogs core_cohort\reportbuilder\datasource\cohorts core_comment\reportbuilder\datasource\comments core_competency\reportbuilder\datasource\competencies 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_role\reportbuilder\datasource\roles core_tag\reportbuilder\datasource\tags core_user\reportbuilder\datasource\users

Public Member Functions

 add_default_columns ()
 Add default datasource columns to the report.
 
 add_default_conditions ()
 Add default datasource conditions to the report.
 
 add_default_filters ()
 Add default datasource filters to the 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_active_columns ()
 Override parent method, returning only those columns specifically added to the custom report (rather than all that are available)
 
 get_active_conditions (bool $checkavailable=true)
 Override parent method, returning only those conditions specifically added to the custom report (rather than all that are available)
 
 get_active_filters ()
 Override parent method, returning only those filters specifically added to the custom report (rather than all that are available)
 
 get_default_column_sorting ()
 Return the default column sorting that will be set for the report upon creation, by {.
 
 get_default_columns ()
 Return the default columns that will be added to the report upon creation, by {.
 
 get_default_condition_values ()
 Return the default condition values that will be added to the report once is created.
 
 get_default_conditions ()
 Return the conditions that will be added to the report once is created.
 
 get_default_filters ()
 Return the filters that will be added to the report once is created.
 
 get_extension ()
 Get the file extension.
 
 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_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 report_elements_modified (int $reportid)
 Indicate that report elements have been modified, e.g.
 

Protected Member Functions

 add_all_from_entities (array $entitynames=[])
 Adds all columns/filters/conditions from all the entities added to the report at once.
 
 add_all_from_entity (string $entityname, array $limitcolumns=[], array $limitfilters=[], array $limitconditions=[],)
 Adds all columns/filters/conditions from the given entity to the report at once.
 
 add_conditions_from_entity (string $entityname, array $include=[], array $exclude=[])
 Add conditions from the given entity name to be available to use in a custom 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.
 

Protected Attributes

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

Member Function Documentation

◆ add_all_from_entities()

core_reportbuilder\datasource::add_all_from_entities ( array $entitynames = [])
finalprotected

Adds all columns/filters/conditions from all the entities added to the report at once.

Parameters
string[]$entitynamesIf specified, then only these entity elements are added (otherwise all)

◆ add_all_from_entity()

core_reportbuilder\datasource::add_all_from_entity ( string $entityname,
array $limitcolumns = [],
array $limitfilters = [],
array $limitconditions = [] )
finalprotected

Adds all columns/filters/conditions from the given entity to the report at once.

Parameters
string$entityname
string[]$limitcolumnsInclude only these columns
string[]$limitfiltersInclude only these filters
string[]$limitconditionsInclude only these conditions

◆ add_conditions_from_entity()

core_reportbuilder\datasource::add_conditions_from_entity ( string $entityname,
array $include = [],
array $exclude = [] )
finalprotected

Add conditions from the given entity name to be available to use in a custom report.

Wildcard matching is supported with '' in both $include and $exclude, e.g. ['customfield']

Parameters
string$entityname
string[]$includeInclude only these conditions, if omitted then include all
string[]$excludeExclude these conditions, if omitted then exclude none
Exceptions
coding_exceptionIf both $include and $exclude are non-empty

◆ add_default_columns()

core_reportbuilder\datasource::add_default_columns ( )

Add default datasource columns to the report.

Uses column data returned by the source {

See also
get_default_columns} and {
get_default_column_sorting} methods
Exceptions
coding_exceptionIf default column sorting refers to an invalid column

◆ add_default_conditions()

core_reportbuilder\datasource::add_default_conditions ( )

Add default datasource conditions to the report.

This method is optional and can be called when the report is created to add the default conditions defined in the selected datasource.

◆ add_default_filters()

core_reportbuilder\datasource::add_default_filters ( )

Add default datasource filters to the report.

This method is optional and can be called when the report is created to add the default filters defined in the selected datasource.

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

core_reportbuilder\datasource::get_active_columns ( )

Override parent method, returning only those columns specifically added to the custom report (rather than all that are available)

Return values
column[]

◆ get_active_conditions()

core_reportbuilder\datasource::get_active_conditions ( bool $checkavailable = true)

Override parent method, returning only those conditions specifically added to the custom report (rather than all that are available)

Parameters
bool$checkavailable
Return values
filter[]

◆ get_active_filters()

core_reportbuilder\datasource::get_active_filters ( )

Override parent method, returning only those filters specifically added to the custom report (rather than all that are available)

Return values
filter[]

◆ get_default_column_sorting()

◆ get_default_columns()

◆ get_default_condition_values()

core_reportbuilder\datasource::get_default_condition_values ( )

Return the default condition values that will be added to the report once is created.

For any of the default conditions returned by the method {

See also
get_default_conditions} is possible to set the initial values.
Return values
array

Reimplemented in core_admin\reportbuilder\datasource\task_logs, core_cohort\reportbuilder\datasource\cohorts, core_competency\reportbuilder\datasource\competencies, core_course\reportbuilder\datasource\participants, core_files\reportbuilder\datasource\files, and core_user\reportbuilder\datasource\users.

◆ get_default_conditions()

◆ get_default_filters()

◆ get_extension()

core\dataformat\base::get_extension ( )
inherited

Get the file extension.

Return values
stringfile extension

◆ 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

◆ report_elements_modified()

static core_reportbuilder\datasource::report_elements_modified ( int $reportid)
staticfinal

Indicate that report elements have been modified, e.g.

columns/filters/conditions have been added, removed or updated

Parameters
int$reportid

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

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