You are here

function heartbeat_api_log in Heartbeat 6.3

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

API function to log a message from custom code

Parameters

string $message_id: Id of the message that is known in the message

integer $uid: Actor or user performing the activity

integer $uid_target [optional]: user id of the target user if present. Target users can be an addresse or a user relation transaction with the actor $uid

integer $nid [optional]: Node id if the activity is content related

array $variables [optional]: Variables can be used if you used them in the used message. Take care to use the @-sign for words that are prefix with the question mark sign in the messages

File

./heartbeat.module, line 487

Code

function heartbeat_api_log($message_id, $uid, $uid_target = 0, $nid = 0, $variables = array()) {
  $data = array();

  // Normal form values
  $data['message_id'] = $message_id;
  $data['uid'] = $uid;
  $data['uid_target'] = $uid_target;
  $data['nid_target'] = $nid;

  // Relational message of heartbeat messages
  $message = heartbeat_load_message($data['message_id']);
  $data['message'] = $message->message;
  $data['message_concat'] = $message->message_concat;
  if (!empty($variables) && is_array($variables)) {
    $data['variables'] = heartbeat_encode_message_variables($variables);
  }
  return heartbeat_log($data);
}