78 return _elgg_services()->notifications->unregisterEvent($object_type, $object_subtype);
137 $subs = new \Elgg\Notifications\SubscriptionsService($db, $methods);
153 $subs = new \Elgg\Notifications\SubscriptionsService($db, $methods);
174 $subs = new \Elgg\Notifications\SubscriptionsService($db, $methods);
203 $stop_time =
time() + 45;
228 $recipient =
$message->getRecipient();
234 if (!$recipient || !$recipient->email) {
238 $to = $recipient->email;
242 if (!($sender instanceof \
ElggUser) && $sender->email) {
243 $from = $sender->email;
244 }
else if (
$site->email) {
245 $from =
$site->email;
249 $from =
"noreply-{$token}@{$site->getDomain()}";
271 if (!is_array($returnvalue) || !is_array($returnvalue[
'params'])) {
279 $mt = microtime(
true);
281 $returnvalue[
'headers'][
'Message-ID'] =
"{$url_path}.default.{$mt}@{$hostname}";
296 function _elgg_notifications_smtp_thread_headers($hook,
$type, $returnvalue,
$params) {
298 if (!is_array($returnvalue) || !is_array($returnvalue[
'params'])) {
303 $notificationParams =
elgg_extract(
'params', $returnvalue, array());
305 $notification =
elgg_extract(
'notification', $notificationParams);
307 if (!($notification instanceof \
Elgg\Notifications\Notification)) {
319 if ($event->getAction() ===
'create') {
322 $messageId =
"{$urlPath}.entity.{$object->guid}@{$hostname}";
324 $mt = microtime(
true);
325 $messageId =
"{$urlPath}.entity.{$object->guid}.$mt@{$hostname}";
327 $returnvalue[
'headers'][
"Message-ID"] = $messageId;
333 $threadMessageId =
"<{$urlPath}.entity.{$container->guid}@{$hostname}>";
334 $returnvalue[
'headers'][
'In-Reply-To'] = $threadMessageId;
335 $returnvalue[
'headers'][
'References'] = $threadMessageId;
356 elgg_extend_view(
'forms/account/settings',
'core/settings/account/notifications');
380 if (!is_array($to)) {
381 $to = array((
int) $to);
386 if (($methods_override) && (!is_array($methods_override))) {
387 $methods_override = array($methods_override);
392 foreach ($to as
$guid) {
398 $methods = $methods_override;
403 if (is_object($tmp)) {
404 foreach ($tmp as $k => $v) {
415 foreach ($methods as
$method) {
417 $handler = $notify_service->getDeprecatedHandler($method);
420 elgg_log(
"No handler registered for the method $method",
'WARNING');
424 elgg_log(
"Sending message to $guid using $method");
437 error_log($e->getMessage());
499 $params[
'methods_override'] = $methods_override;
512 foreach ($to as
$guid) {
517 $recipients[] = $recipient;
533 elgg_deprecated_notice(__FUNCTION__ .
' has been deprecated by ElggUser::getNotificationSettings()',
'2.3');
544 return (
object)
$user->getNotificationSettings();
558 elgg_deprecated_notice(__FUNCTION__ .
' has been deprecated by ElggUser::setNotificationSetting()',
'2.3');
595 $msg =
"Missing a required parameter, '" .
'from' .
"'";
596 throw new \NotificationException($msg);
600 $msg =
"Missing a required parameter, '" .
'to' .
"'";
601 throw new \NotificationException($msg);
605 "Content-Type" =>
"text/plain; charset=UTF-8; format=flowed",
606 "MIME-Version" =>
"1.0",
607 "Content-Transfer-Encoding" =>
"8bit",
611 $mail_params = array(
631 $to_address = Address::fromString(
$result[
'to']);
632 $from_address = Address::fromString(
$result[
'from']);
642 $body = html_entity_decode(
$body, ENT_QUOTES,
'UTF-8');
652 foreach (
$result[
'headers'] as $headerName => $headerValue) {
656 $message->getHeaders()->addHeaderLine(
"{$headerName}: {$headerValue}");
684 $current_settings =
$user->getNotificationSettings();
687 foreach (
$method as $k => $v) {
689 if ($current_settings[$k] == ($v ==
'yes')) {
693 $result =
$user->setNotificationSetting($k, ($v ==
'yes'));
709 $tests[] =
"{$CONFIG->path}engine/tests/ElggCoreDatabaseQueueTest.php";
714 $events->registerHandler(
'init',
'system',
'_elgg_notifications_init');
716 $hooks->registerHandler(
'unit_test',
'system',
'_elgg_notifications_test');
$object
These two snippets demonstrates triggering an event and how to register for that event.
elgg_get_site_entity($site_guid=0)
Get an entity (default is current site)
elgg_register_notification_method($name)
Register a delivery method for notifications.
if($guid==elgg_get_logged_in_user_guid()) $name
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
elgg_strip_tags($string, $allowable_tags=null)
Strip tags and offer plugins the chance.
_elgg_notifications_cron()
private
elgg_unregister_notification_event($object_type, $object_subtype)
Unregister a notification event.
_elgg_enqueue_notification_event($action, $type, $object)
Queue a notification event for later handling.
$guid
Removes an admin notice.
elgg parse_url
Parse a URL into its parts.
elgg_register_plugin_hook_handler($hook, $type, $callback, $priority=500)
elgg_remove_subscription($user_guid, $method, $target_guid)
Unsubscribe a user to notifications about a target entity.
elgg_get_subscriptions_for_container($container_guid)
Get the subscriptions for the content created inside this container.
_elgg_notifications_init()
private
_elgg_save_notification_user_settings()
Save personal notification settings - input comes from request.
elgg_unregister_notification_method($name)
Unregister a delivery method for notifications.
notify_user($to, $from=0, $subject= '', $message= '', array $params=array(), $methods_override=null)
Notify a user via their preferences.
_elgg_notifications_smtp_default_message_id_header($hook, $type, $returnvalue, $params)
Adds default Message-ID header to all e-mails.
set_user_notification_setting($user_guid, $method, $value)
Set a user notification pref.
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
elgg global
Pointer to the global context.
elgg_get_site_url($site_guid=0)
Get the URL for the current (or specified) site.
elgg_extend_view($view, $view_extension, $priority=501)
Extends a view with another view.
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
elgg system_message
Wrapper function for system_messages.
elgg_register_event_handler($event, $object_type, $callback, $priority=500)
elgg_log($message, $level= 'NOTICE')
Display or log a message.
_elgg_send_email_notification($hook, $type, $result, $params)
Send an email notification.
_elgg_notifications_test($hook, $type, $tests)
private
elgg_add_subscription($user_guid, $method, $target_guid)
Subscribe a user to notifications about a target entity.
elgg_register_notification_event($object_type, $object_subtype, array $actions=array())
Register a notification event.
elgg register_error
Wrapper function for system_messages.
elgg_get_logged_in_user_entity()
Return the current logged in user, or null if no user is logged in.
elgg_get_notification_methods()
Returns registered delivery methods for notifications [ 'email' => 'email', 'sms' => 'sms'...
$user_guid
Avatar remove action.
get_user_notification_settings($user_guid=0)
Get the notification settings for a given user.
elgg_send_email($from, $to, $subject, $body, array $params=null)
Send an email to any email address.
http free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
elgg_get_logged_in_user_guid()
Return the current logged in user by guid.
_elgg_notify_user($to, $from, $subject, $message, array $params=null, $methods_override="")
Notify a user via their preferences.
get_entity($guid)
Loads and returns an entity object from a guid.