function notifications_messaging_templates in Notifications 6.4
Same name and namespace in other branches
- 7 includes/templates.inc \notifications_messaging_templates()
Implementation of hook_messaging_templates()
This will be actually included and called from notifications_messaging() when needed
For some of these templates, we don't want them to be filtered by enabled events so we provide them straight to messaging module. The others will be returned by notifications_get_templates()
Depending on $op, this hook takes different parameters and returns different pieces of information:
- 'message groups' Get array of message groups, each of which will have one or more keys for different templates Each group should have a unique key, so it should start with the module name
- 'message keys' Get message template parts for a given group ($arg1) Return array of key => name for each part
- 'messages' Get default message templates for a given group ($arg1). It should return default texts, indexed by message key that will be the default templates These templates may be edited on the 'Messaging templates' page
- 'tokens' Get available tokens for a given message group and key ($arg1). Return array of token keys that will be available for this message templates The tokens themselves may be default tokens (provided by token module) or we can add new tokens implementing hook_token_list() and hook_token_value()
Parameters
$op: Operation, type of information to retrieve
$arg1, $arg2...: Different parameters depending on $op
1 call to notifications_messaging_templates()
- notifications_messaging in ./
notifications.module - Implementation of hook_messaging()
File
- includes/
templates.inc, line 76 - Notifications templates
Code
function notifications_messaging_templates($op = 'info', $type = 'all', $language = NULL) {
switch ($op) {
case 'message groups':
$type = $type ? $type : 'all';
// First compile enabled templates only from hook_notifications_templates()
$info = notifications_get_templates('info', 'enabled');
if ($type == 'all' || $type == 'notifications-message') {
$info['notifications-message'] = array(
'module' => 'notifications',
'name' => t('Notifications messages'),
'description' => t('These are the common parts for one time messages sent by Notifications. These are not triggered by subscriptions and events. They are replies to operations requested by a user.'),
'fallback' => FALSE,
);
}
if ($type == 'all' || $type == 'notifications-user-unsubscribe') {
$info['notifications-user-unsubscribe'] = array(
'module' => 'notifications',
'name' => t('Cancel user subscriptions'),
'description' => t('It should contain a link to cancel all subscriptions for a user.'),
'fallback' => 'notifications-message',
);
}
if ($type == 'all' || $type == 'notifications-destination-unsubscribe') {
$info['notifications-destination-unsubscribe'] = array(
'module' => 'notifications',
'name' => t('Cancel destination subscriptions'),
'description' => t('It should contain a link to cancel all subscriptions for a destination address.'),
'fallback' => 'notifications-message',
);
}
return $info;
case 'message keys':
return notifications_get_templates('parts', $type);
case 'messages':
// The second argument should be language object
return notifications_get_templates('defaults', $type, $language);
case 'tokens':
return notifications_get_templates('tokens', $type);
}
}