function privatemsg_rules_rules_action_info in Privatemsg 7.2
Same name and namespace in other branches
- 6.2 privatemsg_rules/privatemsg_rules.rules.inc \privatemsg_rules_rules_action_info()
- 7 privatemsg_rules/privatemsg_rules.rules.inc \privatemsg_rules_rules_action_info()
Implements hook_rules_action_info().
File
- privatemsg_rules/
privatemsg_rules.rules.inc, line 13 - Hooks and callback functions for rules.module integration.
Code
function privatemsg_rules_rules_action_info() {
// Re-use existing information and also get information about fields added
// to private messages.
$fields = entity_get_all_property_info('privatemsg_message');
// Remove properties that can't be used here.
unset($fields['mid']);
unset($fields['thread_id']);
unset($fields['timestamp']);
// Remove fields, they are not supported yet.
foreach (array_keys($fields) as $key) {
if (strpos($key, 'field_') === 0) {
unset($fields[$key]);
}
}
// Update some descriptions and other definitions.
$fields['subject']['description'] = t('Subject of the message. To use the tokens provided by Privatemsg, use {token}, for example: {privatemsg_message:recipient:name}.');
$fields['body']['description'] = t('Body of the message. To use the tokens provided by Privatemsg, use {token}, for example: {privatemsg_message:recipient:name}.');
$fields['body']['long'] = TRUE;
// Make subject and body translatable.
$fields['subject']['translatable'] = TRUE;
$fields['body']['translatable'] = TRUE;
// Reply doesn't have subject either.
$reply_fields = $fields;
unset($reply_fields['subject']);
$actions = array(
'privatemsg_rules_new' => array(
'label' => t('Send a message'),
'named parameter' => TRUE,
'parameter' => array(
'recipient' => array(
'type' => 'user',
'label' => t('Recipient'),
'description' => t('Recipient of the message.'),
),
) + $fields,
'new variables' => array(
'thread_id' => array(
'type' => 'integer',
'label' => t('ID of new thread'),
),
),
'group' => t('Private messages'),
),
'privatemsg_rules_reply' => array(
'label' => t('Reply to a message'),
'named parameter' => TRUE,
'parameter' => array(
'thread_id' => array(
'type' => 'integer',
'label' => t('Privatemsg thread id'),
'description' => t('Thread ID of the thread that should be responded to.'),
),
) + $reply_fields,
'group' => t('Private messages'),
),
'privatemsg_rules_unread_count' => array(
'label' => t('Load number of unread messages'),
'parameter' => array(
'account' => array(
'type' => 'user',
'label' => t('User account'),
'description' => t('Specify the user for which the number of unread messages should be loaded.'),
),
),
'new variables' => array(
'unread_count' => array(
'type' => 'integer',
'label' => t('Number of unread messages'),
),
),
'group' => t('Private messages'),
),
);
if (module_exists('privatemsg_filter')) {
$actions['privatemsg_rules_tag_thread'] = array(
'label' => t('Tag a privatemsg thread'),
'parameter' => array(
'thread_id' => array(
'type' => 'integer',
'label' => t('Specify the thread ID that should be tagged.'),
),
'account' => array(
'type' => 'user',
'label' => t('Specify for which user the message should tagged.'),
),
'privatemsg_tag' => array(
'type' => 'text',
'label' => t('Name of the tag that should be added.'),
'description' => t('Multiple tags can be specified, separated by a comma.'),
),
),
'group' => t('Private messages'),
);
}
if (module_exists('privatemsg_roles')) {
$actions['privatemsg_rules_new_role'] = array(
'label' => t('Send a message to a role'),
'named parameter' => TRUE,
'parameter' => array(
'roles' => array(
'type' => 'list<integer>',
'label' => t('Roles'),
'options list' => 'entity_metadata_user_roles',
'description' => t('Select the roles whose users should receive the message.'),
),
) + $fields,
'new variables' => array(
'thread_id' => array(
'type' => 'integer',
'label' => t('ID of new thread'),
),
),
'group' => t('Private messages'),
);
}
return $actions;
}