function notifications_content_messaging_template in Notifications 6.3
Implementation of hook_messaging_template()
File
- notifications_content/
notifications_content.module, line 434 - Subscriptions to content events
Code
function notifications_content_messaging_template($op, $type = NULL, $langcode = NULL) {
switch ($op) {
case 'templates':
$help = t('The <em>Header</em> and <em>Footer</em> will be taken from Notification events.', array(), $langcode);
$help_digest = $help . ' ' . t('The <em>Digest line</em> will be used when composing Short digests on which each event will be just a line.', array(), $langcode);
// Generic notifications event
$info['notifications-event-node'] = array(
'module' => 'notifications_content',
'type' => 'notifications',
'title' => t('Notifications for node events', array(), $langcode),
'digest' => 'notifications-digest',
'description' => t('Defaults for all notifications related to node events.', array(), $langcode),
'help' => $help_digest,
'fallback' => 'notifications-event',
);
$info['notifications-event-node-insert'] = array(
'module' => 'notifications_content',
'type' => 'notifications',
'title' => t('Notifications for node creation', array(), $langcode),
'digest' => 'notifications-digest-node-type',
'description' => t('Notifications produced when a new node is created.', array(), $langcode),
'help' => $help_digest,
'fallback' => 'notifications-event-node',
);
$info['notifications-event-node-update'] = array(
'module' => 'notifications_content',
'type' => 'notifications',
'title' => t('Notifications for node updates', array(), $langcode),
'digest' => 'notifications-digest-node-nid',
'description' => t('Notifications produced when a node is updated.', array(), $langcode),
'help' => $help_digest,
'fallback' => 'notifications-event-node',
);
$info['notifications-event-node-comment'] = array(
'module' => 'notifications_content',
'type' => 'notifications',
'title' => t('Notifications for node comments', array(), $langcode),
'digest' => 'notifications-digest-node-nid',
'description' => t('Notifications produced when a comment is posted to a node.', array(), $langcode),
'help' => $help_digest,
'fallback' => 'notifications-event-node',
);
// Node group digests, will have specific help text in hook_help()
$info['notifications-digest-node-nid'] = array(
'module' => 'notifications-content',
'type' => 'notifications',
'title' => t('Groups digests per node', array(), $langcode),
'description' => t('Group of events digested for each node.', array(), $langcode),
'fallback' => 'notifications-digest',
);
$info['notifications-digest-node-type'] = array(
'module' => 'notifications-content',
'type' => 'notifications',
'title' => t('Groups digests per node type', array(), $langcode),
'description' => t('Group of events digested for each node type.', array(), $langcode),
'fallback' => 'notifications-digest',
);
// More templates for each node type, disabled by default
foreach (node_get_types() as $key => $node_type) {
$variables = array(
'@name' => $node_type->name,
);
$basekey = 'notifications-content-' . $key;
$info[$basekey] = array(
'module' => 'notifications_content',
'type' => 'notifications',
'fallback' => 'notifications-event-node',
'title' => t('Notifications for @name events', $variables, $langcode),
'description' => t('Defaults for all notifications related to @name events.', $variables, $langcode),
'disabled' => TRUE,
);
$info[$basekey . '-insert'] = array(
'module' => 'notifications_content',
'type' => 'notifications',
'title' => t('Notifications for @name creation', $variables, $langcode),
'digest' => 'notifications-digest-node-type',
'description' => t('Notifications produced when a new @name is created.', $variables, $langcode),
'help' => $help_digest,
'fallback' => 'notifications-event-node-insert',
'disabled' => TRUE,
);
$info[$basekey . '-update'] = array(
'module' => 'notifications_content',
'type' => 'notifications',
'title' => t('Notifications for @name updates', $variables, $langcode),
'digest' => 'notifications-digest-node-nid',
'description' => t('Notifications produced when a @name is updated.', $variables, $langcode),
'help' => $help_digest,
'fallback' => 'notifications-event-node-insert',
'disabled' => TRUE,
);
$info[$basekey . '-comment'] = array(
'module' => 'notifications_content',
'type' => 'notifications',
'title' => t('Notifications for @name comments', $variables, $langcode),
'digest' => 'notifications-digest-node-nid',
'description' => t('Notifications produced when a comment is posted to a @name.', $variables, $langcode),
'help' => $help_digest,
'fallback' => 'notifications-event-node-insert',
'disabled' => TRUE,
);
}
return $info;
case 'defaults':
$node_read_more = t('Read more [node-url]', array(), $langcode);
$comment_read_more = t('Read more [comment-url]', array(), $langcode);
// Event notifications
switch ($type) {
case 'notifications-event-node':
case 'notifications-event-node-update':
return array(
'subject' => t('Update for [type-name]: [title]', array(), $langcode),
'main' => array(
'[node-teaser]',
$node_read_more,
),
'digest' => array(
'[title]',
$node_read_more,
),
);
case 'notifications-event-node-insert':
return array(
'subject' => t('New [type-name]: [title]', array(), $langcode),
'main' => array(
'[node-teaser]',
$node_read_more,
),
'digest' => array(
'[title]',
$node_read_more,
),
);
case 'notifications-event-node-comment':
return array(
'subject' => t('Comment for [type-name]: [title]', array(), $langcode),
'main' => array(
t('Comment by [comment-author-name]: [comment-title]', array(), $langcode),
'[comment-body]',
$comment_read_more,
),
'digest' => array(
t('New comment by [comment-author-name]: [comment-title]', array(), $langcode),
$comment_read_more,
),
);
case 'notifications-digest-node-nid':
// Define only group title and group footer (closing)
// The 'closing' statement is typically a 'read more' link
return array(
'title' => t('Updates for [type-name]: [title]', array(), $langcode),
'closing' => $node_read_more,
);
case 'notifications-digest-node-type':
return array(
'title' => t('New content of type [type-name] has been submitted'),
'closing' => '...',
);
}
break;
case 'tokens':
$keys = explode('-', $type) + array(
2 => '',
3 => '',
);
$tokens = array();
// These are the token groups that will be used for this module's messages
if (strpos($type, 'notifications-event-node') === 0 || strpos($type, 'notifications-content') === 0) {
$tokens[] = 'node';
if (strpos($type, '-comment')) {
$tokens[] = 'comment';
}
}
elseif (strpos($type, 'notifications-digest-node') === 0) {
if ($keys[3] == 'nid') {
$tokens[] = 'node';
}
elseif ($keys[3] == 'type') {
// Special format for isolated tokens: array('token type', 'token id').
// In this case, as messages are digested by node type the only common element will be node-type
$tokens[] = array(
'node',
'type-name',
);
}
}
return $tokens;
}
}