function notifications_process_build_simple in Notifications 6.3
Creates a single message for a single event
Replaces notifications_process_message();
Parameters
$account: Destination user account
$event: Event object which caused this notification
$subscriptions: Array of subscription ids
Return value
Message array
1 string reference to 'notifications_process_build_simple'
- notifications_notifications in ./
notifications.module - Implementation of notifications_hook()
File
- ./
notifications.cron.inc, line 532
Code
function notifications_process_build_simple($event, $params) {
// Get base template with all parameters
$template = Notifications_Template::create_event_template($event, $params->send_method, $params->language, $params->module);
//notifications_event_template($params->event, $params);
$template
->set_params($params);
// 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;
$template->subscriptions = array(
$event->eid => $subscriptions,
);
$template
->set_object('subscriptions', $template->subscriptions);
$template
->set_object('events', array(
$event,
));
// Build event parts
$template
->add_part('subject');
$template
->add_part('header');
$template
->add_part('main');
$template
->add_part('footer');
// We pass only the first subscription, which is at least something
// @ TODO Handle nicely the case where there are more than one subscription
$template
->set_object('user', $params->account);
$template
->set_object('subscription', $event_subscription);
notifications_log('Built event template', array(
'template' => $template,
));
// Build message from template and parameters
return $template
->build();
}