Post vault class.
More...
|
| 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') |
| 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') |
| Get the posts for the given user.
|
|
| get_replies_to_post (stdClass $user, post_entity $post, bool $canseeprivatereplies, string $orderby='created 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.
|
|
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
- Copyright
- 2019 Ryan Wyllie ryan@.nosp@m.mood.nosp@m.le.co.nosp@m.m
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
◆ from_db_records()
mod_forum\local\vaults\post::from_db_records |
( |
array | $results | ) |
|
|
protected |
◆ generate_get_records_sql()
mod_forum\local\vaults\post::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 | $wheresql | Where conditions for the SQL |
string | null | $sortsql | Order by conditions for the SQL |
int | null | $userid | The user ID |
- Return values
-
Reimplemented from mod_forum\local\vaults\db_table_vault.
◆ get_db()
mod_forum\local\vaults\db_table_vault::get_db |
( |
| ) |
|
|
protectedinherited |
Get the moodle database.
- Return values
-
◆ get_entity_factory()
mod_forum\local\vaults\db_table_vault::get_entity_factory |
( |
| ) |
|
|
protectedinherited |
Get the entity factory.
- Return values
-
◆ get_first_post_for_discussion_ids()
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.
- Parameters
-
int[] | $discussionids | The list of discussions to fetch counts for |
- Return values
-
post_entity[] | The post object of the first post for each discussions returned in an associative array |
◆ get_from_discussion_id()
mod_forum\local\vaults\post::get_from_discussion_id |
( |
stdClass | $user, |
|
|
int | $discussionid, |
|
|
bool | $canseeprivatereplies, |
|
|
string | $orderby = 'created ASC' ) |
Get the post ids for the given discussion.
- Parameters
-
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 |
- Return values
-
◆ get_from_discussion_ids()
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.
- Parameters
-
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 |
- Return values
-
◆ get_from_filters()
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.
- Parameters
-
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.
- Parameters
-
bool | $canseeprivatereplies | Whether this user can see all private replies or not |
string | $orderby | Order the results |
- Return values
-
◆ 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 | $id | Identifier for the entity |
- Return values
-
◆ 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
-
- Return values
-
◆ get_latest_posts_for_discussion_ids()
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.
- Parameters
-
stdClass | $user | |
array | $discussionids | |
bool | $canseeprivatereplies | |
- Return values
-
- Exceptions
-
◆ get_legacy_factory()
mod_forum\local\vaults\db_table_vault::get_legacy_factory |
( |
| ) |
|
|
protectedinherited |
Get the legacy factory.
- Return values
-
◆ get_posts_in_discussion_for_user_id()
mod_forum\local\vaults\post::get_posts_in_discussion_for_user_id |
( |
int | $discussionid, |
|
|
int | $userid, |
|
|
bool | $canseeprivatereplies, |
|
|
string | $orderby = 'created ASC' ) |
Get the posts for the given user.
- Parameters
-
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 |
- Return values
-
◆ get_preprocessors()
mod_forum\local\vaults\db_table_vault::get_preprocessors |
( |
| ) |
|
|
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.
- Return values
-
Reimplemented in mod_forum\local\vaults\discussion_list, and mod_forum\local\vaults\forum.
◆ get_replies_to_post()
mod_forum\local\vaults\post::get_replies_to_post |
( |
stdClass | $user, |
|
|
post_entity | $post, |
|
|
bool | $canseeprivatereplies, |
|
|
string | $orderby = 'created 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.
- Parameters
-
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 |
- Return values
-
◆ get_reply_count_for_discussion_ids()
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.
- Parameters
-
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 |
- Return values
-
int[] | The number of replies for each discussion returned in an associative array |
◆ get_reply_count_for_post_id_in_discussion_id()
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.
- Parameters
-
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 |
- Return values
-
int | The number of replies for each discussion returned in an associative array |
◆ get_table_alias()
mod_forum\local\vaults\post::get_table_alias |
( |
| ) |
|
|
protected |
◆ get_unread_count_for_discussion_ids()
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.
- Parameters
-
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 |
- Return values
-
int[] | The count of unread posts for each discussion returned in an associative array |
◆ 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[] | $records | List of DB results |
- Return values
-
The documentation for this class was generated from the following file:
- mod/forum/classes/local/vaults/post.php