72 return _elgg_services()->notifications->unregisterEvent($object_type, $object_subtype);
153 return $subs->getSubscriptionsForContainer($container_guid);
181 $stop_time = time() + 45;
200 $recipient =
$message->getRecipient();
206 if (!$recipient || !$recipient->email) {
210 $to = $recipient->email;
214 if (!($sender instanceof
ElggUser) && $sender->email) {
215 $from = $sender->email;
216 }
else if (
$site->email) {
217 $from =
$site->email;
220 $from =
'noreply@' .
$site->getDomain();
237 function _elgg_notifications_smtp_thread_headers($hook,
$type, $returnvalue,
$params) {
239 $notificationParams =
elgg_extract(
'params', $returnvalue, array());
241 $notification =
elgg_extract(
'notification', $notificationParams);
255 if ($event->getAction() ===
'create') {
258 $messageId =
"<{$urlPath}.entity.{$object->guid}@{$hostname}>";
260 $mt = microtime(
true);
261 $messageId =
"<{$urlPath}.entity.{$object->guid}.$mt@{$hostname}>";
263 $returnvalue[
'headers'][
"Message-ID"] = $messageId;
269 $threadMessageId =
"<{$urlPath}.entity.{$container->guid}@{$hostname}>";
270 $returnvalue[
'headers'][
'In-Reply-To'] = $threadMessageId;
271 $returnvalue[
'headers'][
'References'] = $threadMessageId;
291 elgg_extend_view(
'forms/account/settings',
'core/settings/account/notifications');
319 if (!is_array($to)) {
320 $to = array((
int)$to);
326 if (($methods_override) && (!is_array($methods_override))) {
327 $methods_override = array($methods_override);
332 foreach ($to as
$guid) {
338 $methods = $methods_override;
343 if (is_object($tmp)) {
344 foreach ($tmp as $k => $v) {
355 foreach ($methods as
$method) {
357 $handler = $notify_service->getDeprecatedHandler($method);
360 error_log(
"No handler registered for the method $method",
'WARNING');
364 elgg_log(
"Sending message to $guid using $method");
375 }
catch (Exception
$e) {
376 error_log($e->getMessage());
438 if (!is_array($to)) {
439 $to = array((
int)$to);
447 if (($methods_override) && (!is_array($methods_override))) {
448 $methods_override = array($methods_override);
453 $available_methods =
_elgg_services()->notifications->getMethods();
454 if (!$available_methods) {
466 foreach ($to as
$guid) {
472 $methods = $methods_override;
476 foreach ($tmp as $k => $v) {
486 foreach ($methods as
$method) {
487 if (!in_array($method, $available_methods)) {
493 if (
_elgg_services()->hooks->hasHandler(
'send',
"notification:$method")) {
501 $params[
'notification'] = $notification;
535 $prefix =
"notification:method:";
538 foreach ($all_metadata as $meta) {
539 $name = substr($meta->name, strlen($prefix));
542 if (strpos($meta->name, $prefix) === 0) {
572 $prefix =
"notification:method:$method";
599 $msg =
"Missing a required parameter, '" .
'from' .
"'";
604 $msg =
"Missing a required parameter, '" .
'to' .
"'";
609 "Content-Type" =>
"text/plain; charset=UTF-8; format=flowed",
610 "MIME-Version" =>
"1.0",
611 "Content-Transfer-Encoding" =>
"8bit",
615 $mail_params = array(
629 foreach (array(
'to',
'from',
'subject',
'body',
'headers') as
$key) {
638 $header_eol =
"\r\n";
639 if (isset($CONFIG->broken_mta) && $CONFIG->broken_mta) {
645 if (strtolower(substr(PHP_OS, 0, 3)) ==
'win') {
647 if (strpos($to,
'<')) {
648 preg_match(
'/<(.*)>/', $to, $matches);
651 if (strpos($from,
'<')) {
652 preg_match(
'/<(.*)>/', $from, $matches);
663 $headers_string =
'';
665 $headers_string .=
"$key: $value{$header_eol}";
672 if (is_callable(
'mb_encode_mimeheader')) {
677 $body = html_entity_decode(
$body, ENT_QUOTES,
'UTF-8');
679 $body = preg_replace(
"/(\r\n|\r)/",
"\n",
$body);
680 $body = preg_replace(
"/^From/",
">From",
$body);
698 foreach (
$method as $k => $v) {
700 if ($current_settings->$k == ($v ==
'yes')) {
721 $tests[] =
"{$CONFIG->path}engine/tests/ElggCoreDatabaseQueueTest.php";
elgg_get_site_entity($site_guid=0)
Get an ElggSite 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_extract($key, array $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
elgg_register_plugin_hook_handler($hook, $type, $callback, $priority=500)
Register a callback as a plugin hook handler.
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.
set_user_notification_setting($user_guid, $method, $value)
Set a user notification pref.
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
Trigger a Plugin Hook and run all handler callbacks registered to that hook:type. ...
elgg global
Pointer to the global context.
elgg_get_site_url($site_guid=0)
Get the URL for the current (or specified) site.
elgg system_message
Wrapper function for system_messages.
elgg_register_event_handler($event, $object_type, $callback, $priority=500)
Register a callback as an Elgg event handler.
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.
$language
$vars['language'] $vars['lc'] if present, client will be sent long expires headers ...
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.
$actions
Provides common Elgg services.
_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.