You are here

function heartbeat_messages_install in Heartbeat 6.2

Same name and namespace in other branches
  1. 6.4 heartbeat.module \heartbeat_messages_install()
  2. 6.3 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 430
To fully understand this, you have to be familiar with the rules module. Lots of documentation can be found on http://drupal.org/node/298480 for an introduction and tutorial, but http://drupal.org/node/298486 is a lot of handy info for developers.

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} (message, message_concat, concat_args, event, karma_index, description, module, variables) \n    VALUES ('%s', '%s','%s','%s',%d,'%s','%s','%s') ", $record->message, $record->message_concat, $record->concat_args, $record->event, $record->karma_index, $record->description, $record->module, $record->variables);
  }
  return $objects;
}