function notifications_process_digest_short in Notifications 5
Same name and namespace in other branches
- 6 notifications.cron.inc \notifications_process_digest_short()
- 6.2 notifications.cron.inc \notifications_process_digest_short()
Digest multiple events in a single message, short format.
Return value
array with messages ready to be sent
1 string reference to 'notifications_process_digest_short'
- notifications_notifications in ./
notifications.module - Implementation of notifications_hook()
File
- ./
notifications.cron.inc, line 383
Code
function notifications_process_digest_short($account, $events, $subscriptions, $send_interval, $send_method) {
// Compile list of events for each object
$list = array();
// Build up the digested list with text replacement
// We need text replacement for each line because it depends on different objects
foreach ($events as $event) {
notifications_log($event, 'digesting');
$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,
);
// $info = notifications_event_types($event->type, $event->action);
$digest = nofitications_digest_event_info($event);
$digest_type = $digest['type'];
$digest_value = $digest['value'];
if (!isset($list[$digest_type][$digest_value]['group'])) {
$group = array(
'title' => notifications_digest_group($digest, 'title', $send_method),
'footer' => notifications_digest_group($digest, 'footer', $send_method),
);
// The objects passed here for tokens will be the ones from the first event only
$list[$digest_type][$digest_value]['group'] = notifications_text_replace($group, $objects);
notifications_log("Digesting object (type={$digest_type} value={$digest_value})");
}
// Check duplicate notifications for the same event so we do some deduping
if (!isset($list[$digest_type][$digest_value]['line'][$event->eid])) {
$line = notifications_digest_line($event, $send_method, $objects);
$list[$digest_type][$digest_value]['line'][$event->eid] = notifications_text_replace($line, $event->objects);
}
}
// Create message. Do all this in one replacement, then strip out the subject
$text['subject'] = notifications_message_part('digest', 'subject', $send_method);
$text['header'] = notifications_message_part('digest', 'header', $send_method);
$text['footer'] = notifications_message_part('digest', 'footer', $send_method);
// We dont pass a subscription object here, won't be too much use anyway
$text = notifications_text_replace($text, array(
'user' => $account,
'subscription' => NULL,
));
// Compose body. All these lines have been text replaced
$body = theme('notifications_digest_short_body', $text, $list);
// Build the final digested message, and return in an array
$message = array(
'subject' => $text['subject'],
'body' => $body,
'events' => $events,
'subscriptions' => $subscriptions,
'digest' => 'short',
);
return array(
$message,
);
}