summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDries Buytaert2007-05-26 10:54:12 (GMT)
committerDries Buytaert2007-05-26 10:54:12 (GMT)
commit7f83d274b5eead1c1dc0a92036afccc11cdbd5d8 (patch)
treeee66a8007c134851abeecd194aa5c4c3d53810c6
parent1f864214976463f31fcf3645cb9ab4934c54d72c (diff)
- Patch #146937 by merlinofchaos: restore maintenance mode.
-rw-r--r--includes/common.inc1
-rw-r--r--includes/menu.inc29
2 files changed, 30 insertions, 0 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 7af6845..513b6fc 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -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',
diff --git a/includes/menu.inc b/includes/menu.inc
index 0750ddd..3ab496b 100644
--- a/includes/menu.inc
+++ b/includes/menu.inc
@@ -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;
+}