You are here

function drupal_get_messages in Drupal 5

Same name and namespace in other branches
  1. 8 core/includes/bootstrap.inc \drupal_get_messages()
  2. 4 includes/bootstrap.inc \drupal_get_messages()
  3. 6 includes/bootstrap.inc \drupal_get_messages()
  4. 7 includes/bootstrap.inc \drupal_get_messages()

Return all messages that have been set.

Parameters

$type: (optional) Only return messages of this type.

$clear_queue: (optional) Set to FALSE if you do not want to clear the messages queue

Return value

An associative array, the key is the message type, the value an array of messages. If the $type parameter is passed, you get only that type, or an empty array if there are no such messages. If $type is not passed, all message types are returned, or an empty array if none exist.

2 calls to drupal_get_messages()
page_set_cache in includes/common.inc
Store the current page in the cache.
theme_status_messages in includes/theme.inc
Return a themed set of status and/or error messages. The messages are grouped by type.

File

includes/bootstrap.inc, line 807
Functions that need to be loaded on every Drupal request.

Code

function drupal_get_messages($type = NULL, $clear_queue = TRUE) {
  if ($messages = drupal_set_message()) {
    if ($type) {
      if ($clear_queue) {
        unset($_SESSION['messages'][$type]);
      }
      if (isset($messages[$type])) {
        return array(
          $type => $messages[$type],
        );
      }
    }
    else {
      if ($clear_queue) {
        unset($_SESSION['messages']);
      }
      return $messages;
    }
  }
  return array();
}