function _menu_site_is_offline in Drupal 6
Same name and namespace in other branches
- 4 includes/menu.inc \_menu_site_is_offline()
- 5 includes/menu.inc \_menu_site_is_offline()
- 7 includes/menu.inc \_menu_site_is_offline()
Checks whether the site is off-line for maintenance.
This function will log the current user out and redirect to front page if the current user has no 'administer site configuration' permission.
Return value
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.
Related topics
1 call to _menu_site_is_offline()
- menu_execute_active_handler in includes/
menu.inc - Execute the page callback associated with the current path
File
- includes/
menu.inc, line 2483 - API for the Drupal menu system.
Code
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')) {
// Ensure that the off-line message is displayed only once [allowing for
// page redirects], and specifically suppress its display on the site
// maintenance page.
if (drupal_get_normal_path($_GET['q']) != 'admin/settings/site-maintenance') {
drupal_set_message(l(t('Operating in off-line mode.'), 'admin/settings/site-maintenance'), 'status', FALSE);
}
}
else {
// Anonymous users get a FALSE at the login prompt, TRUE otherwise.
if (user_is_anonymous()) {
return $_GET['q'] != 'user' && $_GET['q'] != 'user/login';
}
// Logged in users are unprivileged here, so they are logged out.
require_once drupal_get_path('module', 'user') . '/user.pages.inc';
user_logout();
}
}
return FALSE;
}