function notifications_digest_build_long in Notifications 6.3
Same name and namespace in other branches
- 6.4 notifications_digest/notifications_digest.module \notifications_digest_build_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_digest_build_long'
- notifications_digest_notifications in notifications_digest/
notifications_digest.module - Implementation of hook_notifications()
File
- notifications_digest/
notifications_digest.module, line 137 - Notifications message digest
Code
function notifications_digest_build_long($params) {
notifications_log('Digesting long format', array(
'params' => $params,
));
// Build the base template with full parameters
$template = Notifications_Template::create_template('digest', NULL, $params->send_method, $params->language, $params->module);
//$template = notifications_digest_template(NULL, $params->module, $params->send_method, $params->language);
$template->subscriptions = $params->subscriptions;
$template->events = $params->events;
$template
->set_params($params);
$template
->add_part('subject');
$template
->add_part('header');
// Add shared objects, will be inherited by child templates
$template
->set_object('user', $params->account);
// 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 ($params->events as $event) {
// Pass only the first subscription for this event
$subscriptions = !empty($params->subscriptions[$event->eid]) ? $params->subscriptions[$event->eid] : array();
$event_subscription = ($sid = current($subscriptions)) ? notifications_load_subscription($sid) : NULL;
// We use the regular template for the events, method and language will be inherited
if ($event_template = $template
->get_event_template($event)) {
$event_template
->set_object('subscription', $event_subscription);
$event_template
->add_part('subject');
$event_template
->add_part('main');
}
$template
->add_child($event_template, 'main');
}
$template
->add_part('footer');
notifications_log('Built long digest template', array(
'template' => $template,
));
// Build message from template and parameters
$message = $template
->build();
// Return array of messages instead of message;
return array(
$message,
);
}