Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
mod_forum\local\vaults\discussion_list Class Reference

Discussion list vault. More...

Inheritance diagram for mod_forum\local\vaults\discussion_list:
mod_forum\local\vaults\db_table_vault

Public Member Functions

 get_from_forum_id (int $forumid, bool $includehiddendiscussions, ?int $includepostsforuser, ?int $sortorder, int $limit, int $offset)
 Get each discussion, first post, first and last post author for the given forum, considering timed posts, and pagination. More...
 
 get_from_forum_id_and_group_id (int $forumid, array $groupids, bool $includehiddendiscussions, ?int $includepostsforuser, ?int $sortorder, int $limit, int $offset)
 Get each discussion, first post, first and last post author for the given forum, and the set of groups to display considering timed posts, and pagination. More...
 
 get_from_id (int $id)
 Get the entity for the given id. More...
 
 get_from_ids (array $ids)
 Get the list of entities for the given ids. More...
 
 get_total_discussion_count_from_forum_id (int $forumid, bool $includehiddendiscussions, ?int $includepostsforuser)
 Count the number of discussions in the forum. More...
 
 get_total_discussion_count_from_forum_id_and_group_id (int $forumid, array $groupids, bool $includehiddendiscussions, ?int $includepostsforuser)
 Count the number of discussions in all groups and the list of groups provided. More...
 

Public Attributes

const PAGESIZE_DEFAULT = 100
 Default limit.
 
const SORTORDER_CREATED_ASC = 4
 Sort by created asc.
 
const SORTORDER_CREATED_DESC = 3
 Sort by created desc.
 
const SORTORDER_DISCUSSION_ASC = 8
 Sort by discussion name asc.
 
const SORTORDER_DISCUSSION_DESC = 7
 Sort by discussion name desc.
 
const SORTORDER_GROUP_ASC = 12
 Sort by group name asc.
 
const SORTORDER_GROUP_DESC = 11
 Sort by group name desc.
 
const SORTORDER_LASTPOST_ASC = 2
 Sort by oldest first.
 
const SORTORDER_LASTPOST_DESC = 1
 Sort by newest first.
 
const SORTORDER_REPLIES_ASC = 6
 Sort by number of replies desc.
 
const SORTORDER_REPLIES_DESC = 5
 Sort by number of replies desc.
 
const SORTORDER_STARTER_ASC = 10
 Sort by discussion starter's name asc.
 
const SORTORDER_STARTER_DESC = 9
 Sort by discussion starter's name desc.
 

Protected Member Functions

 from_db_records (array $results)
 Convert the DB records into discussion list entities. More...
 
 generate_count_records_sql (string $wheresql=null)
 Build the SQL to be used in count_records_sql. More...
 
 generate_get_records_sql (string $wheresql=null, ?string $sortsql=null, ?int $userid=null)
 Build the SQL to be used in get_records_sql. More...
 
 generate_get_records_sql (string $wheresql=null, string $sortsql=null, ?int $userid=null)
 Build the SQL to be used in get_records_sql. More...
 
 get_db ()
 Get the moodle database. More...
 
 get_entity_factory ()
 Get the entity factory. More...
 
 get_favourite_alias ()
 Get the favourite table alias. More...
 
 get_hidden_post_sql (bool $includehiddendiscussions, ?int $includepostsforuser)
 Fetch any required SQL to respect timed posts. More...
 
 get_keyfield (?int $sortmethod)
 Get the field to sort by. More...
 
 get_legacy_factory ()
 Get the legacy factory. More...
 
 get_preprocessors ()
 Get a list of preprocessors to execute on the DB results before being converted into entities. More...
 
 get_sort_direction (?int $sortmethod)
 Get the sort direction. More...
 
 get_table_alias ()
 Get the table alias. More...
 
 transform_db_records_to_entities (array $records)
 Execute the defined preprocessors on the DB record results and then convert them into entities. More...
 

Detailed Description

Discussion list vault.

This should be the only place that accessed the database.

This uses the repository pattern. See: https://designpatternsphp.readthedocs.io/en/latest/More/Repository/README.html

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

Member Function Documentation

◆ from_db_records()

mod_forum\local\vaults\discussion_list::from_db_records ( array  $results)
protected

Convert the DB records into discussion list entities.

Parameters
array$resultsThe DB records
Return values
discussion_list[]

Reimplemented from mod_forum\local\vaults\db_table_vault.

◆ generate_count_records_sql()

mod_forum\local\vaults\discussion_list::generate_count_records_sql ( string  $wheresql = null)
protected

Build the SQL to be used in count_records_sql.

Parameters
string | null$wheresqlWhere conditions for the SQL
Return values
string

◆ generate_get_records_sql() [1/2]

mod_forum\local\vaults\discussion_list::generate_get_records_sql ( string  $wheresql = null,
?string  $sortsql = null,
?int  $userid = null 
)
protected

Build the SQL to be used in get_records_sql.

Parameters
string | null$wheresqlWhere conditions for the SQL
string | null$sortsqlOrder by conditions for the SQL
int | null$useridThe ID of the user we are performing this query for
Return values
string

◆ generate_get_records_sql() [2/2]

mod_forum\local\vaults\db_table_vault::generate_get_records_sql ( string  $wheresql = null,
string  $sortsql = null,
?int  $userid = null 
)
abstractprotectedinherited

Build the SQL to be used in get_records_sql.

Parameters
string | null$wheresqlWhere conditions for the SQL
string | null$sortsqlOrder by conditions for the SQL
object | null$userThe user object
Return values
string

Reimplemented in mod_forum\local\vaults\post_read_receipt_collection, mod_forum\local\vaults\post, mod_forum\local\vaults\forum, mod_forum\local\vaults\discussion, and mod_forum\local\vaults\author.

◆ get_db()

mod_forum\local\vaults\db_table_vault::get_db ( )
protectedinherited

Get the moodle database.

Return values
moodle_database

◆ get_entity_factory()

mod_forum\local\vaults\db_table_vault::get_entity_factory ( )
protectedinherited

Get the entity factory.

Return values
entity_factory

◆ get_favourite_alias()

mod_forum\local\vaults\discussion_list::get_favourite_alias ( )
protected

Get the favourite table alias.

Return values
string

◆ get_from_forum_id()

mod_forum\local\vaults\discussion_list::get_from_forum_id ( int  $forumid,
bool  $includehiddendiscussions,
?int  $includepostsforuser,
?int  $sortorder,
int  $limit,
int  $offset 
)

Get each discussion, first post, first and last post author for the given forum, considering timed posts, and pagination.

Parameters
int$forumidThe forum to fetch the discussion set for
bool$includehiddendiscussionsWhether to include hidden discussions or not
int | null$includepostsforuserWhich user to include posts for, if any
int$sortorderThe sort order to use
int$limitThe number of discussions to fetch
int$offsetThe record offset
Return values
arrayThe set of data fetched

◆ get_from_forum_id_and_group_id()

mod_forum\local\vaults\discussion_list::get_from_forum_id_and_group_id ( int  $forumid,
array  $groupids,
bool  $includehiddendiscussions,
?int  $includepostsforuser,
?int  $sortorder,
int  $limit,
int  $offset 
)

Get each discussion, first post, first and last post author for the given forum, and the set of groups to display considering timed posts, and pagination.

Parameters
int$forumidThe forum to fetch the discussion set for
int[]$groupidsThe list of real groups to filter on
bool$includehiddendiscussionsWhether to include hidden discussions or not
int | null$includepostsforuserWhich user to include posts for, if any
int$sortorderThe sort order to use
int$limitThe number of discussions to fetch
int$offsetThe record offset
Return values
arrayThe set of data fetched

◆ get_from_id()

mod_forum\local\vaults\db_table_vault::get_from_id ( int  $id)
inherited

Get the entity for the given id.

Parameters
int$idIdentifier for the entity
Return values
object|null

◆ get_from_ids()

mod_forum\local\vaults\db_table_vault::get_from_ids ( array  $ids)
inherited

Get the list of entities for the given ids.

Parameters
int[]$idsIdentifiers
Return values
array

◆ get_hidden_post_sql()

mod_forum\local\vaults\discussion_list::get_hidden_post_sql ( bool  $includehiddendiscussions,
?int  $includepostsforuser 
)
protected

Fetch any required SQL to respect timed posts.

Parameters
bool$includehiddendiscussionsWhether to include hidden discussions or not
int | null$includepostsforuserWhich user to include posts for, if any
Return values
arrayThe SQL and parameters to include

◆ get_keyfield()

mod_forum\local\vaults\discussion_list::get_keyfield ( ?int  $sortmethod)
protected

Get the field to sort by.

Parameters
int | null$sortmethod
Return values
string

◆ get_legacy_factory()

mod_forum\local\vaults\db_table_vault::get_legacy_factory ( )
protectedinherited

Get the legacy factory.

Return values
object

◆ get_preprocessors()

mod_forum\local\vaults\discussion_list::get_preprocessors ( )
protected

Get a list of preprocessors to execute on the DB results before being converted into entities.

Return values
array

Reimplemented from mod_forum\local\vaults\db_table_vault.

◆ get_sort_direction()

mod_forum\local\vaults\discussion_list::get_sort_direction ( ?int  $sortmethod)
protected

Get the sort direction.

Parameters
int | null$sortmethod
Return values
string

◆ get_table_alias()

mod_forum\local\vaults\discussion_list::get_table_alias ( )
protected

Get the table alias.

Return values
string

Reimplemented from mod_forum\local\vaults\db_table_vault.

◆ get_total_discussion_count_from_forum_id()

mod_forum\local\vaults\discussion_list::get_total_discussion_count_from_forum_id ( int  $forumid,
bool  $includehiddendiscussions,
?int  $includepostsforuser 
)

Count the number of discussions in the forum.

Parameters
int$forumidId of the forum to count discussions in
bool$includehiddendiscussionsInclude hidden dicussions in the count?
int | null$includepostsforuserInclude discussions created by this user in the count (only works if not including hidden discussions).
Return values
int

◆ get_total_discussion_count_from_forum_id_and_group_id()

mod_forum\local\vaults\discussion_list::get_total_discussion_count_from_forum_id_and_group_id ( int  $forumid,
array  $groupids,
bool  $includehiddendiscussions,
?int  $includepostsforuser 
)

Count the number of discussions in all groups and the list of groups provided.

Parameters
int$forumidId of the forum to count discussions in
int[]$groupidsList of group ids to include in the count (discussions in all groups will always be counted)
bool$includehiddendiscussionsInclude hidden dicussions in the count?
int | null$includepostsforuserInclude discussions created by this user in the count (only works if not including hidden discussions).
Return values
int

◆ transform_db_records_to_entities()

mod_forum\local\vaults\db_table_vault::transform_db_records_to_entities ( array  $records)
protectedinherited

Execute the defined preprocessors on the DB record results and then convert them into entities.

Parameters
stdClass[]$recordsList of DB results
Return values
array

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