function notifications_message_part in Notifications 5
Same name and namespace in other branches
- 6 notifications.cron.inc \notifications_message_part()
- 6.2 notifications.cron.inc \notifications_message_part()
Get message part
It searches for optional message group keys for options defaulting to $type 1. $type-[$event->type]-[$event->action] 2. $type-[$event->type] 3. $type
Parameters
$type: Message type to send, either 'event' or 'digest'
$key: Id of message part, ie 'header'
$method: Method by which message will be sent. Normally 'mail'
$param: Event data
Return value
Part of the message.
6 calls to notifications_message_part()
- notifications_digest_group in ./
notifications.cron.inc - Get text parts for digests.
- notifications_digest_line in ./
notifications.cron.inc - Digest each line, with some caching for performance
- notifications_process_digest_long in ./
notifications.cron.inc - Digest multiple events in a single message, long format.
- notifications_process_digest_short in ./
notifications.cron.inc - Digest multiple events in a single message, short format.
- notifications_process_message in ./
notifications.cron.inc - Creates a single message for a single event
File
- ./
notifications.cron.inc, line 567
Code
function notifications_message_part($type, $key, $method, $param = NULL) {
// If event passed check for predefined text or get optional keys from event
if ($type == 'event' && is_object($param)) {
if (isset($param->text[$key])) {
return $param->text[$key];
}
else {
$options = array(
$param->type,
$param->action,
);
}
}
elseif ($method == 'test') {
// Little trick for this to be testable
return "{$type} {$key} [type-name] [title] [site-name]";
}
else {
$options = is_array($param) ? $param : array();
}
$keyparts = array_merge(array(
'notifications-' . $type,
), $options);
// Output some debugging info in case we dont find a suitable message part
$output = "[UNDEFINED type = {$type}, method = {$method}, key = " . implode('-', $keyparts) . ']';
while ($keyparts) {
$groupkey = implode('-', $keyparts);
if ($text = messaging_message_part($groupkey, $key, $method)) {
$output = $text == MESSAGING_EMPTY ? '' : $text;
break;
}
// If no text trim out latest part of the key and retry
array_pop($keyparts);
}
return $output;
}