From 7c5d2ebc95acf8a79e07a88fe66f4f43245a148f Mon Sep 17 00:00:00 2001 From: Mathew May Date: Mon, 22 Jul 2019 12:41:24 +0800 Subject: [PATCH] MDL-50472 auth: Add maintenance message to the login page. --- auth/classes/output/login.php | 7 +++++++ lib/templates/loginform.mustache | 19 ++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/auth/classes/output/login.php b/auth/classes/output/login.php index 7034e978f51..c98048b9327 100644 --- a/auth/classes/output/login.php +++ b/auth/classes/output/login.php @@ -72,6 +72,8 @@ class login implements renderable, templatable { public $username; /** @var string The csrf token to limit login to requests that come from the login form. */ public $logintoken; + /** @var string Maintenance message, if Maintenance is enabled. */ + public $maintenance; /** * Constructor. @@ -109,6 +111,10 @@ class login implements renderable, templatable { $this->instructions = get_string('loginsteps', 'core', 'signup.php'); } + if ($CFG->maintenance_enabled == true && !empty($CFG->maintenance_message)) { + $this->maintenance = $CFG->maintenance_message; + } + // Identity providers. $this->identityproviders = \auth_plugin_base::get_identity_providers($authsequence); $this->logintoken = \core\session\manager::get_login_token(); @@ -145,6 +151,7 @@ class login implements renderable, templatable { $data->signupurl = $this->signupurl->out(false); $data->username = $this->username; $data->logintoken = $this->logintoken; + $data->maintenance = format_text($this->maintenance, FORMAT_MOODLE); return $data; } diff --git a/lib/templates/loginform.mustache b/lib/templates/loginform.mustache index 9448feab522..b9e1598b8f6 100644 --- a/lib/templates/loginform.mustache +++ b/lib/templates/loginform.mustache @@ -36,7 +36,8 @@ "signupurl": "http://localhost/stable_master/login/signup.php", "cookieshelpiconformatted": "", "username": "", - "logintoken": "randomstring" + "logintoken": "randomstring", + "maintenance": "For full access to this site, you need to login in as an admin." } }} {{#hasinstructions}} @@ -163,6 +164,22 @@ +{{#maintenance}} +
+
+
+
+
+

{{#str}}sitemaintenance, core_admin{{/str}}

+
+
+ {{{maintenance}}} +
+
+
+
+
+{{/maintenance}} {{#js}} {{#error}} require(['jquery'], function($) {