Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
|
Class to manage subscriptions. More...
Static Public Member Functions | |
static | activate_subscriptions (array $ids) |
Activates a group of subscriptions based on an input array of ids. More... | |
static | count_rule_subscriptions ($ruleid) |
Get count of subscriptions for a given rule. More... | |
static | count_user_subscriptions ($userid=0) |
Get count of subscriptions for a given user. More... | |
static | count_user_subscriptions_for_course ($courseid, $userid=0) |
Get count of subscriptions for a given user in a given course. More... | |
static | create_subscription ($ruleid, $courseid, $cmid, $userid=0) |
Subscribe a user to a given rule. More... | |
static | deactivate_subscriptions (array $ids) |
Deactivates a group of subscriptions based on an input array of ids. More... | |
static | delete_cm_subscriptions ($cmid) |
Delete all subscriptions for a course module. More... | |
static | delete_stale_subscriptions ($userid=0) |
Deletes subscriptions which have been inactive for a period of time. More... | |
static | delete_subscription ($subscriptionorid, $checkuser=true) |
Delete a subscription. More... | |
static | delete_user_subscriptions ($userid) |
Delete all subscriptions for a user. More... | |
static | event_has_subscriptions ($eventname, $courseid) |
Returns true if an event in a particular course has a subscription. More... | |
static | get_subscription ($subscriptionorid) |
Get a subscription instance for an given subscription id. More... | |
static | get_subscriptions_by_event (\stdClass $event) |
Return a list of subscriptions for a given event. More... | |
static | get_user_subscriptions ($limitfrom=0, $limitto=0, $userid=0, $order='s.courseid ASC, r.name') |
Get an array of subscriptions for a given user. More... | |
static | get_user_subscriptions_for_course ($courseid, $limitfrom=0, $limitto=0, $userid=0, $order='s.timecreated DESC') |
Get an array of subscriptions for a given user in a given course. More... | |
static | remove_all_subscriptions_for_rule ($ruleid, $coursecontext=null) |
Delete all subscribers for a given rule. More... | |
static | remove_all_subscriptions_in_course ($coursecontext) |
Delete all subscriptions in a course. More... | |
static | subscription_is_active (subscription $subscription) |
Check whether a subscription is active. More... | |
Public Attributes | |
const | INACTIVE_SUBSCRIPTION_LIFESPAN_IN_DAYS = 30 |
@const Period of time, in days, after which an inactive subscription will be removed completely. | |
Static Protected Member Functions | |
static | get_instances ($arr) |
Helper method to convert db records to instances. More... | |
static | get_subscription_join_rule_sql ($count=false) |
Return sql to join rule and subscription table. More... | |
Class to manage subscriptions.
|
static |
Activates a group of subscriptions based on an input array of ids.
array | $ids | of subscription ids. |
bool | true if the operation was successful, false otherwise. |
|
static |
Get count of subscriptions for a given rule.
int | $ruleid | rule id of the subscription. |
int | number of subscriptions |
|
static |
Get count of subscriptions for a given user.
int | $userid | Id of the user for which the subscription needs to be fetched. Defaults to $USER; |
int | number of subscriptions |
|
static |
Get count of subscriptions for a given user in a given course.
int | $courseid | course id. |
int | $userid | Id of the user for which the subscription needs to be fetched. Defaults to $USER; |
int | number of subscriptions |
|
static |
Subscribe a user to a given rule.
int | $ruleid | Rule id. |
int | $courseid | Course id. |
int | $cmid | Course module id. |
int | $userid | User who is subscribing, defaults to $USER. |
bool|int | returns id of the created subscription. |
|
static |
Deactivates a group of subscriptions based on an input array of ids.
array | $ids | of subscription ids. |
bool | true if the operation was successful, false otherwise. |
|
static |
Delete all subscriptions for a course module.
int | $cmid | cm id. |
mixed |
|
static |
Deletes subscriptions which have been inactive for a period of time.
int | $userid | if provided, only this user's stale subscriptions will be deleted. |
bool | true if the operation was successful, false otherwise. |
|
static |
Delete a subscription.
subscription | int | $subscriptionorid | an instance of subscription class or id. |
bool | $checkuser | Check if the subscription belongs to current user before deleting. |
bool |
coding_exception | if $checkuser is true and the subscription doesn't belong to the current user. |
|
static |
Delete all subscriptions for a user.
int | $userid | user id. |
mixed |
|
static |
Returns true if an event in a particular course has a subscription.
string | $eventname | the name of the event |
int | $courseid | the course id |
bool | returns true if the event has subscriptions in a given course, false otherwise. |
|
staticprotected |
Helper method to convert db records to instances.
array | $arr | of subscriptions. |
array | of subscriptions as instances. |
|
static |
Get a subscription instance for an given subscription id.
subscription | int | $subscriptionorid | an instance of subscription class or id. |
subscription | returns a instance of subscription class. |
|
staticprotected |
Return sql to join rule and subscription table.
bool | $count | Weather if this is a count query or not. |
string | the sql. |
|
static |
Return a list of subscriptions for a given event.
stdClass | $event | the event object. |
array |
|
static |
Get an array of subscriptions for a given user.
int | $limitfrom | Limit from which to fetch rules. |
int | $limitto | Limit to which rules need to be fetched. |
int | $userid | Id of the user for which the subscription needs to be fetched. Defaults to $USER; |
string | $order | Order to sort the subscriptions. |
array | list of subscriptions |
|
static |
Get an array of subscriptions for a given user in a given course.
int | $courseid | course id. |
int | $limitfrom | Limit from which to fetch rules. |
int | $limitto | Limit to which rules need to be fetched. |
int | $userid | Id of the user for which the subscription needs to be fetched. Defaults to $USER; |
string | $order | Order to sort the subscriptions. |
array | list of subscriptions |
|
static |
Delete all subscribers for a given rule.
int | $ruleid | rule id. |
context | null | $coursecontext | the context of the course - this is passed when we can not get the context via context_course as the course has been deleted. |
bool |
|
static |
Delete all subscriptions in a course.
This is called after a course was deleted, context no longer exists but we kept the object
context_course | $coursecontext | the context of the course |
|
static |
Check whether a subscription is active.
tool_monitor::subscription | $subscription | instance. |
bool | true if the subscription is active, false otherwise. |