Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250711) (9addea9f0ac)
core_reportbuilder\table\custom_report_table Class Reference
Inheritance diagram for core_reportbuilder\table\custom_report_table:
core_reportbuilder\table\base_report_table core_table\dynamic core_reportbuilder\table\custom_report_table_view

Public Member Functions

 __construct (string $uniqueid, string $download='')
 Table constructor.
 
 download_buttons ()
 Download is disabled when editing the report.
 
 format_row ($row)
 Format each row of returned data, executing defined callbacks for the row and each column.
 
 get_context ()
 Get the context for the table (that of the report persistent)
 
 get_row_cells_html (string $rowid, array $row, ?array $suppresslastrow)
 Override get_row_cells_html to add an extra cell with the toggle button for card view.
 
 get_sort_columns ()
 Get user preferred sort columns, overriding those of parent.
 
 get_sql_sort ()
 Override parent method of the same, to ensure that any columns with custom sort fields are accounted for.
 
 get_total_row_count ()
 Return total row count for report table.
 
 guess_base_url ()
 Set the base URL of the table to the current page URL.
 
 has_capability ()
 Check if the user has the capability to access this table.
 
 out ($pagesize, $useinitialsbar, $downloadhelpbutton='')
 Overriding this method to handle live editing setting.
 
 print_headers ()
 Override parent method for printing headers so we can render our custom controls in each cell.
 
 print_nothing_to_display ()
 Override print_nothing_to_display to ensure that column headers are always added.
 
 query_db ($pagesize, $useinitialsbar=true)
 Override parent method of the same, to make use of a recordset and avoid issues with duplicate values in the first column.
 
 set_report_editing (bool $editing)
 Whether the current report table is being edited, in which case certain actions are not applied to it, e.g.
 
 start_html ()
 Override start of HTML to remove top pagination.
 
 wrap_html_finish ()
 Provide additional table debugging during editing.
 

Static Public Member Functions

static create (int $reportid, string $download='')
 Return a new instance of the class for given report ID.
 

Protected Member Functions

 get_active_columns ()
 Get the columns of the custom report, returned instances being valid and available for the user.
 
 get_table_sql (bool $includesort=true)
 Generate suitable SQL for the table.
 
 init_sql (string $fields, string $from, array $joins, string $where, array $params, array $groupby=[])
 Initialises table SQL properties.
 

Protected Attributes

bool $editing = false
 $editing
 
string $groupbysql = ''
 $groupbysql
 
report $persistent
 $persistent
 
datasource $report
 $report
 
bool const REPORT_EDITING = true
 Whether report is being edited (we don't want user filters/sorting to be applied when editing)
 

Constructor & Destructor Documentation

◆ __construct()

core_reportbuilder\table\custom_report_table::__construct ( string $uniqueid,
string $download = '' )

Table constructor.

Note that the passed unique ID value must match the pattern "custom-report-table-(::d+)" so that dynamic updates continue to load the same report

Parameters
string$uniqueid
string$download
Exceptions
moodle_exceptionFor invalid unique ID

Member Function Documentation

◆ create()

static core_reportbuilder\table\custom_report_table::create ( int $reportid,
string $download = '' )
static

Return a new instance of the class for given report ID.

Parameters
int$reportid
string$download
Return values
static

◆ download_buttons()

core_reportbuilder\table\custom_report_table::download_buttons ( )

Download is disabled when editing the report.

Return values
string

Reimplemented in core_reportbuilder\table\custom_report_table_view.

◆ format_row()

core_reportbuilder\table\custom_report_table::format_row ( $row)

Format each row of returned data, executing defined callbacks for the row and each column.

Parameters
array | stdClass$row
Return values
array

◆ get_active_columns()

core_reportbuilder\table\custom_report_table::get_active_columns ( )
protected

Get the columns of the custom report, returned instances being valid and available for the user.

Return values
column[]

◆ get_context()

core_reportbuilder\table\base_report_table::get_context ( )
inherited

Get the context for the table (that of the report persistent)

Return values
context

◆ get_row_cells_html()

core_reportbuilder\table\custom_report_table::get_row_cells_html ( string $rowid,
array $row,
?array $suppresslastrow )

Override get_row_cells_html to add an extra cell with the toggle button for card view.

Parameters
string$rowid
array$row
array | null$suppresslastrow
Return values
string

◆ get_sort_columns()

core_reportbuilder\table\custom_report_table::get_sort_columns ( )

Get user preferred sort columns, overriding those of parent.

If user has no preferences then use report defaults

Return values
array

◆ get_sql_sort()

core_reportbuilder\table\base_report_table::get_sql_sort ( )
inherited

Override parent method of the same, to ensure that any columns with custom sort fields are accounted for.

Because the base table_sql has "special" handling of fullname columns {

See also
table_sql::contains_fullname_columns}, we need to handle that here to ensure that any that are being sorted take priority over reportbuilders own aliases of the same columns. This prevents them appearing multiple times in a query, which SQL Server really doesn't like
Return values
string

◆ get_table_sql()

core_reportbuilder\table\base_report_table::get_table_sql ( bool $includesort = true)
protectedinherited

Generate suitable SQL for the table.

Parameters
bool$includesort
Return values
string

◆ get_total_row_count()

core_reportbuilder\table\base_report_table::get_total_row_count ( )
inherited

Return total row count for report table.

Note we'd typically use {

See also
query_db} and then read the {
totalrows} property to reduce DB calls, however we can use this method when we specifically don't also need to obtain all data
Return values
int

◆ has_capability()

core_reportbuilder\table\custom_report_table::has_capability ( )

Check if the user has the capability to access this table.

Return values
boolReturn true if capability check passed.

Implements core_table\dynamic.

Reimplemented in core_reportbuilder\table\custom_report_table_view.

◆ init_sql()

core_reportbuilder\table\base_report_table::init_sql ( string $fields,
string $from,
array $joins,
string $where,
array $params,
array $groupby = [] )
protectedinherited

Initialises table SQL properties.

Parameters
string$fields
string$from
array$joins
string$where
array$params
array$groupby

◆ out()

core_reportbuilder\table\custom_report_table::out ( $pagesize,
$useinitialsbar,
$downloadhelpbutton = '' )

Overriding this method to handle live editing setting.

Parameters
int$pagesize
bool$useinitialsbar
string$downloadhelpbutton

◆ print_headers()

core_reportbuilder\table\custom_report_table::print_headers ( )

Override parent method for printing headers so we can render our custom controls in each cell.

Reimplemented in core_reportbuilder\table\custom_report_table_view.

◆ print_nothing_to_display()

core_reportbuilder\table\custom_report_table::print_nothing_to_display ( )

Override print_nothing_to_display to ensure that column headers are always added.

Reimplemented from core_reportbuilder\table\base_report_table.

◆ query_db()

core_reportbuilder\table\base_report_table::query_db ( $pagesize,
$useinitialsbar = true )
inherited

Override parent method of the same, to make use of a recordset and avoid issues with duplicate values in the first column.

Parameters
int$pagesize
bool$useinitialsbar

◆ set_report_editing()

core_reportbuilder\table\base_report_table::set_report_editing ( bool $editing)
inherited

Whether the current report table is being edited, in which case certain actions are not applied to it, e.g.

user filtering and sorting. Default class value is false

Parameters
bool$editing

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