Elgg  Version 6.1
Functions
notification.php File Reference

Go to the source code of this file.

Functions

 elgg_register_notification_event (string $object_type, string $object_subtype, array $actions=[], string $handler=NotificationEventHandler::class)
 Register a notification event. More...
 
 elgg_unregister_notification_event (string $object_type, string $object_subtype, array $actions=[])
 Unregister a notification event. More...
 
 elgg_register_notification_method (string $name)
 Register a delivery method for notifications. More...
 
 elgg_get_notification_methods ()
 Returns registered delivery methods for notifications [ 'email' => 'email', 'sms' => 'sms', ] More...
 
 elgg_unregister_notification_method (string $name)
 Unregister a delivery method for notifications. More...
 
 elgg_get_notification_events ()
 Get the registered notification events in the format. More...
 
 elgg_get_subscriptions_for_container (int $container_guid)
 Get the subscriptions for the content created inside this container. More...
 
 notify_user (int|array $to, int $from=0, string $subject= '', string $message= '', array $params=[], $methods_override=null)
 Notify a user via their preferences. More...
 
 elgg_send_email (\Elgg\Email $email)
 Send an email to any email address. More...
 
 elgg_enqueue_notification_event (string $action,\ElggData $object,\ElggEntity $actor=null)
 Enqueue a notification event for delivery. More...
 

Function Documentation

elgg_enqueue_notification_event ( string  $action,
\ElggData  $object,
\ElggEntity  $actor = null 
)

Enqueue a notification event for delivery.

Only use this function if the default event based queueing can't be used.

Parameters
string$actionthe action of the notification event
\ElggData$objectthe object used in the notification event
\ElggEntity$actor(optional) the actor of the notification event (default: logged in user or owner of $object)
See also
elgg_register_notification_event()
Returns
void
Since
4.3

Definition at line 256 of file notification.php.

elgg_get_notification_events ( )

Get the registered notification events in the format.

array ( <type> => array ( <subtype> => array ( <action1>, <action2>, ) ) )

Returns
array
Since
4.0

Definition at line 153 of file notification.php.

elgg_get_notification_methods ( )

Returns registered delivery methods for notifications [ 'email' => 'email', 'sms' => 'sms', ]

Returns
array
Since
2.3

Definition at line 121 of file notification.php.

elgg_get_subscriptions_for_container ( int  $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).
Since
1.9

Definition at line 171 of file notification.php.

elgg_register_notification_event ( string  $object_type,
string  $object_subtype,
array  $actions = [],
string  $handler = NotificationEventHandler::class 
)

Register a notification event.

Elgg sends notifications for the items that have been registered with this function. For example, if you want notifications to be sent when a bookmark has been created or updated, call the function like this:

   elgg_register_notification_event('object', 'bookmarks', array('create', 'update'));
Parameters
string$object_type'object', 'user', 'group', 'site'
string$object_subtypeThe subtype or name of the entity
array$actionsArray of actions or empty array for the action event. An event is usually described by the first string passed to elgg_trigger_event(). Examples include 'create', 'update', and 'publish'. The default is 'create'.
string$handlerNotificationEventHandler classname
Returns
void
Since
1.9

Definition at line 73 of file notification.php.

elgg_register_notification_method ( string  $name)

Register a delivery method for notifications.

Register for the 'send', 'notification:[method name]' event to handle sending a notification. A notification object is in the params array for the event with the key 'notification'. See .

Parameters
string$nameThe notification method name
Returns
void
See also
elgg_unregister_notification_method()
Since
1.9

Definition at line 105 of file notification.php.

elgg_send_email ( \Elgg\Email  $email)

Send an email to any email address.

Parameters
\Elgg\Email$emailEmail
Returns
bool
Since
1.7.2

Definition at line 239 of file notification.php.

elgg_unregister_notification_event ( string  $object_type,
string  $object_subtype,
array  $actions = [] 
)

Unregister a notification event.

Parameters
string$object_type'object', 'user', 'group', 'site'
string$object_subtypeThe type of the entity
array$actionsThe notification action to unregister, leave empty for all actions. Example ('create', 'delete', 'publish')
Returns
void
Since
1.9
See also
elgg_register_notification_event()

Definition at line 88 of file notification.php.

elgg_unregister_notification_method ( string  $name)

Unregister a delivery method for notifications.

Parameters
string$nameThe notification method name
Returns
void
See also
elgg_register_notification_method()
Since
1.9

Definition at line 134 of file notification.php.

notify_user ( int|array  $to,
int  $from = 0,
string  $subject = '',
string  $message = '',
array  $params = [],
  $methods_override = null 
)

Notify a user via their preferences.

Parameters
mixed$toEither a guid or an array of guid's to notify.
int$fromGUID of the sender, which may be a user, site or object.
string$subjectMessage subject.
string$messageMessage body.
array$paramsMisc additional parameters specific to various methods.
                            By default Elgg core supports three parameters, which give
                            notification plugins more control over the notifications:

                            object => null|\ElggEntity|\ElggAnnotation The object that is triggering the notification.

                            action => null|string Word that describes the action that is triggering the notification (e.g. "create" or "update").

                            summary => null|string Summary that notification plugins can use alongside the notification title and body.
mixed$methods_overrideA string, or an array of strings specifying the delivery methods to use - or leave blank for delivery using the user's chosen delivery methods.
Returns
array Compound array of each delivery user/delivery method's success or failure.

Definition at line 201 of file notification.php.