Elgg  Version 3.0
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Elgg\Notifications\SubscriptionsService Class Reference

WARNING: API IN FLUX. More...

Public Member Functions

 __construct (Database $db, array $methods=[])
 Constructor. More...
 
 getSubscriptions (NotificationEvent $event)
 Get the subscriptions for this notification event. More...
 
 getSubscriptionsForContainer ($container_guid)
 Get the subscriptions for the content created inside this container. More...
 
 addSubscription ($userGuid, $method, $targetGuid)
 Subscribe a user to notifications about a target entity. More...
 
 removeSubscription ($userGuid, $method, $targetGuid)
 Unsubscribe a user to notifications about a target entity. More...
 

Public Attributes

const RELATIONSHIP_PREFIX = 'notify'
 Elgg has historically stored subscriptions as relationships with the prefix 'notify'. More...
 
 $methods
 

Protected Member Functions

 getSubscriptionRecords ($container_guid)
 Get subscription records from the database. More...
 
 getMethodRelationships ()
 Get the relationship names for notifications. More...
 

Protected Attributes

 $db
 

Detailed Description

WARNING: API IN FLUX.

DO NOT USE DIRECTLY.

Definition at line 16 of file SubscriptionsService.php.

Constructor & Destructor Documentation

Elgg\Notifications\SubscriptionsService::__construct ( Database  $db,
array  $methods = [] 
)

Constructor.

Parameters
Database$dbDatabase object
array$methodsNotification delivery method names

Definition at line 38 of file SubscriptionsService.php.

Member Function Documentation

Elgg\Notifications\SubscriptionsService::addSubscription (   $userGuid,
  $method,
  $targetGuid 
)

Subscribe a user to notifications about a target entity.

This method will return false if the subscription already exists.

Parameters
int$userGuidThe GUID of the user to subscribe to notifications
string$methodThe delivery method of the notifications
int$targetGuidThe entity to receive notifications about
Returns
boolean

Definition at line 125 of file SubscriptionsService.php.

Elgg\Notifications\SubscriptionsService::getMethodRelationships ( )
protected

Get the relationship names for notifications.

Returns
array

Definition at line 180 of file SubscriptionsService.php.

Elgg\Notifications\SubscriptionsService::getSubscriptionRecords (   $container_guid)
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.

Parameters
int$container_guidThe GUID of the subscription target
Returns
array

Definition at line 155 of file SubscriptionsService.php.

Elgg\Notifications\SubscriptionsService::getSubscriptions ( NotificationEvent  $event)

Get the subscriptions for this notification event.

The return array is of the form:

array( <user guid>=""> => array('email', 'sms', 'ajax'), );

Parameters
NotificationEvent$eventNotification event
Returns
array

Definition at line 55 of file SubscriptionsService.php.

Elgg\Notifications\SubscriptionsService::getSubscriptionsForContainer (   $container_guid)

Get the subscriptions for the content created inside this container.

The return array is of the form:

array( <user guid>=""> => array('email', 'sms', 'ajax'), );

Parameters
int$container_guidGUID of the entity acting as a container
Returns
array User GUIDs (keys) and their subscription types (values).

Definition at line 97 of file SubscriptionsService.php.

Elgg\Notifications\SubscriptionsService::removeSubscription (   $userGuid,
  $method,
  $targetGuid 
)

Unsubscribe a user to notifications about a target entity.

Parameters
int$userGuidThe GUID of the user to unsubscribe to notifications
string$methodThe delivery method of the notifications to stop
int$targetGuidThe entity to stop receiving notifications about
Returns
boolean

Definition at line 141 of file SubscriptionsService.php.

Member Data Documentation

Elgg\Notifications\SubscriptionsService::$db
protected

Definition at line 30 of file SubscriptionsService.php.

Elgg\Notifications\SubscriptionsService::$methods

Definition at line 27 of file SubscriptionsService.php.

const Elgg\Notifications\SubscriptionsService::RELATIONSHIP_PREFIX = 'notify'

Elgg has historically stored subscriptions as relationships with the prefix 'notify'.

Definition at line 21 of file SubscriptionsService.php.


The documentation for this class was generated from the following file: