=== modified file 'includes/bootstrap.inc' --- includes/bootstrap.inc 2009-01-31 16:50:56.000000000 +0000 +++ includes/bootstrap.inc 2009-02-24 13:54:00.657638500 +0000 @@ -968,7 +968,7 @@ * @param $message * The message should begin with a capital letter and always ends with a * period '.'. - * @param $type + * @param $severity * The type of the message. One of the following values are possible: * - 'status' * - 'warning' @@ -976,19 +976,25 @@ * @param $repeat * If this is FALSE and the message is already set, then the message won't * be repeated. + * @param $type + * The message type. Can be anything but is set to 'general' by default. */ -function drupal_set_message($message = NULL, $type = 'status', $repeat = TRUE) { +function drupal_set_message($message = NULL, $severity = 'status', $repeat = TRUE, $type = 'general') { if ($message) { if (!isset($_SESSION['messages'])) { drupal_set_session('messages', array()); } - if (!isset($_SESSION['messages'][$type])) { - $_SESSION['messages'][$type] = array(); + if (!isset($_SESSION['messages'][$severity])) { + $_SESSION['messages'][$severity] = array(); + } + + if (!isset($_SESSION['messages'][$severity][$type])) { + $_SESSION['messages'][$severity][$type] = array(); } - if ($repeat || !in_array($message, $_SESSION['messages'][$type])) { - $_SESSION['messages'][$type][] = $message; + if ($repeat || !in_array($message, $_SESSION['messages'][$severity][$type])) { + $_SESSION['messages'][$severity][$type][] = $message; } } @@ -999,26 +1005,65 @@ /** * Return all messages that have been set. * - * @param $type - * (optional) Only return messages of this type. + * @param $severity + * (optional) Only return messages of this severity level. Has three default + * values: + * - 'status' + * - 'warning' + * - 'error' * @param $clear_queue * (optional) Set to FALSE if you do not want to clear the messages queue + * @param $type + * (optional) Restrict returned values to a specific type. Unless otherwise + * specified in drupal_set_message(), a message's type will be 'general'. * @return * 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. + * all messages are returned, or an empty array if none exist. */ -function drupal_get_messages($type = NULL, $clear_queue = TRUE) { +function drupal_get_messages($severity = NULL, $clear_queue = TRUE, $type = NULL) { if ($messages = drupal_set_message()) { - if ($type) { - if ($clear_queue) { - unset($_SESSION['messages'][$type]); + if ($severity) { + + if ($type) { + if ($clear_queue) { + unset($_SESSION['messages'][$severity][$type]); + } + if (isset($messages[$severity][$type])) { + return array( + $severity => array( + $type => $messages[$severity][$type], + ), + ); + } } - if (isset($messages[$type])) { - return array($type => $messages[$type]); + + else { + if ($clear_queue) { + unset($_SESSION['messages'][$severity]); + } + foreach ($messages[$severity] as $type => $messages) { + $output[$severity][$type] = $messages; + } + return $output; + } + + } + + elseif ($type) { + $output = array(); + foreach ($messages as $severity => $data) { + if (isset($messages[$severity][$type])) { + if ($clear_queue) { + unset($_SESSION['messages'][$severity][$type]); + } + $output[$severity][$type] = $messages[$severity][$type]; + } } + return $output; } + else { if ($clear_queue) { unset($_SESSION['messages']); === modified file 'includes/theme.inc' --- includes/theme.inc 2009-02-22 17:55:29.000000000 +0000 +++ includes/theme.inc 2009-02-24 13:59:10.821034200 +0000 @@ -1102,27 +1102,33 @@ * Return a themed set of status and/or error messages. The messages are grouped * by type. * - * @param $display - * (optional) Set to 'status' or 'error' to display only messages of that type. + * @param $severity + * (optional) Set to 'status' or 'error' to display only messages of that severity level. + * + * @param $type + * (optional) Set to 'general' or a module-specific value to only show messages of that type. * * @return * A string containing the messages. */ -function theme_status_messages($display = NULL) { +function theme_status_messages($severity = NULL, $type = NULL) { $output = ''; - foreach (drupal_get_messages($display) as $type => $messages) { - $output .= "
\n"; - if (count($messages) > 1) { - $output .= " \n"; - } - else { - $output .= $messages[0]; + else { + $output .= $messages[0]; + } + $output .= "
\n"; } - $output .= "\n"; } return $output; }