Elgg  Version 3.0
Namespaces | Functions | Variables
notification.php File Reference

Go to the source code of this file.

Namespaces

 Elgg\Core
 Updates the advanced settings for the primary site object.
 

Functions

 elgg_register_notification_event ($object_type, $object_subtype, array $actions=[])
 Register a notification event. More...
 
 elgg_unregister_notification_event ($object_type, $object_subtype)
 Unregister a notification event. More...
 
 elgg_register_notification_method ($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 ($name)
 Unregister a delivery method for notifications. More...
 
 elgg_add_subscription ($user_guid, $method, $target_guid)
 Subscribe a user to notifications about a target entity. More...
 
 elgg_remove_subscription ($user_guid, $method, $target_guid)
 Unsubscribe a user to notifications about a target entity. More...
 
 elgg_get_subscriptions_for_container ($container_guid)
 Get the subscriptions for the content created inside this container. More...
 
 _elgg_enqueue_notification_event ($action, $type, $object)
 Queue a notification event for later handling. More...
 
 _elgg_notifications_cron ()
 Process notification queue. More...
 
 _elgg_send_email_notification ($hook, $type, $result, $params)
 Send an email notification. More...
 
 _elgg_notifications_smtp_default_message_id_header ($hook, $type, $email)
 Adds default Message-ID header to all e-mails. More...
 
 _elgg_notifications_smtp_thread_headers ($hook, $type, $email)
 Adds default thread SMTP headers to group messages correctly. More...
 
 _elgg_notifications_init ()
 Notification init. More...
 
 _elgg_notify_user ($to, $from, $subject, $message, array $params=null, $methods_override="")
 Notify a user via their preferences. More...
 
 notify_user ($to, $from=0, $subject= '', $message= '', array $params=[], $methods_override=null)
 Notify a user via their preferences. More...
 
 elgg_send_email ($email)
 Send an email to any email address. More...
 
 elgg_set_email_transport (\Zend\Mail\Transport\TransportInterface $mailer)
 Replace default email transport. More...
 
 _elgg_save_notification_user_settings ()
 Save personal notification settings - input comes from request. More...
 
 _elgg_notifications_test ($hook, $type, $tests)
 Register unit tests. More...
 

Variables

return function (\Elgg\EventsService $events,\Elgg\HooksRegistrationService $hooks)
 

Function Documentation

_elgg_enqueue_notification_event (   $action,
  $type,
  $object 
)

Queue a notification event for later handling.

Checks to see if this event has been registered for notifications. If so, it adds the event to a notification queue.

This function triggers the 'enqueue', 'notification' hook.

Parameters
string$actionThe name of the action
string$typeThe type of the object
\ElggData$objectThe object of the event
Returns
void

Definition at line 189 of file notification.php.

_elgg_notifications_cron ( )

Process notification queue.

Returns
void

Definition at line 200 of file notification.php.

_elgg_notifications_init ( )

Notification init.

Returns
void

Definition at line 345 of file notification.php.

_elgg_notifications_smtp_default_message_id_header (   $hook,
  $type,
  $email 
)

Adds default Message-ID header to all e-mails.

Parameters
string$hook"prepare"
string$type"system:email"
\Elgg\Email$emailEmail instance
See also
https://tools.ietf.org/html/rfc5322#section-3.6.4
Returns
void|

Definition at line 263 of file notification.php.

_elgg_notifications_smtp_thread_headers (   $hook,
  $type,
  $email 
)

Adds default thread SMTP headers to group messages correctly.

Note that it won't be sufficient for some email clients. Ie. Gmail is looking at message subject anyway.

Parameters
string$hook"prepare"
string$type"system:email"
\Elgg\Email$emailEmail instance
Returns
void|

Definition at line 290 of file notification.php.

_elgg_notifications_test (   $hook,
  $type,
  $tests 
)

Register unit tests.

Parameters
string$hook'unit_test'
string$type'system'
array$testscurrent return value
Returns
array

Definition at line 624 of file notification.php.

_elgg_notify_user (   $to,
  $from,
  $subject,
  $message,
array  $params = null,
  $methods_override = "" 
)

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.
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 375 of file notification.php.

_elgg_save_notification_user_settings ( )

Save personal notification settings - input comes from request.

Returns
void

Definition at line 583 of file notification.php.

_elgg_send_email_notification (   $hook,
  $type,
  $result,
  $params 
)

Send an email notification.

Parameters
string$hookHook name
string$typeHook type
bool$resultHas anyone sent a message yet?
array$paramsHook parameters
Returns
bool

Definition at line 217 of file notification.php.

elgg_add_subscription (   $user_guid,
  $method,
  $target_guid 
)

Subscribe a user to notifications about a target entity.

Parameters
int$user_guidThe GUID of the user to subscribe to notifications
string$methodThe delivery method of the notifications
int$target_guidThe entity to receive notifications about
Returns
bool
Since
1.9

Definition at line 130 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 105 of file notification.php.

elgg_get_subscriptions_for_container (   $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 167 of file notification.php.

elgg_register_notification_event (   $object_type,
  $object_subtype,
array  $actions = [] 
)

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'.
Returns
void
Since
1.9

Definition at line 61 of file notification.php.

elgg_register_notification_method (   $name)

Register a delivery method for notifications.

Register for the 'send', 'notification:[method name]' plugin hook to handle sending a notification. A notification object is in the params array for the hook 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 89 of file notification.php.

elgg_remove_subscription (   $user_guid,
  $method,
  $target_guid 
)

Unsubscribe a user to notifications about a target entity.

Parameters
int$user_guidThe GUID of the user to unsubscribe to notifications
string$methodThe delivery method of the notifications to stop
int$target_guidThe entity to stop receiving notifications about
Returns
bool
Since
1.9

Definition at line 146 of file notification.php.

elgg_send_email (   $email)

Send an email to any email address.

Parameters
\Elgg\Email$emailEmail
Returns
bool
Since
1.7.2

Definition at line 542 of file notification.php.

elgg_set_email_transport ( \Zend\Mail\Transport\TransportInterface  $mailer)

Replace default email transport.

Note
If you are replacing the transport persistently, e.g. on each page request via a plugin, avoid using plugin settings to store transport configuration, as it may be expensive to fetch these settings. Instead, configure the transport via elgg-config/settings.php or use site config DB storage.
Parameters
\Zend\Mail\Transport\TransportInterface$mailerTransport
Returns
void

Definition at line 573 of file notification.php.

elgg_unregister_notification_event (   $object_type,
  $object_subtype 
)

Unregister a notification event.

Parameters
string$object_type'object', 'user', 'group', 'site'
string$object_subtypeThe type of the entity
Returns
bool
Since
1.9

Definition at line 73 of file notification.php.

elgg_unregister_notification_method (   $name)

Unregister a delivery method for notifications.

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

Definition at line 117 of file notification.php.

notify_user (   $to,
  $from = 0,
  $subject = '',
  $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.
Exceptions
NotificationException

Definition at line 507 of file notification.php.

Variable Documentation

See also
::loadCore Do not do work here. Just register for events.

Definition at line 632 of file notification.php.