You are here

function maintenance_exempt_menu_site_status_alter in Maintenance Exempt 7

Implements hook_menu_site_status_alter().

File

./maintenance_exempt.module, line 12
Allow exemption of maintenance mode based on either certain set IP addresses or matching a set query string value.

Code

function maintenance_exempt_menu_site_status_alter(&$menu_site_status, $path) {
  if ($menu_site_status == MENU_SITE_ONLINE) {

    // No need to check for exemption.
    return;
  }
  if (in_array($_SERVER['REQUEST_URI'], maintenance_exempt_get_urls())) {
    $menu_site_status = MENU_SITE_ONLINE;
    return;
  }
  if (maintenance_exempt_ip_match()) {
    $menu_site_status = MENU_SITE_ONLINE;
    return;
  }

  // Fetch the query string exemption key if there is one.
  $key = variable_get('maintenance_exempt_query_key', '');
  if ($key && isset($_GET[$key])) {

    // Grant exemption.
    $menu_site_status = MENU_SITE_ONLINE;
    $_SESSION['maintenance_exempt'] = $key;
    return;
  }

  // Exemption status may be stored in the session.
  if (isset($_SESSION['maintenance_exempt']) && $_SESSION['maintenance_exempt'] == $key) {
    $menu_site_status = MENU_SITE_ONLINE;
    return;
  }
}