Commit 7f83d274 authored by Dries's avatar Dries

- Patch #146937 by merlinofchaos: restore maintenance mode.

parent 1f864214
......@@ -320,6 +320,7 @@ function drupal_goto($path = '', $query = NULL, $fragment = NULL, $http_response
* Generates a site off-line message
*/
function drupal_site_offline() {
drupal_maintenance_theme();
drupal_set_header('HTTP/1.1 503 Service unavailable');
drupal_set_title(t('Site off-line'));
print theme('maintenance_page', filter_xss_admin(variable_get('site_offline_message',
......
......@@ -305,6 +305,10 @@ function menu_get_item($path = NULL) {
* Execute the page callback associated with the current path
*/
function menu_execute_active_handler() {
if (_menu_site_is_offline()) {
return MENU_SITE_OFFLINE;
}
if ($item = menu_get_item()) {
if ($item->access) {
if ($item->file) {
......@@ -1462,3 +1466,28 @@ function menu_path_is_external($path) {
$colonpos = strpos($path, ':');
return $colonpos !== FALSE && !preg_match('![/?#]!', substr($path, 0, $colonpos)) && filter_xss_bad_protocol($path, FALSE) == check_plain($path);
}
/**
* Returns TRUE if the site is off-line for maintenance.
*/
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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment