user_activity.rules_defaults.inc in Heartbeat 6.2
Rules' pre-configured rules for default drupal core behaviour.
File
user_activity/user_activity.rules_defaults.incView source
<?php
/**
* @file
* Rules' pre-configured rules for default drupal core behaviour.
*/
/**
* Implementation of hook_rules_defaults
*
* @return configured rules array
*/
function user_activity_rules_defaults() {
$config['rules'] = array();
$config['rules'] += user_activity_node_defaults();
$config['rules'] += user_activity_comment_defaults();
//dsm('user_activity_rules_defaults');
return $config;
}
/**
* Function to work with rules on node events
*/
function user_activity_node_defaults() {
$config = array(
# node_update_activity_rule
'node_update_activity_rule' => array(
'#type' => 'rule',
'#fixed' => TRUE,
'#name' => 'node_update_activity_rule',
'#label' => 'Heartbeat: User activity - log user on update content',
'#set' => 'event_node_update',
'#categories' => array(
'heartbeat',
),
'#active' => 1,
'#weight' => '0',
'#status' => 'default',
// 'custom' will make it deletable
'#conditions' => array(
0 => rules_use_condition('rules_condition_content_is_published', array(
'#settings' => array(
'#argument map' => array(
'node' => 'node',
),
),
'#weight' => 0,
)),
),
'#actions' => rules_use_action('user_activity_rules_default_action', array(
'#settings' => array(
'event_param' => 'event_node_update',
'uid_param' => '[author:uid]',
'uid_target_param' => '0',
'nid_target_param' => '[node:nid]',
'message_param' => t(heartbeat_event_messages('event_node_update', 'message')),
'message_concat_param' => t(heartbeat_event_messages('event_node_update', 'message_concat')),
'variables_param' => heartbeat_event_messages('event_node_update', 'variables'),
'#eval input' => array(
'token_rules_input_evaluator' => array(
'uid_param' => array(
0 => 'author',
),
'nid_target_param' => array(
0 => 'node',
),
'message_param' => array(
0 => 'node',
1 => 'author',
),
'variables_param' => array(
0 => 'node',
1 => 'author',
),
),
),
),
)),
),
// end node_update_activity_rule
// node_add_activity_rule
'node_add_activity_rule' => array(
'#type' => 'rule',
'#name' => 'node_add_activity_rule',
'#categories' => array(
'heartbeat',
),
'#set' => 'event_node_insert',
'#label' => 'Heartbeat: User activity - log user added new content',
'#active' => 1,
'#weight' => '0',
'#status' => 'default',
'#conditions' => array(
0 => rules_use_condition('rules_condition_content_is_published', array(
'#settings' => array(
'#argument map' => array(
'node' => 'node',
),
),
'#weight' => 0,
)),
),
'#actions' => rules_use_action('user_activity_rules_default_action', array(
'#settings' => array(
'event_param' => 'event_node_insert',
'uid_param' => '[author:uid]',
'uid_target_param' => '0',
'nid_target_param' => '[node:nid]',
'message_param' => t(heartbeat_event_messages('event_node_insert', 'message')),
'message_concat_param' => t(heartbeat_event_messages('event_node_update', 'message_concat')),
'variables_param' => heartbeat_event_messages('event_node_insert', 'variables'),
'#eval input' => array(
'token_rules_input_evaluator' => array(
'uid_param' => array(
0 => 'author',
),
'nid_target_param' => array(
0 => 'node',
),
'message_param' => array(
0 => 'node',
1 => 'author',
),
'variables_param' => array(
0 => 'node',
1 => 'author',
),
),
),
),
)),
),
);
return $config;
}
/**
* Function to work with comment events
*/
function user_activity_comment_defaults() {
$config = array(
// comment_add_activity_rule
'comment_add_activity_rule' => array(
'#type' => 'rule',
'#name' => 'comment_add_activity_rule',
'#categories' => array(
'heartbeat',
),
'#set' => 'event_comment_insert',
'#label' => 'Heartbeat: User activity - log user added new reply (comment)',
'#active' => 1,
'#weight' => '0',
'#status' => 'default',
'#conditions' => array(),
'#actions' => rules_use_action('user_activity_rules_default_action', array(
'#settings' => array(
'event_param' => 'event_comment_insert',
'uid_param' => '[comment_author:uid]',
'uid_target_param' => '[node_author:uid]',
'nid_target_param' => '[node:nid]',
'message_param' => t(heartbeat_event_messages('event_comment_insert', 'message')),
'message_concat_param' => t(heartbeat_event_messages('event_node_update', 'message_concat')),
'variables_param' => heartbeat_event_messages('event_comment_insert', 'variables'),
'#eval input' => array(
'token_rules_input_evaluator' => array(
'uid_param' => array(
0 => 'comment_author',
),
'uid_target_param' => array(
0 => 'node_author',
),
'nid_target_param' => array(
0 => 'node',
),
'variables_param' => array(
0 => 'comment_author',
1 => 'node',
),
),
),
),
)),
),
// end comment_add_activity_rule
// comment_update_activity_rule
'comment_update_activity_rule' => array(
'#type' => 'rule',
'#name' => 'comment_update_activity_rule',
'#categories' => array(
'heartbeat',
),
'#set' => 'event_comment_update',
'#label' => 'Heartbeat: User activity - log user updating a comment',
'#active' => 1,
'#weight' => '0',
'#status' => 'default',
'#conditions' => array(),
'#actions' => rules_use_action('user_activity_rules_default_action', array(
'#settings' => array(
'event_param' => 'event_comment_update',
'uid_param' => '[comment_author:uid]',
'uid_target_param' => '[node_author:uid]',
'nid_target_param' => '[node:nid]',
'message_param' => t(heartbeat_event_messages('event_comment_update', 'message')),
'message_concat_param' => t(heartbeat_event_messages('event_node_update', 'message_concat')),
'variables_param' => heartbeat_event_messages('event_comment_update', 'variables'),
'#eval input' => array(
'token_rules_input_evaluator' => array(
'uid_param' => array(
0 => 'comment_author',
),
'uid_target_param' => array(
0 => 'node_author',
),
'nid_target_param' => array(
0 => 'node',
),
'variables_param' => array(
0 => 'comment_author',
1 => 'node',
),
),
),
),
)),
),
);
return $config;
}
Functions
Name | Description |
---|---|
user_activity_comment_defaults | Function to work with comment events |
user_activity_node_defaults | Function to work with rules on node events |
user_activity_rules_defaults | Implementation of hook_rules_defaults |