function drupal_set_message

7.x bootstrap.inc drupal_set_message($message = NULL, $type = 'status', $repeat = TRUE)
6.x bootstrap.inc drupal_set_message($message = NULL, $type = 'status', $repeat = TRUE)

Set a message which reflects the status of the performed operation.

If the function is called with no arguments, this function returns all set messages without clearing them.

Parameters

$message: The message should begin with a capital letter and always ends with a period '.'.

$type: The type of the message. One of the following values are possible:

  • 'status'
  • 'warning'
  • 'error'

$repeat: If this is FALSE and the message is already set, then the message won't be repeated.

169 calls to drupal_set_message()
aggregator_categorize_items_submit in drupal-6.x/modules/aggregator/aggregator.pages.inc
Process aggregator_categorize_items form submissions.
aggregator_form_category_submit in drupal-6.x/modules/aggregator/aggregator.admin.inc
Process aggregator_form_category form submissions.
aggregator_form_feed_submit in drupal-6.x/modules/aggregator/aggregator.admin.inc
Process aggregator_form_feed form submissions.
aggregator_parse_feed in drupal-6.x/modules/aggregator/aggregator.module
Parse a feed and store its items.
aggregator_refresh in drupal-6.x/modules/aggregator/aggregator.module
Checks a news feed for new items.

... See full list

File

drupal-6.x/includes/bootstrap.inc, line 991
Functions that need to be loaded on every Drupal request.

Code

function drupal_set_message($message = NULL, $type = 'status', $repeat = TRUE) {
  if ($message) {
    if (!isset($_SESSION['messages'])) {
      $_SESSION['messages'] = array();
    }

    if (!isset($_SESSION['messages'][$type])) {
      $_SESSION['messages'][$type] = array();
    }

    if ($repeat || !in_array($message, $_SESSION['messages'][$type])) {
      $_SESSION['messages'][$type][] = $message;
    }
  }

  // messages not set when DB connection fails
  return isset($_SESSION['messages']) ? $_SESSION['messages'] : NULL;
}