Community Documentation

_menu_site_is_offline

5 menu.inc _menu_site_is_offline()
6 menu.inc _menu_site_is_offline()
7 menu.inc _menu_site_is_offline($check_only = FALSE)
8 menu.inc _menu_site_is_offline($check_only = FALSE)

Returns TRUE if the site is off-line for maintenance.

File

includes/menu.inc, line 1344
API for the Drupal menu system.

Code

<?php
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;
      }
    }
    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);
      }
    }
  }
  return FALSE;
}
?>
Login or register to post comments