function notifications_process_digest_long in Notifications 6.2
Same name and namespace in other branches
- 5 notifications.cron.inc \notifications_process_digest_long()
- 6 notifications.cron.inc \notifications_process_digest_long()
Digest multiple events in a single message, long format.
We use digest templates for subject, header, footer digest-subject digest-header digest-footer but the regular templates for the message body for each event event-[type]-[action]-main or event-[type]-main or event-main
Return value
array with messages ready to be sent
1 string reference to 'notifications_process_digest_long'
- notifications_notifications in ./
notifications.module - Implementation of notifications_hook()
File
- ./
notifications.cron.inc, line 847
Code
function notifications_process_digest_long($account, $events, $subscriptions, $send_interval, $send_method, $module = 'notifications') {
// Build the message body as an array of event notifications
$body = array();
// Build up the digested list with text replacement, body as big array
// We need text replacement for each line because it depends on different objects
foreach ($events as $event) {
notifications_log('Digesting long format', array(
'event' => $event,
));
// We use the regular template for the events
$part = array();
$part[] = notifications_message_part('event', 'subject', $send_method, $event, $module);
$part[] = notifications_message_part('event', 'main', $send_method, $event, $module);
// Pass only the first subscription here
$sid = is_array($subscriptions[$event->eid]) ? array_shift($subscriptions[$event->eid]) : 0;
$subscription = $sid ? notifications_load_subscription($sid) : NULL;
$objects = $event->objects + array(
'user' => $account,
'subscription' => $subscription,
'event' => $event,
);
$body = array_merge($body, messaging_text_replace($part, $objects));
}
// Create message. Do all this in one replacement, then strip out the subject
$text['subject'] = notifications_message_part('digest', 'subject', $send_method, NULL, $module);
$text['header'] = notifications_message_part('digest', 'header', $send_method, NULL, $module);
$text['footer'] = notifications_message_part('digest', 'footer', $send_method, NULL, $module);
// We dont pass a subscription object here, won't be too much use anyway
$text = messaging_text_replace($text, array(
'user' => $account,
'subscription' => NULL,
));
// Compose body. All these lines have been text replaced, chance for theming
$body = theme('notifications_digest_long_body', $text['header'], $body, $text['footer']);
// Build the final digested message, and return in an array
$message = array(
'subject' => $text['subject'],
'body' => $body,
'events' => $events,
'subscriptions' => $subscriptions,
'digest' => 'long',
);
return array(
$message,
);
}