You are here

function _heartbeat_message_prepare in Heartbeat 6.4

Prepares a record for database storage

2 calls to _heartbeat_message_prepare()
heartbeat_message_insert in ./heartbeat.module
Inserts a heartbeat message
heartbeat_message_update in ./heartbeat.module
Updates a heartbeat message

File

./heartbeat.module, line 1467

Code

function _heartbeat_message_prepare($record) {
  $record = (object) $record;
  if (isset($record->concat_args) && is_array($record->concat_args)) {
    $record->concat_args['merge_separator_t'] = preg_match('/[a-z]/', $record->concat_args['merge_separator']);
    $record->concat_args['merge_end_separator_t'] = preg_match('/[a-z]/', $record->concat_args['merge_end_separator']);
    $record->concat_args = heartbeat_encode_message_variables($record->concat_args);
  }
  if (empty($record->variables)) {
    $record->variables = array();
  }
  if (isset($record->variables) && is_array($record->variables)) {
    $record->variables = heartbeat_encode_message_variables($record->variables);
  }
  $attachments = array();
  if (isset($record->attachments) && is_array($record->attachments)) {
    $attachments = $record->attachments;
  }
  $record->attachments = serialize($attachments);

  // Set keys to default if left empty
  if (!isset($record->perms) || !is_numeric($record->perms)) {
    $record->perms = HEARTBEAT_PUBLIC_TO_ALL;
  }
  return $record;
}