=== modified file 'includes/bootstrap.inc'
--- includes/bootstrap.inc	2007-12-20 08:20:58 +0000
+++ includes/bootstrap.inc	2007-12-27 16:01:09 +0000
@@ -762,7 +762,9 @@ function drupal_set_message($message = N
       $_SESSION['messages'][$type] = array();
     }
 
-    $_SESSION['messages'][$type][] = $message;
+    if (!in_array($message, $_SESSION['messages'][$type])) {
+      $_SESSION['messages'][$type][] = $message;
+    }
   }
 
   // messages not set when DB connection fails

=== modified file 'includes/menu.inc'
--- includes/menu.inc	2007-12-26 19:02:23 +0000
+++ includes/menu.inc	2007-12-27 12:32:37 +0000
@@ -2228,26 +2228,30 @@ function menu_path_is_external($path) {
 }
 
 /**
- * Returns TRUE if the site is off-line for maintenance.
+ * Checks whether the site is off-line for maintenance.
+ *
+ * Note that logged in users without 'administer site configuration' are logged
+ * out.
+ *
+ * @return
+ *   FALSE if the site is not off-line or its the login page or the user has
+ *     'administer site configuration' permission.
+ *   TRUE for anonymous users not on the login page if the site is off-line.
  */
 function _menu_site_is_offline() {
   // Check if site is set to off-line mode.
   if (variable_get('site_offline', 0)) {
     // Check if the user has administration privileges.
-    if (!user_access('administer site configuration')) {
-      // Check if this is an attempt to login.
-      if (drupal_get_normal_path($_GET['q']) != 'user') {
-        return TRUE;
-      }
+    if (user_access('administer site configuration')) {
+      drupal_set_message(t('Operating in off-line mode.'), 'status');
     }
     else {
-      $offline_message = t('Operating in off-line mode.');
-      $messages = drupal_set_message();
-      // Ensure that the off-line message is displayed only once [allowing for
-      // page redirects].
-      if (!isset($messages) || !isset($messages['status']) || !in_array($offline_message, $messages['status'])) {
-        drupal_set_message($offline_message);
+      // Logged in users are unprivileged here, so they are logged out.
+      if (user_is_logged_in()) {
+        drupal_goto('logout');
       }
+      // Anonymous users get a FALSE at the login prompt, TRUE otherwise.
+      return $_GET['q'] != 'user' && $_GET['q'] != 'user/login';
     }
   }
   return FALSE;

