diff options
author | Dries Buytaert <dries@buytaert.net> | 2005-10-08 12:38:20 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2005-10-08 12:38:20 +0000 |
commit | 709b9005f57be838f3a0d4f516dd0d755d2ee5f2 (patch) | |
tree | edf195b69d20283c34496f861e0230b7f7b61c1e /includes | |
parent | 7863be5e82ccfbaa4aa9bac2343ad9e560130b44 (diff) | |
download | brdo-709b9005f57be838f3a0d4f516dd0d755d2ee5f2.tar.gz brdo-709b9005f57be838f3a0d4f516dd0d755d2ee5f2.tar.bz2 |
- Modified version of patch #32622 by kbahey: added 'site offline/maintenance' feature.
(Untested because the admin/settings page doesn't work yet.)
Diffstat (limited to 'includes')
-rw-r--r-- | includes/common.inc | 11 | ||||
-rw-r--r-- | includes/menu.inc | 21 |
2 files changed, 32 insertions, 0 deletions
diff --git a/includes/common.inc b/includes/common.inc index 6f348500b..dc7a41afd 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -252,6 +252,17 @@ function drupal_goto($path = '', $query = NULL, $fragment = NULL) { exit(); } + +/** + * Generates a site offline message + */ +function drupal_site_offline() { + header('HTTP/1.0 503 Service unavailable'); + drupal_set_title(t('Site offline')); + print theme('maintenance_page', variable_get('site_offline_message', + t('%site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('%site' => variable_get('site_name', t('This drupal site')))))); +} + /** * Generates a 404 error if the request can not be handled. */ diff --git a/includes/menu.inc b/includes/menu.inc index ee8875b22..826d1c0ed 100644 --- a/includes/menu.inc +++ b/includes/menu.inc @@ -164,6 +164,7 @@ define('MENU_CUSTOM_MENU', MENU_IS_ROOT | MENU_VISIBLE_IN_TREE | MENU_CREATED_BY define('MENU_FOUND', 1); define('MENU_NOT_FOUND', 2); define('MENU_ACCESS_DENIED', 3); +define('MENU_SITE_OFFLINE', 4); /** * @} End of "Menu status codes". @@ -324,6 +325,10 @@ function menu_set_location($location) { * act as if the user were in a different location on the site. */ function menu_execute_active_handler() { + if (_menu_site_is_offline()) { + return MENU_SITE_OFFLINE; + } + $menu = menu_get_menu(); // Determine the menu item containing the callback. @@ -1040,3 +1045,19 @@ function _menu_build_local_tasks($pid) { return $forked; } +/** + * Returns TRUE if the is offline for maintenance. + */ +function _menu_site_is_offline() { + // Check if site is set to offline 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/login') { + return TRUE; + } + } + } + return FALSE; +} |