Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
|
Forum subscription manager. More...
Static Public Member Functions | |
static | fetch_discussion_subscription ($forumid, $userid=null) |
Retrieve the discussion subscription data for the specified userid and forum. | |
static | fetch_subscribed_users ($forum, $groupid=0, $context=null, $fields=null, $includediscussionsubscriptions=false) |
Returns a list of user objects who are subscribed to this forum. | |
static | fetch_subscription_cache ($forumid, $userid) |
Fetch the forum subscription data for the specified userid and forum. | |
static | fill_discussion_subscription_cache ($forumid, $userid=null) |
Fill the discussion subscription data for the specified userid and forum. | |
static | fill_subscription_cache ($forumid, $userid=null) |
Fill the forum subscription data for the specified userid and forum. | |
static | fill_subscription_cache_for_course ($courseid, $userid) |
Fill the forum subscription data for all forums that the specified userid can subscribe to in the specified course. | |
static | get_potential_subscribers ($context, $groupid, $fields, $sort='') |
Get the list of potential subscribers to a forum. | |
static | get_subscription_mode ($forum) |
Returns the current subscription mode for the forum. | |
static | get_unsubscribable_forums () |
Returns an array of forums that the current user is subscribed to and is allowed to unsubscribe from. | |
static | get_user_default_subscription ($forum, $context, $cm, ?int $discussionid) |
Gets the default subscription value for the logged in user. | |
static | is_forcesubscribed ($forum) |
Helper to determine whether a forum has it's subscription mode set to forced subscription. | |
static | is_subscribable ($forum) |
Helper to determine whether the specified forum can be subscribed to. | |
static | is_subscribed ($userid, $forum, $discussionid=null, $cm=null) |
Whether a user is subscribed to this forum, or a discussion within the forum. | |
static | reset_discussion_cache () |
Reset the discussion cache. | |
static | reset_forum_cache () |
Reset the forum cache. | |
static | set_subscription_mode ($forumid, $status=1) |
Set the forum subscription mode. | |
static | subscribe_user ($userid, $forum, $context=null, $userrequest=false) |
Adds user to the subscriber list. | |
static | subscribe_user_to_discussion ($userid, $discussion, $context=null) |
Subscribes the user to the specified discussion. | |
static | subscription_disabled ($forum) |
Helper to determine whether a forum has it's subscription mode set to disabled. | |
static | unsubscribe_user ($userid, $forum, $context=null, $userrequest=false) |
Removes user from the subscriber list. | |
static | unsubscribe_user_from_discussion ($userid, $discussion, $context=null) |
Unsubscribes the user from the specified discussion. | |
Public Attributes | |
int const | FORUM_DISCUSSION_UNSUBSCRIBED = -1 |
The status value for an unsubscribed discussion. | |
Static Protected Member Functions | |
static | add_to_discussion_cache ($forumid, $userid, $discussion, $preference) |
Add the specified discussion and user preference to the discussion subscription cache. | |
static | is_subscribed_to_forum ($userid, $forum) |
Whether a user is subscribed to this forum. | |
Static Protected Attributes | |
static bool[] | $discussionfetchedforums = array() |
The list of forums which have been wholly retrieved for the forum discussion subscription cache. | |
static bool[] | $fetchedforums = array() |
The list of forums which have been wholly retrieved for the forum subscription cache. | |
static array[] | $forumcache = array() |
The subscription cache for forums. | |
static array[] | $forumdiscussioncache = array() |
The subscription cache for forum discussions. | |
Forum subscription manager.
|
staticprotected |
Add the specified discussion and user preference to the discussion subscription cache.
int | $forumid | The ID of the forum that this preference belongs to |
int | $userid | The ID of the user that this preference belongs to |
int | $discussion | The ID of the discussion that this preference relates to |
int | $preference | The preference to store |
|
static |
Retrieve the discussion subscription data for the specified userid and forum.
This is returned as an array of discussions for that forum which contain the preference in a stdClass.
int | $forumid | The forum to retrieve a cache for |
int | $userid | The user ID |
array | of stdClass objects with one per discussion in the forum. |
|
static |
Returns a list of user objects who are subscribed to this forum.
stdClass | $forum | The forum record. |
int | $groupid | The group id if restricting subscriptions to a group of users, or 0 for all. |
context_module | $context | the forum context, to save re-fetching it where possible. |
string | $fields | requested user fields (with "u." table prefix). |
boolean | $includediscussionsubscriptions | Whether to take discussion subscriptions and unsubscriptions into consideration. |
array | list of users. |
|
static |
Fetch the forum subscription data for the specified userid and forum.
int | $forumid | The forum to retrieve a cache for |
int | $userid | The user ID |
boolean |
|
static |
Fill the discussion subscription data for the specified userid and forum.
If the userid is not specified, then all discussion subscription data for that forum is fetched in a single query and used for subsequent lookups without requiring further database queries.
int | $forumid | The forum to retrieve a cache for |
int | $userid | The user ID |
void |
|
static |
Fill the forum subscription data for the specified userid and forum.
If the userid is not specified, then all subscription data for that forum is fetched in a single query and used for subsequent lookups without requiring further database queries.
int | $forumid | The forum to retrieve a cache for |
int | $userid | The user ID |
void |
|
static |
Fill the forum subscription data for all forums that the specified userid can subscribe to in the specified course.
int | $courseid | The course to retrieve a cache for |
int | $userid | The user ID |
void |
|
static |
Get the list of potential subscribers to a forum.
context_module | $context | the forum context. |
integer | $groupid | the id of a group, or 0 for all groups. |
string | $fields | the list of fields to return for each user. As for get_users_by_capability. |
string | $sort | sort order. As for get_users_by_capability. |
array | list of users. |
|
static |
Returns the current subscription mode for the forum.
stdClass | $forum | The record of the forum to set |
int | The forum subscription mode |
|
static |
Returns an array of forums that the current user is subscribed to and is allowed to unsubscribe from.
array | An array of unsubscribable forums |
|
static |
Gets the default subscription value for the logged in user.
stdClass | $forum | The forum record |
context | $context | The course context |
cm_info | $cm | cm_info |
int | null | $discussionid | The discussion we are checking against |
bool | Default subscription |
coding_exception |
|
static |
Helper to determine whether a forum has it's subscription mode set to forced subscription.
stdClass | $forum | The record of the forum to test |
bool |
|
static |
Helper to determine whether the specified forum can be subscribed to.
stdClass | $forum | The record of the forum to test |
bool |
|
static |
Whether a user is subscribed to this forum, or a discussion within the forum.
If a discussion is specified, then report whether the user is subscribed to posts to this particular discussion, taking into account the forum preference.
If it is not specified then only the forum preference is considered.
int | $userid | The user ID |
stdClass | $forum | The record of the forum to test |
int | $discussionid | The ID of the discussion to check |
$cm | The coursemodule record. If not supplied, this will be calculated using get_fast_modinfo instead. |
boolean |
|
staticprotected |
Whether a user is subscribed to this forum.
int | $userid | The user ID |
stdClass | $forum | The record of the forum to test |
boolean |
|
static |
Reset the discussion cache.
This cache is used to reduce the number of database queries when checking forum discussion subscription states.
|
static |
Reset the forum cache.
This cache is used to reduce the number of database queries when checking forum subscription states.
|
static |
Set the forum subscription mode.
By default when called without options, this is set to FORUM_FORCESUBSCRIBE.
stdClass | $forum | The record of the forum to set |
int | $status | The new subscription state |
bool |
|
static |
Adds user to the subscriber list.
int | $userid | The ID of the user to subscribe |
stdClass | $forum | The forum record for this forum. |
context_module | null | $context | Module context, may be omitted if not known or if called for the current module set in page. |
boolean | $userrequest | Whether the user requested this change themselves. This has an effect on whether discussion subscriptions are removed too. |
bool|int | Returns true if the user is already subscribed, or the forum_subscriptions ID if the user was successfully subscribed. |
|
static |
Subscribes the user to the specified discussion.
int | $userid | The userid of the user being subscribed |
stdClass | $discussion | The discussion to subscribe to |
context_module | null | $context | Module context, may be omitted if not known or if called for the current module set in page. |
boolean | Whether a change was made |
|
static |
Helper to determine whether a forum has it's subscription mode set to disabled.
stdClass | $forum | The record of the forum to test |
bool |
|
static |
Removes user from the subscriber list.
int | $userid | The ID of the user to unsubscribe |
stdClass | $forum | The forum record for this forum. |
context_module | null | $context | Module context, may be omitted if not known or if called for the current module set in page. |
boolean | $userrequest | Whether the user requested this change themselves. This has an effect on whether discussion subscriptions are removed too. |
boolean | Always returns true. |
|
static |
Unsubscribes the user from the specified discussion.
int | $userid | The userid of the user being unsubscribed |
stdClass | $discussion | The discussion to unsubscribe from |
context_module | null | $context | Module context, may be omitted if not known or if called for the current module set in page. |
boolean | Whether a change was made |
|
staticprotected |
The list of forums which have been wholly retrieved for the forum discussion subscription cache.
This allows for prior caching of an entire forum to reduce the number of DB queries in a subscription check loop.
|
staticprotected |
The list of forums which have been wholly retrieved for the forum subscription cache.
This allows for prior caching of an entire forum to reduce the number of DB queries in a subscription check loop.
|
staticprotected |
The subscription cache for forums.
The first level key is the user ID The second level is the forum ID The Value then is bool for subscribed of not.
An array of arrays.
|
staticprotected |
The subscription cache for forum discussions.
The first level key is the user ID The second level is the forum ID The third level key is the discussion ID The value is then the users preference (int)