diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-08-22 18:24:14 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-08-22 18:24:14 +0000 |
commit | a9762cd3bf93ac8bbcafec23328c3ecde9d1498a (patch) | |
tree | 4a7abe998616a563a6471b3ac8915a943fcdeaa1 /includes | |
parent | 4cbe60a533acc3d30da5ddd68f932d79982eeeff (diff) | |
download | brdo-a9762cd3bf93ac8bbcafec23328c3ecde9d1498a.tar.gz brdo-a9762cd3bf93ac8bbcafec23328c3ecde9d1498a.tar.bz2 |
#201415 by sun: Add a permission to access site in maintenance mode.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/common.inc | 4 | ||||
-rw-r--r-- | includes/menu.inc | 35 | ||||
-rw-r--r-- | includes/update.inc | 26 |
3 files changed, 39 insertions, 26 deletions
diff --git a/includes/common.inc b/includes/common.inc index a7947828e..767d0c400 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -390,8 +390,8 @@ function drupal_goto($path = '', $query = NULL, $fragment = NULL, $http_response function drupal_site_offline() { drupal_maintenance_theme(); drupal_set_header('503 Service unavailable'); - drupal_set_title(t('Site offline')); - print theme('maintenance_page', filter_xss_admin(variable_get('site_offline_message', + drupal_set_title(t('Site under maintenance')); + print theme('maintenance_page', filter_xss_admin(variable_get('maintenance_mode_message', t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => variable_get('site_name', 'Drupal')))))); } diff --git a/includes/menu.inc b/includes/menu.inc index 2fe2159ff..e3e5e724f 100644 --- a/includes/menu.inc +++ b/includes/menu.inc @@ -2744,32 +2744,37 @@ function menu_path_is_external($path) { } /** - * Checks whether the site is offline for maintenance. + * Checks whether the site is in maintenance mode. * * This function will log the current user out and redirect to front page - * if the current user has no 'administer site configuration' permission. + * if the current user has no 'access site in maintenance mode' permission. * * @return - * FALSE if the site is not offline 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 offline. + * FALSE if the site is not in maintenance mode, the user login page is + * displayed, or the user has the 'access site in maintenance mode' + * permission. TRUE for anonymous users not being on the login page when the + * site is in maintenance mode. */ function _menu_site_is_offline() { - // Check if site is set to maintenance mode. - if (variable_get('site_offline', 0)) { - // Check if the user has administration privileges. - if (user_access('administer site configuration')) { - // Ensure that the offline 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/config/development/maintenance') { - drupal_set_message(t('Operating in maintenance mode. <a href="@url">Go online.</a>', array('@url' => url('admin/config/development/maintenance'))), 'status', FALSE); + // Check if site is in maintenance mode. + if (variable_get('maintenance_mode', 0)) { + if (user_access('access site in maintenance mode')) { + // Ensure that the maintenance mode message is displayed only once + // (allowing for page redirects) and specifically suppress its display on + // the maintenance mode settings page. + if ($_GET['q'] != 'admin/config/development/maintenance') { + if (user_access('administer site configuration')) { + drupal_set_message(t('Operating in maintenance mode. <a href="@url">Go online.</a>', array('@url' => url('admin/config/development/maintenance'))), 'status', FALSE); + } + else { + drupal_set_message(t('Operating in maintenance mode.'), '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'; + return ($_GET['q'] != 'user' && $_GET['q'] != 'user/login'); } // Logged in users are unprivileged here, so they are logged out. require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'user') . '/user.pages.inc'; diff --git a/includes/update.inc b/includes/update.inc index efe0d8535..4878e7db6 100644 --- a/includes/update.inc +++ b/includes/update.inc @@ -232,6 +232,7 @@ function update_prepare_d7_bootstrap() { * made which make it impossible to continue using the prior version. */ function update_fix_d7_requirements() { + global $conf; $ret = array(); // Rewrite the settings.php file if necessary. @@ -242,17 +243,24 @@ function update_fix_d7_requirements() { file_put_contents(conf_path() . '/settings.php', "\n" . '$databases = ' . var_export($databases, TRUE) . ';', FILE_APPEND); } if (drupal_get_installed_schema_version('system') < 7000 && !variable_get('update_d7_requirements', FALSE)) { - // Add the cache_path table. $schema['cache_path'] = drupal_get_schema_unprocessed('system', 'cache'); $schema['cache_path']['description'] = 'Cache table used for path alias lookups.'; db_create_table($ret, 'cache_path', $schema['cache_path']); - variable_set('update_d7_requirements', TRUE); // Add column for locale context. if (db_table_exists('locales_source')) { db_add_field($ret, 'locales_source', 'context', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', 'description' => 'The context this string applies to.')); } + + // Rename 'site_offline_message' variable to 'maintenance_mode_message'. + // Old variable is removed in update for system.module. + // @see system_update_7036(). + if ($message = variable_get('site_offline_message', NULL)) { + variable_set('maintenance_mode_message', $message); + } + + variable_set('update_d7_requirements', TRUE); } update_fix_d7_install_profile(); @@ -423,9 +431,9 @@ function update_do_one($module, $number, &$context) { function update_batch($start, $redirect = NULL, $url = NULL, $batch = array()) { // During the update, bring the site offline so that schema changes do not // affect visiting users. - $_SESSION['site_offline'] = variable_get('site_offline', FALSE); - if ($_SESSION['site_offline'] == FALSE) { - variable_set('site_offline', TRUE); + $_SESSION['maintenance_mode'] = variable_get('maintenance_mode', FALSE); + if ($_SESSION['maintenance_mode'] == FALSE) { + variable_set('maintenance_mode', TRUE); } $operations = array(); @@ -480,10 +488,10 @@ function update_finished($success, $results, $operations) { $_SESSION['updates_remaining'] = $operations; // Now that the update is done, we can put the site back online if it was - // previously turned off. - if (isset($_SESSION['site_offline']) && $_SESSION['site_offline'] == FALSE) { - variable_set('site_offline', FALSE); - unset($_SESSION['site_offline']); + // previously in maintenance mode. + if (isset($_SESSION['maintenance_mode']) && $_SESSION['maintenance_mode'] == FALSE) { + variable_set('maintenance_mode', FALSE); + unset($_SESSION['maintenance_mode']); } } |