74 return _elgg_services()->notifications->unregisterEvent($object_type, $object_subtype);
117 $subs = new \Elgg\Notifications\SubscriptionsService($db, $methods);
133 $subs = new \Elgg\Notifications\SubscriptionsService($db, $methods);
154 $subs = new \Elgg\Notifications\SubscriptionsService($db, $methods);
183 $stop_time = time() + 45;
208 $recipient =
$message->getRecipient();
214 if (!$recipient || !$recipient->email) {
218 $to = $recipient->email;
222 if (!($sender instanceof \
ElggUser) && $sender->email) {
223 $from = $sender->email;
224 }
else if (
$site->email) {
225 $from =
$site->email;
228 $from =
'noreply@' .
$site->getDomain();
250 if (!is_array($returnvalue) || !is_array($returnvalue[
'params'])) {
258 $mt = microtime(
true);
260 $returnvalue[
'headers'][
'Message-ID'] =
"<{$url_path}.default.{$mt}@{$hostname}>";
275 function _elgg_notifications_smtp_thread_headers($hook,
$type, $returnvalue,
$params) {
277 if (!is_array($returnvalue) || !is_array($returnvalue[
'params'])) {
282 $notificationParams =
elgg_extract(
'params', $returnvalue, array());
284 $notification =
elgg_extract(
'notification', $notificationParams);
286 if (!($notification instanceof \
Elgg\Notifications\Notification)) {
298 if ($event->getAction() ===
'create') {
301 $messageId =
"<{$urlPath}.entity.{$object->guid}@{$hostname}>";
303 $mt = microtime(
true);
304 $messageId =
"<{$urlPath}.entity.{$object->guid}.$mt@{$hostname}>";
306 $returnvalue[
'headers'][
"Message-ID"] = $messageId;
312 $threadMessageId =
"<{$urlPath}.entity.{$container->guid}@{$hostname}>";
313 $returnvalue[
'headers'][
'In-Reply-To'] = $threadMessageId;
314 $returnvalue[
'headers'][
'References'] = $threadMessageId;
335 elgg_extend_view(
'forms/account/settings',
'core/settings/account/notifications');
359 if (!is_array($to)) {
360 $to = array((
int)$to);
366 if (($methods_override) && (!is_array($methods_override))) {
367 $methods_override = array($methods_override);
372 foreach ($to as
$guid) {
378 $methods = $methods_override;
383 if (is_object($tmp)) {
384 foreach ($tmp as $k => $v) {
395 foreach ($methods as
$method) {
397 $handler = $notify_service->getDeprecatedHandler($method);
400 elgg_log(
"No handler registered for the method $method",
'WARNING');
404 elgg_log(
"Sending message to $guid using $method");
416 error_log($e->getMessage());
478 if (!is_array($to)) {
479 $to = array((
int)$to);
487 if (($methods_override) && (!is_array($methods_override))) {
488 $methods_override = array($methods_override);
493 $available_methods =
_elgg_services()->notifications->getMethods();
494 if (!$available_methods) {
502 $event = new \Elgg\Notifications\Event(
$params[
'object'],
$params[
'action'], $sender);
506 foreach ($to as
$guid) {
512 $methods = $methods_override;
516 foreach ($tmp as $k => $v) {
526 foreach ($methods as
$method) {
527 if (!in_array($method, $available_methods)) {
533 if (
_elgg_services()->hooks->hasHandler(
'send',
"notification:$method")) {
541 $params[
'notification'] = $notification;
575 $prefix =
"notification:method:";
578 foreach ($all_metadata as $meta) {
579 $name = substr($meta->name, strlen($prefix));
582 if (strpos($meta->name, $prefix) === 0) {
612 $prefix =
"notification:method:$method";
639 $msg =
"Missing a required parameter, '" .
'from' .
"'";
640 throw new \NotificationException($msg);
644 $msg =
"Missing a required parameter, '" .
'to' .
"'";
645 throw new \NotificationException($msg);
649 "Content-Type" =>
"text/plain; charset=UTF-8; format=flowed",
650 "MIME-Version" =>
"1.0",
651 "Content-Transfer-Encoding" =>
"8bit",
655 $mail_params = array(
669 foreach (array(
'to',
'from',
'subject',
'body',
'headers') as
$key) {
678 $header_eol =
"\r\n";
679 if (isset($CONFIG->broken_mta) && $CONFIG->broken_mta) {
685 if (strtolower(substr(PHP_OS, 0, 3)) ==
'win') {
687 if (strpos($to,
'<')) {
688 preg_match(
'/<(.*)>/', $to, $matches);
691 if (strpos($from,
'<')) {
692 preg_match(
'/<(.*)>/', $from, $matches);
703 $headers_string =
'';
705 $headers_string .=
"$key: $value{$header_eol}";
712 if (is_callable(
'mb_encode_mimeheader')) {
717 $body = html_entity_decode(
$body, ENT_QUOTES,
'UTF-8');
719 $body = preg_replace(
"/(\r\n|\r)/",
"\n",
$body);
720 $body = preg_replace(
"/^From/",
">From",
$body);
738 foreach (
$method as $k => $v) {
740 if ($current_settings->$k == ($v ==
'yes')) {
761 $tests[] =
"{$CONFIG->path}engine/tests/ElggCoreDatabaseQueueTest.php";
766 $events->registerHandler(
'init',
'system',
'_elgg_notifications_init');
768 $hooks->registerHandler(
'unit_test',
'system',
'_elgg_notifications_test');
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_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.
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
sanitise_string($string)
Wrapper function for alternate English spelling (.
elgg_extend_view($view, $view_extension, $priority=501, $viewtype= '')
Extends a view with another view.
_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_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
elgg global
Pointer to the global context.
elgg_get_site_url($site_guid=0)
Get the URL for the current (or specified) site.
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.
notify_user($to, $from, $subject, $message, array $params=array(), $methods_override="")
Notify a user via their preferences.
elgg_get_logged_in_user_entity()
Return the current logged in user, or null if no user is logged in.
$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.
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.