You are here

function jammer_messages_boot in Jammer 7

Same name and namespace in other branches
  1. 6 jammer_messages.module \jammer_messages_boot()

Implements hook_boot().

File

./jammer_messages.module, line 11
Filter status messages set by drupal_set_message().

Code

function jammer_messages_boot() {
  if (!empty($_SESSION['messages'])) {
    $results = db_query("SELECT message_string FROM {jammer_messages}");
    foreach ($results as $message_filter) {
      $message_filter = $message_filter->message_string;
      foreach ($_SESSION['messages'] as $type => $messages) {
        $grep_results = preg_grep('/' . $message_filter . '/', $_SESSION['messages'][$type]);
        foreach ($grep_results as $key => $match) {
          unset($_SESSION['messages'][$type][$key]);
        }
        if (empty($_SESSION['messages'][$type])) {
          unset($_SESSION['messages'][$type]);
        }
      }
    }
  }
}