Moodle PHP Documentation 4.5
Moodle 4.5.5+ (Build: 20250711) (ce34e8ff087)
forumreport_summary\summary_table Class Reference

The class for displaying the forum report table. More...

Inheritance diagram for forumreport_summary\summary_table:

Public Member Functions

 __construct (int $courseid, array $filters, bool $allowbulkoperations, bool $canseeprivatereplies, int $perpage, bool $canexport, bool $iscoursereport, bool $accessallforums)
 Forum report table constructor.
 
 add_filter (int $filtertype, array $values=[])
 Adds the relevant SQL to apply a filter to the report.
 
 col_attachmentcount (\stdClass $data)
 Generate the attachmentcount column.
 
 col_earliestpost (\stdClass $data)
 Generate the earliestpost column.
 
 col_export (\stdClass $data)
 Generate the export column.
 
 col_fullname ($data)
 Generate the fullname column.
 
 col_latestpost (\stdClass $data)
 Generate the latestpost column.
 
 col_postcount (\stdClass $data)
 Generate the postcount column.
 
 col_replycount (\stdClass $data)
 Generate the replycount column.
 
 col_select ($data)
 Generate the select column.
 
 download ($format)
 Download the summary report in the selected format.
 
 get_perpage ()
 Fetch the number of items to be displayed per page.
 
 out ($pagesize, $useinitialsbar, $downloadhelpbutton='')
 Convenience method to call a number of methods for you to display the table.
 
 print_nothing_to_display ()
 Override the default implementation to set a notification.
 
 query_db ($pagesize, $useinitialsbar=false)
 Query the db.
 
 set_sql ($fields, $from, $where, array $params=[])
 Overriding the parent method because it should not be used here.
 
 wrap_html_finish ()
 Overriding method to render the bulk actions and items per page pagination options directly below the table.
 

Public Attributes

stdClass $sql
 The various SQL segments that will be combined to form queries to fetch various information.
 
const DEFAULT_PER_PAGE = 50
 Default number of rows to display per page.
 
const FILTER_DATES = 3
 Dates filter type.
 
const FILTER_FORUM = 1
 Forum filter type.
 
const FILTER_GROUPS = 2
 Groups filter type.
 
const LOG_SUMMARY_TEMP_TABLE = 'forum_report_summary_counts'
 Table to store summary data extracted from the log table.
 

Protected Member Functions

 apply_filters (array $filters)
 Apply the relevant filters to the report.
 
 create_log_summary_temp_table ()
 Creates a temp table to store summary data from the log table for this request.
 
 define_base_filter_sql ()
 Instantiate the properties to store filter values.
 
 define_base_sql ()
 Define the object to store all for the table SQL and initialises the base SQL required.
 
 define_table_configs ()
 Define various table config options.
 
 drop_log_summary_temp_table ()
 Drops the temp table.
 
 fill_log_summary_temp_table ()
 Fills the log summary temp table.
 
 get_filter_groups (array $groups)
 Get the final list of groups to filter by, based on the groups submitted, and those the user has access to.
 
 get_filter_name (int $filtertype)
 Provides the string name of each filter type, to be used by errors.
 
 get_full_sql (bool $fullselect=true)
 Prepares a complete SQL statement from the base query and any filters defined.
 
 get_internal_log_reader ()
 Returns an internal and enabled log reader.
 
 set_forum_properties (array $forumids)
 Sets properties that are determined by forum filter values.
 
 show_word_char_counts ()
 

Protected Attributes

bool $accessallforums = false
 True if user has access to all forums in the course (and is running course report), otherwise false.
 
bool $allowbulkoperations = false
 Whether the user has the capability/capabilities to perform bulk operations.
 
bool $canseeprivatereplies
 Whether the user can see all private replies or not.
 
stdClass $cms = []
 The course module object(s) of the forum(s) being reported on.
 
int $courseid
 The course ID containing the forum(s) being reported on.
 
array $exportfilterdata = []
 Validated filter data, for use in GET parameters by export links.
 
array $forumcontexts = []
 of context objects for the forums included in the report.
 
bool $iscoursereport = false
 True if reporting on all forums in course user has access to, false if reporting on a single forum.
 
core log sql_reader null $logreader = null
 
int $perpage = self::DEFAULT_PER_PAGE
 The number of rows to be displayed per page.
 
array $perpageoptions = [50, 100, 200]
 The values available for pagination size per page.
 
context_course context_module $userfieldscontext = null
 The context where the report is being run (either a specific forum or the course).
 
int $userid
 The user ID if only one user's summary will be generated.
 

Detailed Description

The class for displaying the forum report table.

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

Constructor & Destructor Documentation

◆ __construct()

forumreport_summary\summary_table::__construct ( int $courseid,
array $filters,
bool $allowbulkoperations,
bool $canseeprivatereplies,
int $perpage,
bool $canexport,
bool $iscoursereport,
bool $accessallforums )

Forum report table constructor.

Parameters
int$courseidThe ID of the course the forum(s) exist within.
array$filtersReport filters in the format 'type' => [values].
bool$allowbulkoperationsIs the user allowed to perform bulk operations?
bool$canseeprivaterepliesWhether the user can see all private replies or not.
int$perpageThe number of rows to display per page.
bool$canexportIs the user allowed to export records?
bool$iscoursereportWhether the user is running a course level report
bool$accessallforumsIf user is running a course level report, do they have access to all forums in the course?

Member Function Documentation

◆ add_filter()

forumreport_summary\summary_table::add_filter ( int $filtertype,
array $values = [] )

Adds the relevant SQL to apply a filter to the report.

Parameters
int$filtertypeFilter type as defined by class constants.
array$valuesOptional array of values passed into the filter type.
Return values
void
Exceptions
coding_exception

◆ apply_filters()

forumreport_summary\summary_table::apply_filters ( array $filters)
protected

Apply the relevant filters to the report.

Parameters
array$filtersReport filters in the format 'type' => [values].
Return values
void.

◆ col_attachmentcount()

forumreport_summary\summary_table::col_attachmentcount ( \stdClass $data)

Generate the attachmentcount column.

Parameters
stdClass$dataThe row data.
Return values
intnumber of files attached to posts by user.

◆ col_earliestpost()

forumreport_summary\summary_table::col_earliestpost ( \stdClass $data)

Generate the earliestpost column.

Parameters
stdClass$dataThe row data.
Return values
stringTimestamp of user's earliest post, or a dash if no posts exist.

◆ col_export()

forumreport_summary\summary_table::col_export ( \stdClass $data)

Generate the export column.

Parameters
stdClass$dataThe row data.
Return values
stringThe link to export content belonging to the row.

◆ col_fullname()

forumreport_summary\summary_table::col_fullname ( $data)

Generate the fullname column.

Parameters
stdClass$dataThe row data.
Return values
stringUser's full name.

◆ col_latestpost()

forumreport_summary\summary_table::col_latestpost ( \stdClass $data)

Generate the latestpost column.

Parameters
stdClass$dataThe row data.
Return values
stringTimestamp of user's most recent post, or a dash if no posts exist.

◆ col_postcount()

forumreport_summary\summary_table::col_postcount ( \stdClass $data)

Generate the postcount column.

Parameters
stdClass$dataThe row data.
Return values
intnumber of discussion posts made by user.

◆ col_replycount()

forumreport_summary\summary_table::col_replycount ( \stdClass $data)

Generate the replycount column.

Parameters
stdClass$dataThe row data.
Return values
intnumber of replies made by user.

◆ col_select()

forumreport_summary\summary_table::col_select ( $data)

Generate the select column.

Parameters
stdClass$data
Return values
string

◆ create_log_summary_temp_table()

forumreport_summary\summary_table::create_log_summary_temp_table ( )
protected

Creates a temp table to store summary data from the log table for this request.

Return values
null

◆ define_base_filter_sql()

forumreport_summary\summary_table::define_base_filter_sql ( )
protected

Instantiate the properties to store filter values.

Return values
void.

◆ define_base_sql()

forumreport_summary\summary_table::define_base_sql ( )
protected

Define the object to store all for the table SQL and initialises the base SQL required.

Return values
void.

◆ define_table_configs()

forumreport_summary\summary_table::define_table_configs ( )
protected

Define various table config options.

Return values
void.

◆ download()

forumreport_summary\summary_table::download ( $format)

Download the summary report in the selected format.

Parameters
string$formatThe format to download the report.

◆ drop_log_summary_temp_table()

forumreport_summary\summary_table::drop_log_summary_temp_table ( )
protected

Drops the temp table.

This should be called once the processing for the summary table has been done.

◆ fill_log_summary_temp_table()

forumreport_summary\summary_table::fill_log_summary_temp_table ( )
protected

Fills the log summary temp table.

Return values
null

◆ get_filter_groups()

forumreport_summary\summary_table::get_filter_groups ( array $groups)
protected

Get the final list of groups to filter by, based on the groups submitted, and those the user has access to.

Parameters
array$groupsThe group IDs submitted.
Return values
arrayGroup objects of groups to use in groups filter. If no filtering required (all groups selected), returns [].

◆ get_filter_name()

forumreport_summary\summary_table::get_filter_name ( int $filtertype)
protected

Provides the string name of each filter type, to be used by errors.

Note: This does not use language strings as the value is injected into error strings.

Parameters
int$filtertypeType of filter
Return values
stringName of the filter

◆ get_full_sql()

forumreport_summary\summary_table::get_full_sql ( bool $fullselect = true)
protected

Prepares a complete SQL statement from the base query and any filters defined.

Parameters
bool$fullselectWhether to select all relevant columns. False selects a count only (used to calculate pagination).
Return values
stringThe complete SQL statement.

◆ get_internal_log_reader()

forumreport_summary\summary_table::get_internal_log_reader ( )
protected

Returns an internal and enabled log reader.

Return values
core::log::sql_reader|false

◆ get_perpage()

forumreport_summary\summary_table::get_perpage ( )

Fetch the number of items to be displayed per page.

Return values
int

◆ out()

forumreport_summary\summary_table::out ( $pagesize,
$useinitialsbar,
$downloadhelpbutton = '' )

Convenience method to call a number of methods for you to display the table.

Overrides the parent so SQL for filters is handled.

Parameters
int$pagesizeNumber of rows to fetch.
bool$useinitialsbarWhether to include the initials bar with the table.
string$downloadhelpbuttonUnused.
Return values
void.

◆ print_nothing_to_display()

forumreport_summary\summary_table::print_nothing_to_display ( )

Override the default implementation to set a notification.

Return values
void.

◆ query_db()

forumreport_summary\summary_table::query_db ( $pagesize,
$useinitialsbar = false )

Query the db.

Store results in the table object for use by build_table.

Parameters
int$pagesizeSize of page for paginated displayed table.
bool$useinitialsbarOverridden but unused.
Return values
void

◆ set_forum_properties()

forumreport_summary\summary_table::set_forum_properties ( array $forumids)
protected

Sets properties that are determined by forum filter values.

Parameters
array$forumidsThe forum IDs passed in by the filter.
Return values
void

◆ set_sql()

forumreport_summary\summary_table::set_sql ( $fields,
$from,
$where,
array $params = [] )

Overriding the parent method because it should not be used here.

Filters are applied, so the structure of $this->sql is now different to the way this is set up in the parent.

Parameters
string$fieldsUnused.
string$fromUnused.
string$whereUnused.
array$paramsUnused.
Return values
void.
Exceptions
coding_exception

◆ wrap_html_finish()

forumreport_summary\summary_table::wrap_html_finish ( )

Overriding method to render the bulk actions and items per page pagination options directly below the table.

Return values
void

Member Data Documentation

◆ $userid

int forumreport_summary\summary_table::$userid
protected

The user ID if only one user's summary will be generated.

This will apply to users without permission to view others' summaries.


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