You are here

function heartbeat_messages_install in Heartbeat 6.3

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

Function to install default records

Parameters

string $module to conventionally look: for defined record objects in heartbeat_messages

1 call to heartbeat_messages_install()
heartbeat_gather_messages in ./heartbeat.module
Function that gathers all messages from all modules New ones and existing ones

File

./heartbeat.module, line 674

Code

function heartbeat_messages_install($objects) {
  foreach ($objects as $record) {
    $record = (object) $record;
    if (isset($record->concat_args) && is_array($record->concat_args)) {
      $record->concat_args = heartbeat_encode_message_variables($record->concat_args);
    }
    if (isset($record->variables) && is_array($record->variables)) {
      $record->variables = heartbeat_encode_message_variables($record->variables);
    }

    //watchdog('heartbeat', $module.' is writing a message to heartbeat_messages.', ((array)$record) );

    // drupal_write record does not work when installing all modules together
    // reason is the schema static cannot rebuilt without messing in the core.
    // drupal_write_record('heartbeat_messages', $record);
    db_query("INSERT INTO {heartbeat_messages} (\n    message_id, message_type, message, message_concat, concat_args, perms, description, module, variables)\n    VALUES ('%s', '%s', '%s', '%s','%s', %d, '%s', '%s', '%s') ", $record->message_id, $record->message_type, $record->message, $record->message_concat, $record->concat_args, $record->perms, $record->description, $record->module, $record->variables);
  }
  return $objects;
}