Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250711) (9addea9f0ac)
|
Post vault class. More...
Public Member Functions | |
get_first_post_for_discussion_ids (array $discussionids) | |
Get a mapping of the first post in each discussion based on post creation time. | |
get_from_discussion_id (stdClass $user, int $discussionid, bool $canseeprivatereplies, string $orderby='created ASC, id ASC') | |
Get the post ids for the given discussion. | |
get_from_discussion_ids (stdClass $user, array $discussionids, bool $canseeprivatereplies, string $orderby='') | |
Get the list of posts for the given discussions. | |
get_from_filters (stdClass $user, array $filters, bool $canseeprivatereplies, string $orderby='') | |
The method returns posts based on a set of filters. | |
get_from_id (int $id) | |
Get the entity for the given id. | |
get_from_ids (array $ids) | |
Get the list of entities for the given ids. | |
get_latest_posts_for_discussion_ids (stdClass $user, array $discussionids, bool $canseeprivatereplies) | |
Get a mapping of the most recent post record in each discussion based on post creation time. | |
get_posts_in_discussion_for_user_id (int $discussionid, int $userid, bool $canseeprivatereplies, string $orderby='created ASC, id ASC') | |
Get the posts for the given user. | |
get_replies_to_post (stdClass $user, post_entity $post, bool $canseeprivatereplies, string $orderby='created ASC, id ASC') | |
Load a list of replies to the given post. | |
get_reply_count_for_discussion_ids (stdClass $user, array $discussionids, bool $canseeprivatereplies) | |
Get a mapping of replies to the specified discussions. | |
get_reply_count_for_post_id_in_discussion_id (stdClass $user, int $postid, int $discussionid, bool $canseeprivatereplies) | |
Get a mapping of replies to the specified discussions. | |
get_unread_count_for_discussion_ids (stdClass $user, array $discussionids, bool $canseeprivatereplies) | |
Get a mapping of unread post counts for the specified discussions. | |
Protected Member Functions | |
from_db_records (array $results) | |
Convert the DB records into post entities. | |
generate_get_records_sql (?string $wheresql=null, ?string $sortsql=null, ?int $userid=null) | |
Build the SQL to be used in get_records_sql. | |
get_db () | |
Get the moodle database. | |
get_entity_factory () | |
Get the entity factory. | |
get_legacy_factory () | |
Get the legacy factory. | |
get_preprocessors () | |
Get the list of preprocessors to run on the DB record results. | |
get_table_alias () | |
Get the table alias. | |
transform_db_records_to_entities (array $records) | |
Execute the defined preprocessors on the DB record results and then convert them into entities. | |
Post vault class.
This should be the only place that accessed the database.
This class should not return any objects other than post_entity objects. The class may contain some utility count methods which return integers.
This uses the repository pattern. See: https://designpatternsphp.readthedocs.io/en/latest/More/Repository/README.html
|
protected |
Convert the DB records into post entities.
array | $results | The DB records |
post_entity[] |
Reimplemented from mod_forum\local\vaults\db_table_vault.
|
protected |
Build the SQL to be used in get_records_sql.
string | null | $wheresql | Where conditions for the SQL |
string | null | $sortsql | Order by conditions for the SQL |
int | null | $userid | The user ID |
string |
Reimplemented from mod_forum\local\vaults\db_table_vault.
|
protectedinherited |
Get the moodle database.
moodle_database |
|
protectedinherited |
Get the entity factory.
entity_factory |
mod_forum\local\vaults\post::get_first_post_for_discussion_ids | ( | array | $discussionids | ) |
Get a mapping of the first post in each discussion based on post creation time.
int[] | $discussionids | The list of discussions to fetch counts for |
post_entity[] | The post object of the first post for each discussions returned in an associative array |
mod_forum\local\vaults\post::get_from_discussion_id | ( | stdClass | $user, |
int | $discussionid, | ||
bool | $canseeprivatereplies, | ||
string | $orderby = 'created ASC, | ||
id ASC' | ) |
Get the post ids for the given discussion.
stdClass | $user | The user to check the unread count for |
int | $discussionid | The discussion to load posts for |
bool | $canseeprivatereplies | Whether this user can see all private replies or not |
string | $orderby | Order the results |
post_entity[] |
mod_forum\local\vaults\post::get_from_discussion_ids | ( | stdClass | $user, |
array | $discussionids, | ||
bool | $canseeprivatereplies, | ||
string | $orderby = '' ) |
Get the list of posts for the given discussions.
stdClass | $user | The user to load posts for. |
int[] | $discussionids | The list of discussion ids to load posts for |
bool | $canseeprivatereplies | Whether this user can see all private replies or not |
string | $orderby | Order the results |
post_entity[] |
mod_forum\local\vaults\post::get_from_filters | ( | stdClass | $user, |
array | $filters, | ||
bool | $canseeprivatereplies, | ||
string | $orderby = '' ) |
The method returns posts based on a set of filters.
stdClass | $user | Only used when restricting private replies |
array | $filters | Export filters, valid filters are: |
'discussionids' => array of discussion ids eg [1,2,3] 'userids' => array of user ids eg [1,2,3] 'from' => timestamp to filter posts from this date. 'to' => timestamp to filter posts till this date.
bool | $canseeprivatereplies | Whether this user can see all private replies or not |
string | $orderby | Order the results |
post_entity[] |
|
inherited |
Get the entity for the given id.
int | $id | Identifier for the entity |
object|null |
|
inherited |
Get the list of entities for the given ids.
int[] | $ids | Identifiers |
array |
mod_forum\local\vaults\post::get_latest_posts_for_discussion_ids | ( | stdClass | $user, |
array | $discussionids, | ||
bool | $canseeprivatereplies ) |
Get a mapping of the most recent post record in each discussion based on post creation time.
stdClass | $user | |
array | $discussionids | |
bool | $canseeprivatereplies |
array |
coding_exception | |
dml_exception |
|
protectedinherited |
Get the legacy factory.
object |
mod_forum\local\vaults\post::get_posts_in_discussion_for_user_id | ( | int | $discussionid, |
int | $userid, | ||
bool | $canseeprivatereplies, | ||
string | $orderby = 'created ASC, | ||
id ASC' | ) |
Get the posts for the given user.
int | $discussionid | The discussion to fetch posts for |
int | $userid | The user to fetch posts for |
bool | $canseeprivatereplies | Whether this user can see all private replies or not |
string | $orderby | Order the results |
post_entity[] |
|
protectedinherited |
Get the list of preprocessors to run on the DB record results.
The preprocessors should be defined using an associative array. The key used to identify the preprocessor in this list will be used to identify the value of that preprocessor in the list of results when passed to the from_db_records function.
array |
Reimplemented in mod_forum\local\vaults\discussion_list, and mod_forum\local\vaults\forum.
mod_forum\local\vaults\post::get_replies_to_post | ( | stdClass | $user, |
post_entity | $post, | ||
bool | $canseeprivatereplies, | ||
string | $orderby = 'created ASC, | ||
id ASC' | ) |
Load a list of replies to the given post.
This will load all descendants of the post. That is, all direct replies and replies to those replies etc.
The return value will be a flat array of posts in the requested order.
stdClass | $user | The user to check the unread count for |
post_entity | $post | The post to load replies for |
bool | $canseeprivatereplies | Whether this user can see all private replies or not |
string | $orderby | How to order the replies |
post_entity[] |
mod_forum\local\vaults\post::get_reply_count_for_discussion_ids | ( | stdClass | $user, |
array | $discussionids, | ||
bool | $canseeprivatereplies ) |
Get a mapping of replies to the specified discussions.
stdClass | $user | The user to check the unread count for |
int[] | $discussionids | The list of discussions to fetch counts for |
bool | $canseeprivatereplies | Whether this user can see all private replies or not |
int[] | The number of replies for each discussion returned in an associative array |
mod_forum\local\vaults\post::get_reply_count_for_post_id_in_discussion_id | ( | stdClass | $user, |
int | $postid, | ||
int | $discussionid, | ||
bool | $canseeprivatereplies ) |
Get a mapping of replies to the specified discussions.
stdClass | $user | The user to check the unread count for |
int | $postid | The post to collect replies to |
int | $discussionid | The list of discussions to fetch counts for |
bool | $canseeprivatereplies | Whether this user can see all private replies or not |
int | The number of replies for each discussion returned in an associative array |
|
protected |
mod_forum\local\vaults\post::get_unread_count_for_discussion_ids | ( | stdClass | $user, |
array | $discussionids, | ||
bool | $canseeprivatereplies ) |
Get a mapping of unread post counts for the specified discussions.
stdClass | $user | The user to fetch counts for |
int[] | $discussionids | The list of discussions to fetch counts for |
bool | $canseeprivatereplies | Whether this user can see all private replies or not |
int[] | The count of unread posts for each discussion returned in an associative array |
|
protectedinherited |