summaryrefslogtreecommitdiff
path: root/modules/system
diff options
context:
space:
mode:
Diffstat (limited to 'modules/system')
-rw-r--r--modules/system/system.api.php25
-rw-r--r--modules/system/system.test19
2 files changed, 42 insertions, 2 deletions
diff --git a/modules/system/system.api.php b/modules/system/system.api.php
index 497eb9155..f2616ec13 100644
--- a/modules/system/system.api.php
+++ b/modules/system/system.api.php
@@ -3961,5 +3961,30 @@ function hook_filetransfer_backends() {
}
/**
+ * Control site status before menu dispatching.
+ *
+ * The hook is called after checking whether the site is offline but before
+ * the current router item is retrieved and executed by
+ * menu_execute_active_handler(). If the site is in offline mode,
+ * $menu_site_status is set to MENU_SITE_OFFLINE.
+ *
+ * @param $menu_site_status
+ * Supported values are MENU_SITE_OFFLINE, MENU_ACCESS_DENIED,
+ * MENU_NOT_FOUND and MENU_SITE_ONLINE. Any other value than
+ * MENU_SITE_ONLINE will skip the default menu handling system and be passed
+ * for delivery to drupal_deliver_page() with a NULL
+ * $default_delivery_callback.
+ * @param $path
+ * Contains the system path that is going to be loaded. This is read only,
+ * use hook_url_inbound_alter() to change the path.
+ */
+function hook_menu_site_status_alter(&$menu_site_status, $path) {
+ // Allow access to my_module/authentication even if site is in offline mode.
+ if ($menu_site_status == MENU_SITE_OFFLINE && user_is_anonymous() && $path == 'my_module/authentication') {
+ $menu_site_status = MENU_SITE_ONLINE;
+ }
+}
+
+/**
* @} End of "addtogroup hooks".
*/
diff --git a/modules/system/system.test b/modules/system/system.test
index 7d6619802..e456e3744 100644
--- a/modules/system/system.test
+++ b/modules/system/system.test
@@ -770,8 +770,6 @@ class SiteMaintenanceTestCase extends DrupalWebTestCase {
$this->assertText($offline_message);
$this->drupalGet('user/register');
$this->assertText($offline_message);
- $this->drupalGet('user/password');
- $this->assertText($offline_message);
// Verify that user is able to log in.
$this->drupalGet('user');
@@ -804,6 +802,23 @@ class SiteMaintenanceTestCase extends DrupalWebTestCase {
$this->drupalLogout();
$this->drupalGet('');
$this->assertRaw($offline_message, t('Found the site offline message.'));
+
+ // Verify that custom site offline message is not displayed on user/password.
+ $this->drupalGet('user/password');
+ $this->assertText(t('Username or e-mail address'), t('Anonymous users can access user/password'));
+
+ // Submit password reset form.
+ $edit = array(
+ 'name' => $this->user->name,
+ );
+ $this->drupalPost('user/password', $edit, t('E-mail new password'));
+ $mails = $this->drupalGetMails();
+ $start = strpos($mails[0]['body'], 'user/reset/'. $this->user->uid);
+ $path = substr($mails[0]['body'], $start, 66 + strlen($this->user->uid));
+
+ // Log in with temporary login link.
+ $this->drupalPost($path, array(), t('Log in'));
+ $this->assertText($user_message);
}
}