Elgg
Version master
|
Subscription service. More...
Public Member Functions | |
__construct (protected Database $db, protected RelationshipsTable $relationshipsTable, protected EventsService $events) | |
Constructor. More... | |
getNotificationEventSubscriptions (NotificationEvent $event, array $methods, array $exclude_guids_for_records=[]) | |
Get the subscriptions for this notification event. More... | |
getSubscriptionsForContainer (int $container_guid, array $methods, string $type=null, string $subtype=null, string $action=null, int $actor_guid=0) | |
Get the subscriptions for the content created inside this container. More... | |
addSubscription (int $user_guid, string $method, int $target_guid, string $type=null, string $subtype=null, string $action=null) | |
Subscribe a user to notifications about a target entity. More... | |
hasSubscription (int $user_guid, string $method, int $target_guid, string $type=null, string $subtype=null, string $action=null) | |
Check if a subscription exists. More... | |
hasSubscriptions (int $user_guid, int $target_guid, array $methods=[]) | |
Check if any subscription exists. More... | |
removeSubscription (int $user_guid, string $method, int $target_guid, string $type=null, string $subtype=null, string $action=null) | |
Unsubscribe a user to notifications about a target entity. More... | |
removeSubscriptions (int $user_guid, int $target_guid, array $methods=[]) | |
Unsubscribe a user from all notifications about the target entity. More... | |
getSubscribers (int $target_guid, array $methods=[]) | |
Get all subscribers of the target guid. More... | |
getEntitySubscriptions (int $target_guid=0, int $user_guid=0, array $methods=[], string $type=null, string $subtype=null, string $action=null) | |
Get the current subscriptions for the given entity. More... | |
muteNotifications (int $user_guid, int $target_guid) | |
Mute notifications about events affecting the target. More... | |
unmuteNotifications (int $user_guid, int $target_guid) | |
No longer nute notifications about events affecting the target. More... | |
hasMutedNotifications (int $user_guid, int $target_guid) | |
Check if the user has notifications muted about events affecting the target. More... | |
filterSubscriptions (array $subscriptions, NotificationEvent $event, bool $filter_muted=true) | |
Apply filtering to subscriptions, like muted notifications etc. More... | |
Public Attributes | |
const | RELATIONSHIP_PREFIX = 'notify' |
const | MUTE_NOTIFICATIONS_RELATIONSHIP = 'mute_notifications' |
Protected Member Functions | |
filterMutedNotifications (array $subscriptions, NotificationEvent $event) | |
Filter subscriptions based on muted notification settings related to the notification event. More... | |
filterDelayedEmailSubscribers (array $subscriptions) | |
When a user has both 'email' and 'delayed_email' subscription remove the delayed email as it would be a duplicate. More... | |
filterTimedMutedSubscribers (array $subscriptions) | |
Filter users who have set a period in which not to receive notifications. More... | |
getSubscriptionRecords (array $container_guid, array $methods, string $type=null, string $subtype=null, string $action=null, int $actor_guid=0) | |
Get subscription records from the database. More... | |
getMethodRelationships (array $methods, string $type=null, string $subtype=null, string $action=null) | |
Get the relationship names for notifications. More... | |
assertValidTypeSubtypeActionForSubscription ($type, $subtype, $action) | |
Validate subscription input for type, subtype and action. More... | |
Subscription service.
Definition at line 20 of file SubscriptionsService.php.
Elgg\Notifications\SubscriptionsService::__construct | ( | protected Database | $db, |
protected RelationshipsTable | $relationshipsTable, | ||
protected EventsService | $events | ||
) |
Constructor.
Database | $db | Database service |
RelationshipsTable | $relationshipsTable | Relationship database table |
EventsService | $events | Events service |
Definition at line 39 of file SubscriptionsService.php.
Elgg\Notifications\SubscriptionsService::addSubscription | ( | int | $user_guid, |
string | $method, | ||
int | $target_guid, | ||
string | $type = null , |
||
string | $subtype = null , |
||
string | $action = null |
||
) |
Subscribe a user to notifications about a target entity.
This method will return false if the subscription already exists.
int | $user_guid | The GUID of the user to subscribe to notifications |
string | $method | The delivery method of the notifications |
int | $target_guid | The entity to receive notifications about |
string | $type | (optional) entity type |
string | $subtype | (optional) entity subtype |
string | $action | (optional) notification action (eg. 'create') |
InvalidArgumentException |
Definition at line 176 of file SubscriptionsService.php.
|
protected |
Validate subscription input for type, subtype and action.
string | $type | entity type |
string | $subtype | entity subtype |
string | $action | notification action (eg. 'create') |
InvalidArgumentException |
Definition at line 701 of file SubscriptionsService.php.
|
protected |
When a user has both 'email' and 'delayed_email' subscription remove the delayed email as it would be a duplicate.
array | $subscriptions | List of subscribers to filter |
Definition at line 580 of file SubscriptionsService.php.
|
protected |
Filter subscriptions based on muted notification settings related to the notification event.
This filters out muted notifications based on:
array | $subscriptions | List of subscribers to filter |
NotificationEvent | $event | Notification event from which to get information |
Definition at line 532 of file SubscriptionsService.php.
Elgg\Notifications\SubscriptionsService::filterSubscriptions | ( | array | $subscriptions, |
NotificationEvent | $event, | ||
bool | $filter_muted = true |
||
) |
Apply filtering to subscriptions, like muted notifications etc.
array | $subscriptions | List of subscribers to filter |
NotificationEvent | $event | Notification event from which to get information |
bool | $filter_muted | Should the muting rules be applied to the subscriptions (default: true) |
Definition at line 501 of file SubscriptionsService.php.
|
protected |
Filter users who have set a period in which not to receive notifications.
array | $subscriptions | List of subscribers to filter |
Definition at line 600 of file SubscriptionsService.php.
Elgg\Notifications\SubscriptionsService::getEntitySubscriptions | ( | int | $target_guid = 0 , |
int | $user_guid = 0 , |
||
array | $methods = [] , |
||
string | $type = null , |
||
string | $subtype = null , |
||
string | $action = null |
||
) |
Get the current subscriptions for the given entity.
int | $target_guid | The GUID of the entity to get subscriptions for |
int | $user_guid | The GUID of the user to check subscriptions for |
string | $methods | The delivery method of the notifications |
string | $type | (optional) entity type |
string | $subtype | (optional) entity subtype |
string | $action | (optional) notification action (eg. 'create') |
InvalidArgumentException |
Definition at line 392 of file SubscriptionsService.php.
|
protected |
Get the relationship names for notifications.
array | $methods | Notification methods |
string | $type | (optional) entity type |
string | $subtype | (optional) entity subtype |
string | $action | (optional) notification action (eg. 'create') |
Definition at line 676 of file SubscriptionsService.php.
Elgg\Notifications\SubscriptionsService::getNotificationEventSubscriptions | ( | NotificationEvent | $event, |
array | $methods, | ||
array | $exclude_guids_for_records = [] |
||
) |
Get the subscriptions for this notification event.
The return array is of the form:
array( <user guid>=""> => array('email', 'sms', 'ajax'), );
NotificationEvent | $event | Notification event |
array | $methods | Notification methods |
array | $exclude_guids_for_records | GUIDs to exclude from fetching subscription records |
Definition at line 61 of file SubscriptionsService.php.
Elgg\Notifications\SubscriptionsService::getSubscribers | ( | int | $target_guid, |
array | $methods = [] |
||
) |
Get all subscribers of the target guid.
int | $target_guid | the entity of the subscriptions |
array | $methods | (optional) The delivery method of the notifications |
Definition at line 351 of file SubscriptionsService.php.
|
protected |
Get subscription records from the database.
Records are an object with two vars: guid and methods with the latter being a comma-separated list of subscription relationship names.
int[] | $container_guid The GUID of the subscription target | |
array | $methods | Notification methods |
string | $type | (optional) entity type |
string | $subtype | (optional) entity subtype |
string | $action | (optional) notification action (eg. 'create') |
int | $actor_guid | (optional) Notification event actor to exclude from the database subscriptions |
Definition at line 640 of file SubscriptionsService.php.
Elgg\Notifications\SubscriptionsService::getSubscriptionsForContainer | ( | int | $container_guid, |
array | $methods, | ||
string | $type = null , |
||
string | $subtype = null , |
||
string | $action = null , |
||
int | $actor_guid = 0 |
||
) |
Get the subscriptions for the content created inside this container.
The return array is of the form:
array( <user guid>=""> => array('email', 'sms', 'ajax'), );
int | $container_guid | GUID of the entity acting as a container |
array | $methods | Notification methods |
string | $type | (optional) entity type |
string | $subtype | (optional) entity subtype |
string | $action | (optional) notification action (eg. 'create') |
int | $actor_guid | (optional) Notification event actor to exclude from the database subscriptions |
Definition at line 131 of file SubscriptionsService.php.
Elgg\Notifications\SubscriptionsService::hasMutedNotifications | ( | int | $user_guid, |
int | $target_guid | ||
) |
Check if the user has notifications muted about events affecting the target.
int | $user_guid | The GUID of the user to check muted notifcations for |
int | $target_guid | The GUID of the entity to for which to check muted notifications |
Definition at line 488 of file SubscriptionsService.php.
Elgg\Notifications\SubscriptionsService::hasSubscription | ( | int | $user_guid, |
string | $method, | ||
int | $target_guid, | ||
string | $type = null , |
||
string | $subtype = null , |
||
string | $action = null |
||
) |
Check if a subscription exists.
int | $user_guid | The GUID of the user to check subscriptions for |
string | $method | The delivery method of the notifications |
int | $target_guid | The entity to receive notifications about |
string | $type | (optional) entity type |
string | $subtype | (optional) entity subtype |
string | $action | (optional) notification action (eg. 'create') |
InvalidArgumentException |
Definition at line 220 of file SubscriptionsService.php.
Elgg\Notifications\SubscriptionsService::hasSubscriptions | ( | int | $user_guid, |
int | $target_guid, | ||
array | $methods = [] |
||
) |
Check if any subscription exists.
int | $user_guid | The GUID of the user to check subscriptions for |
int | $target_guid | The entity to receive notifications about |
array | $methods | The delivery method of the notifications |
Definition at line 248 of file SubscriptionsService.php.
Elgg\Notifications\SubscriptionsService::muteNotifications | ( | int | $user_guid, |
int | $target_guid | ||
) |
Mute notifications about events affecting the target.
int | $user_guid | The GUID of the user to mute notifications for |
int | $target_guid | The GUID of the entity to for which to mute notifications |
Definition at line 456 of file SubscriptionsService.php.
Elgg\Notifications\SubscriptionsService::removeSubscription | ( | int | $user_guid, |
string | $method, | ||
int | $target_guid, | ||
string | $type = null , |
||
string | $subtype = null , |
||
string | $action = null |
||
) |
Unsubscribe a user to notifications about a target entity.
int | $user_guid | The GUID of the user to unsubscribe to notifications |
string | $method | The delivery method of the notifications to stop |
int | $target_guid | The entity to stop receiving notifications about |
string | $type | (optional) entity type |
string | $subtype | (optional) entity subtype |
string | $action | (optional) notification action (eg. 'create') |
InvalidArgumentException |
Definition at line 290 of file SubscriptionsService.php.
Elgg\Notifications\SubscriptionsService::removeSubscriptions | ( | int | $user_guid, |
int | $target_guid, | ||
array | $methods = [] |
||
) |
Unsubscribe a user from all notifications about the target entity.
int | $user_guid | The GUID of the user to unsubscribe to notifications |
int | $target_guid | The entity to stop receiving notifications about |
array | $methods | (optional) The delivery method of the notifications to stop |
Definition at line 323 of file SubscriptionsService.php.
Elgg\Notifications\SubscriptionsService::unmuteNotifications | ( | int | $user_guid, |
int | $target_guid | ||
) |
No longer nute notifications about events affecting the target.
int | $user_guid | The GUID of the user to unmute notifcations for |
int | $target_guid | The GUID of the entity to for which to unmute notifications |
Definition at line 476 of file SubscriptionsService.php.
const Elgg\Notifications\SubscriptionsService::MUTE_NOTIFICATIONS_RELATIONSHIP = 'mute_notifications' |
Definition at line 30 of file SubscriptionsService.php.
const Elgg\Notifications\SubscriptionsService::RELATIONSHIP_PREFIX = 'notify' |
Definition at line 25 of file SubscriptionsService.php.