function og_notifications_message_alter in Organic groups 6.2
Same name and namespace in other branches
- 5.3 og_notifications/og_notifications.module \og_notifications_message_alter()
- 6 modules/og_notifications/og_notifications.module \og_notifications_message_alter()
A workaround to ensure that OG can provide custom message templates for notifications.
Parameters
Object $message: The message object.
Object $info: Sending method information.
File
- modules/
og_notifications/ og_notifications.module, line 278 - Provide notifications and messaging support for organic groups.
Code
function og_notifications_message_alter(&$message, $info) {
if ($sid = _og_notification_check_message($message)) {
$event = $message->notifications['events'][0];
// Cater for different message groups (actions).
$group = 'og-notifications-' . $event->action;
$send_method = $message->method;
$subscription = notifications_load_subscription($sid);
$text = array(
'subject' => messaging_message_part($group, 'subject', $send_method, $event),
'header' => messaging_message_part($group, 'header', $send_method, $event),
'footer' => messaging_message_part($group, 'footer', $send_method, $event),
);
if (isset($message->body['main'])) {
$text['main'] = messaging_message_part($group, 'main', $send_method, $event);
}
else {
$text['event'] = messaging_message_part($group, 'main', $send_method, $event);
}
$objects = array(
'user' => $message->account,
'node' => $event->objects['node'],
'subscription' => $subscription,
);
if ($event->action == 'comment') {
$objects['comment'] = $event->objects['comment'];
}
$objects = array_merge($objects, $event->objects);
$text = messaging_text_replace($text, $objects);
$message->subject = $text['subject'];
unset($text['subject']);
$message->body = array_merge($message->body, $text);
}
}