summaryrefslogtreecommitdiff
path: root/includes/menu.inc
diff options
context:
space:
mode:
Diffstat (limited to 'includes/menu.inc')
-rw-r--r--includes/menu.inc29
1 files changed, 29 insertions, 0 deletions
diff --git a/includes/menu.inc b/includes/menu.inc
index 0750dddcc..3ab496bfd 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;
+}