You are here

function heartbeat_message_load in Heartbeat 6.4

Fetches the translatable message for corresponding action

Parameters

string $id Message_id or heartbeat_message_id:

string $field Field condition:

4 calls to heartbeat_message_load()
heartbeat_activity_rules_action_message_id_js in modules/heartbeat_rules/hrules.module
Callback function to add variables to the user activity actions forms
heartbeat_log in ./heartbeat.module
User activity logger function
heartbeat_messages_revert in ./heartbeat.admin.inc
Revert a heartbeat message back to default
heartbeat_rules_default_action_form in modules/heartbeat_rules/hrules.rules.inc
Action drupal message configuration form.

File

./heartbeat.module, line 1360

Code

function heartbeat_message_load($id, $field = 'hid') {
  static $templates = array();
  if (!isset($templates[$id])) {
    $where = " hid = %d ";
    if (is_string($id) && (!is_numeric($id) || $field == 'message_id')) {
      $where = " message_id = '%s' ";
      $id = (string) $id;
    }
    $result = db_query("SELECT * from {heartbeat_messages} WHERE " . $where . "", $id);
    $message = db_fetch_object($result);
    if ($message) {
      if (!empty($message->attachments)) {
        $attachments = unserialize($message->attachments);
        $message->attachments = $attachments ? $attachments : array();
      }
      $message->concat_args = heartbeat_decode_message_variables($message->concat_args);
      $message->roles = isset($message->concat_args['roles']) ? $message->concat_args['roles'] : array();
      $message->variables = heartbeat_decode_message_variables($message->variables);
      $message->tags = heartbeat_get_available_tags($message->hid);
      $templates[$id] = $message;
    }
  }
  if (isset($templates[$id])) {
    return $templates[$id];
  }
  return NULL;
}