You are here

function heartbeat_log in Heartbeat 7

Same name and namespace in other branches
  1. 6.4 heartbeat.module \heartbeat_log()
  2. 6.3 heartbeat.module \heartbeat_log()

User activity logger function

Parameters

The data to add one row:

2 calls to heartbeat_log()
heartbeat_api_log in ./heartbeat.module
API function to log a message from custom code
rules_action_heartbeat_activity_log in modules/heartbeat_rules/heartbeat_rules.module
Rules action to log activity.

File

./heartbeat.module, line 886
Module file for heartbeat activity. Basic hook implementations and helper functions will be found here.

Code

function heartbeat_log($data, $args = array()) {

  // Relational message of heartbeat messages
  $template = heartbeat_message_template_load($data['message_id']);
  $heartbeatactivity = new HeartbeatActivity($data, $template);

  // Prepare the fields.
  field_attach_presave('heartbeat_activity', $heartbeatactivity);
  module_invoke_all('heartbeat_activity_presave', $heartbeatactivity);

  // Save the record to the activity table.
  $saved = $heartbeatactivity
    ->save($args);

  // Save fields.
  field_attach_insert("heartbeat_activity", $heartbeatactivity);

  // Invoke the heartbeat activity hooks.
  module_invoke_all("entity_insert", $heartbeatactivity, 'heartbeat_activity');
  module_invoke_all("heartbeat_activity_insert", $heartbeatactivity);
  return $saved;
}