function friendlist_activity_rules_action in Heartbeat 6.2
Action Implementation: Log an activity
@TODO drop the hardcoded arguments
Parameters
array $settings:
array form:
array with two arrays (set_info and variables):
1 string reference to 'friendlist_activity_rules_action'
- friendlist_activity_default in user_activity/
modules/ friendlist_activity/ friendlist_activity.rules_defaults.inc - Function to work with rules defined in friendlist
File
- user_activity/
modules/ friendlist_activity/ friendlist_activity.rules.inc, line 46
Code
function friendlist_activity_rules_action($settings, $form = array(), $event_info = array()) {
//dsm(func_get_args());
// 1. Requester
$data_requester = array();
$data_requester['uid'] = $settings['uid_param'];
$data_requester['uid_target'] = $settings['uid_target_param'];
$data_requester['message'] = t($settings['message_param']);
$data_requester['message_concat'] = t($settings['message_concat_param']);
$data_requester['variables'] = $settings['variables_param'];
$data_requester['event'] = $settings['event_param'];
$data_requester['hid'] = heartbeat_event_id($data_requester['event']);
// decode variables here to preset the arguments
// username1 and 2 because they are being switched
// #relation_type because it has to be translated.
$variables = heartbeat_decode_message_variables($data_requester['variables']);
$args = array(
'@username1' => $variables['username1'],
'@username2' => $variables['username2'],
'#relation_type' => t($variables['relation_type']),
);
user_activity_log($data_requester, $args);
// 2. Requestee, override requester
$data_requestee = $data_requester;
$data_requestee['uid'] = $data_requester['uid_target'];
$data_requestee['uid_target'] = $data_requester['uid'];
$args = array(
'@username1' => $variables['username2'],
'@username2' => $variables['username1'],
'#relation_type' => t($variables['relation_type']),
);
//dsm($data_requestee);
user_activity_log($data_requestee, $args);
}