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;
202 $recipient =
$message->getRecipient();
208 if (!$recipient || !$recipient->email) {
212 $to = $recipient->email;
216 if (!($sender instanceof \
ElggUser) && $sender->email) {
217 $from = $sender->email;
218 }
else if (
$site->email) {
219 $from =
$site->email;
222 $from =
'noreply@' .
$site->getDomain();
239 function _elgg_notifications_smtp_thread_headers($hook,
$type, $returnvalue,
$params) {
241 $notificationParams =
elgg_extract(
'params', $returnvalue, array());
243 $notification =
elgg_extract(
'notification', $notificationParams);
245 if (!($notification instanceof \
Elgg\Notifications\Notification)) {
257 if ($event->getAction() ===
'create') {
260 $messageId =
"<{$urlPath}.entity.{$object->guid}@{$hostname}>";
262 $mt = microtime(
true);
263 $messageId =
"<{$urlPath}.entity.{$object->guid}.$mt@{$hostname}>";
265 $returnvalue[
'headers'][
"Message-ID"] = $messageId;
271 $threadMessageId =
"<{$urlPath}.entity.{$container->guid}@{$hostname}>";
272 $returnvalue[
'headers'][
'In-Reply-To'] = $threadMessageId;
273 $returnvalue[
'headers'][
'References'] = $threadMessageId;
293 elgg_extend_view(
'forms/account/settings',
'core/settings/account/notifications');
317 if (!is_array($to)) {
318 $to = array((
int)$to);
324 if (($methods_override) && (!is_array($methods_override))) {
325 $methods_override = array($methods_override);
330 foreach ($to as
$guid) {
336 $methods = $methods_override;
341 if (is_object($tmp)) {
342 foreach ($tmp as $k => $v) {
353 foreach ($methods as
$method) {
355 $handler = $notify_service->getDeprecatedHandler($method);
358 elgg_log(
"No handler registered for the method $method",
'WARNING');
362 elgg_log(
"Sending message to $guid using $method");
374 error_log($e->getMessage());
436 if (!is_array($to)) {
437 $to = array((
int)$to);
445 if (($methods_override) && (!is_array($methods_override))) {
446 $methods_override = array($methods_override);
451 $available_methods =
_elgg_services()->notifications->getMethods();
452 if (!$available_methods) {
460 $event = new \Elgg\Notifications\Event(
$params[
'object'],
$params[
'action'], $sender);
464 foreach ($to as
$guid) {
470 $methods = $methods_override;
474 foreach ($tmp as $k => $v) {
484 foreach ($methods as
$method) {
485 if (!in_array($method, $available_methods)) {
491 if (
_elgg_services()->hooks->hasHandler(
'send',
"notification:$method")) {
499 $params[
'notification'] = $notification;
533 $prefix =
"notification:method:";
536 foreach ($all_metadata as $meta) {
537 $name = substr($meta->name, strlen($prefix));
540 if (strpos($meta->name, $prefix) === 0) {
570 $prefix =
"notification:method:$method";
597 $msg =
"Missing a required parameter, '" .
'from' .
"'";
598 throw new \NotificationException($msg);
602 $msg =
"Missing a required parameter, '" .
'to' .
"'";
603 throw new \NotificationException($msg);
607 "Content-Type" =>
"text/plain; charset=UTF-8; format=flowed",
608 "MIME-Version" =>
"1.0",
609 "Content-Transfer-Encoding" =>
"8bit",
613 $mail_params = array(
627 foreach (array(
'to',
'from',
'subject',
'body',
'headers') as
$key) {
636 $header_eol =
"\r\n";
637 if (isset($CONFIG->broken_mta) && $CONFIG->broken_mta) {
643 if (strtolower(substr(PHP_OS, 0, 3)) ==
'win') {
645 if (strpos($to,
'<')) {
646 preg_match(
'/<(.*)>/', $to, $matches);
649 if (strpos($from,
'<')) {
650 preg_match(
'/<(.*)>/', $from, $matches);
661 $headers_string =
'';
663 $headers_string .=
"$key: $value{$header_eol}";
670 if (is_callable(
'mb_encode_mimeheader')) {
675 $body = html_entity_decode(
$body, ENT_QUOTES,
'UTF-8');
677 $body = preg_replace(
"/(\r\n|\r)/",
"\n",
$body);
678 $body = preg_replace(
"/^From/",
">From",
$body);
696 foreach (
$method as $k => $v) {
698 if ($current_settings->$k == ($v ==
'yes')) {
719 $tests[] =
"{$CONFIG->path}engine/tests/ElggCoreDatabaseQueueTest.php";
724 $events->registerHandler(
'init',
'system',
'_elgg_notifications_init');
726 $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_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)
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)
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)
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']
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.