You are here

function message_show_message in Message 6

Show a message by the message instance ID.

Parameters

$message_instance: The message instance object.

$account: Optional; The account that access should be checked for.

Return value

HTML with the message.

1 call to message_show_message()
message_handler_field_message_render::render in includes/message_handler_field_message_render.inc

File

./message.module, line 540
API functions to manipulate messages.

Code

function message_show_message($message_instance, $skip_access = FALSE, $account = NULL) {
  $output = '';
  $access = FALSE;
  if (empty($account)) {
    global $user;
    $account = drupal_clone($user);
  }
  if ($skip_access) {
    $access = TRUE;
  }
  elseif ($realms = message_realm_load_multiple_by_message($message_instance->iid)) {
    foreach (message_get_plugin_messages() as $plugin) {
      if (in_array($plugin['realm'], array_keys($realms)) && message_show_message_access($plugin, $message_instance, $realms[$plugin['realm']])) {
        $access = TRUE;
        break;
      }
    }
  }
  if ($access) {
    $output = theme('message', array(
      'message' => $message_instance,
      'output' => message_t($message_instance),
    ));
  }
  return $output;
}