Differences Between: [Versions 310 and 400] [Versions 39 and 400] [Versions 400 and 402] [Versions 400 and 403]
Forum subscription manager.
Copyright: | 2014 Andrew Nicols <andrew@nicols.co.uk> |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 868 lines (36 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
subscriptions:: (23 methods):
is_subscribed()
is_subscribed_to_forum()
is_forcesubscribed()
subscription_disabled()
is_subscribable()
set_subscription_mode()
get_subscription_mode()
get_unsubscribable_forums()
get_potential_subscribers()
fetch_subscription_cache()
fill_subscription_cache()
fill_subscription_cache_for_course()
fetch_subscribed_users()
fetch_discussion_subscription()
fill_discussion_subscription_cache()
add_to_discussion_cache()
reset_discussion_cache()
reset_forum_cache()
subscribe_user()
unsubscribe_user()
subscribe_user_to_discussion()
unsubscribe_user_from_discussion()
get_user_default_subscription()
Class: subscriptions - X-Ref
Forum subscription manager.is_subscribed($userid, $forum, $discussionid = null, $cm = null) X-Ref |
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. return: boolean param: int $userid The user ID param: \stdClass $forum The record of the forum to test param: int $discussionid The ID of the discussion to check param: $cm The coursemodule record. If not supplied, this will be calculated using get_fast_modinfo instead. |
is_subscribed_to_forum($userid, $forum) X-Ref |
Whether a user is subscribed to this forum. return: boolean param: int $userid The user ID param: \stdClass $forum The record of the forum to test |
is_forcesubscribed($forum) X-Ref |
Helper to determine whether a forum has it's subscription mode set to forced subscription. return: bool param: \stdClass $forum The record of the forum to test |
subscription_disabled($forum) X-Ref |
Helper to determine whether a forum has it's subscription mode set to disabled. return: bool param: \stdClass $forum The record of the forum to test |
is_subscribable($forum) X-Ref |
Helper to determine whether the specified forum can be subscribed to. return: bool param: \stdClass $forum The record of the forum to test |
set_subscription_mode($forumid, $status = 1) X-Ref |
Set the forum subscription mode. By default when called without options, this is set to FORUM_FORCESUBSCRIBE. return: bool param: \stdClass $forum The record of the forum to set param: int $status The new subscription state |
get_subscription_mode($forum) X-Ref |
Returns the current subscription mode for the forum. return: int The forum subscription mode param: \stdClass $forum The record of the forum to set |
get_unsubscribable_forums() X-Ref |
Returns an array of forums that the current user is subscribed to and is allowed to unsubscribe from return: array An array of unsubscribable forums |
get_potential_subscribers($context, $groupid, $fields, $sort = '') X-Ref |
Get the list of potential subscribers to a forum. return: array list of users. param: context_module $context the forum context. param: integer $groupid the id of a group, or 0 for all groups. param: string $fields the list of fields to return for each user. As for get_users_by_capability. param: string $sort sort order. As for get_users_by_capability. |
fetch_subscription_cache($forumid, $userid) X-Ref |
Fetch the forum subscription data for the specified userid and forum. return: boolean param: int $forumid The forum to retrieve a cache for param: int $userid The user ID |
fill_subscription_cache($forumid, $userid = null) X-Ref |
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. return: void param: int $forumid The forum to retrieve a cache for param: int $userid The user ID |
fill_subscription_cache_for_course($courseid, $userid) X-Ref |
Fill the forum subscription data for all forums that the specified userid can subscribe to in the specified course. return: void param: int $courseid The course to retrieve a cache for param: int $userid The user ID |
fetch_subscribed_users($forum, $groupid = 0, $context = null, $fields = null,$includediscussionsubscriptions = false) X-Ref |
Returns a list of user objects who are subscribed to this forum. return: array list of users. param: stdClass $forum The forum record. param: int $groupid The group id if restricting subscriptions to a group of users, or 0 for all. param: context_module $context the forum context, to save re-fetching it where possible. param: string $fields requested user fields (with "u." table prefix). param: boolean $includediscussionsubscriptions Whether to take discussion subscriptions and unsubscriptions into consideration. |
fetch_discussion_subscription($forumid, $userid = null) X-Ref |
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. return: array of stdClass objects with one per discussion in the forum. param: int $forumid The forum to retrieve a cache for param: int $userid The user ID |
fill_discussion_subscription_cache($forumid, $userid = null) X-Ref |
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. return: void param: int $forumid The forum to retrieve a cache for param: int $userid The user ID |
add_to_discussion_cache($forumid, $userid, $discussion, $preference) X-Ref |
Add the specified discussion and user preference to the discussion subscription cache. param: int $forumid The ID of the forum that this preference belongs to param: int $userid The ID of the user that this preference belongs to param: int $discussion The ID of the discussion that this preference relates to param: int $preference The preference to store |
reset_discussion_cache() X-Ref |
Reset the discussion cache. This cache is used to reduce the number of database queries when checking forum discussion subscription states. |
reset_forum_cache() X-Ref |
Reset the forum cache. This cache is used to reduce the number of database queries when checking forum subscription states. |
subscribe_user($userid, $forum, $context = null, $userrequest = false) X-Ref |
Adds user to the subscriber list. return: bool|int Returns true if the user is already subscribed, or the forum_subscriptions ID if the user was param: int $userid The ID of the user to subscribe param: \stdClass $forum The forum record for this forum. param: \context_module|null $context Module context, may be omitted if not known or if called for the current param: boolean $userrequest Whether the user requested this change themselves. This has an effect on whether |
unsubscribe_user($userid, $forum, $context = null, $userrequest = false) X-Ref |
Removes user from the subscriber list return: boolean Always returns true. param: int $userid The ID of the user to unsubscribe param: \stdClass $forum The forum record for this forum. param: \context_module|null $context Module context, may be omitted if not known or if called for the current param: boolean $userrequest Whether the user requested this change themselves. This has an effect on whether |
subscribe_user_to_discussion($userid, $discussion, $context = null) X-Ref |
Subscribes the user to the specified discussion. return: boolean Whether a change was made param: int $userid The userid of the user being subscribed param: \stdClass $discussion The discussion to subscribe to param: \context_module|null $context Module context, may be omitted if not known or if called for the current |
unsubscribe_user_from_discussion($userid, $discussion, $context = null) X-Ref |
Unsubscribes the user from the specified discussion. return: boolean Whether a change was made param: int $userid The userid of the user being unsubscribed param: \stdClass $discussion The discussion to unsubscribe from param: \context_module|null $context Module context, may be omitted if not known or if called for the current |
get_user_default_subscription($forum, $context, $cm, ?int $discussionid) X-Ref |
Gets the default subscription value for the logged in user. return: bool Default subscription param: \stdClass $forum The forum record param: \context $context The course context param: \cm_info $cm cm_info param: int|null $discussionid The discussion we are checking against |