Skip to content

Commit 328f918

Browse files
MDL-50472 auth: Add maintenance message to the login page.
1 parent 1a89704 commit 328f918

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

auth/classes/output/login.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ class login implements renderable, templatable {
7272
public $username;
7373
/** @var string The csrf token to limit login to requests that come from the login form. */
7474
public $logintoken;
75+
/** @var string Maintenance message, if Maintenance is enabled. */
76+
public $maintenance;
7577

7678
/**
7779
* Constructor.
@@ -109,6 +111,10 @@ public function __construct(array $authsequence, $username = '') {
109111
$this->instructions = get_string('loginsteps', 'core', 'signup.php');
110112
}
111113

114+
if ($CFG->maintenance_enabled == true && !empty($CFG->maintenance_message)) {
115+
$this->maintenance = $CFG->maintenance_message;
116+
}
117+
112118
// Identity providers.
113119
$this->identityproviders = \auth_plugin_base::get_identity_providers($authsequence);
114120
$this->logintoken = \core\session\manager::get_login_token();
@@ -145,6 +151,7 @@ public function export_for_template(renderer_base $output) {
145151
$data->signupurl = $this->signupurl->out(false);
146152
$data->username = $this->username;
147153
$data->logintoken = $this->logintoken;
154+
$data->maintenance = format_text($this->maintenance, FORMAT_MOODLE);
148155

149156
return $data;
150157
}

lib/templates/loginform.mustache

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@
3838
* cookieshelpiconformatted - Formatted html of cookies help icon,
3939
* errorformatted - Formatted error,
4040
* logourl - Flag, logo url,
41-
* sitename - Name of site.
42-
* logintoken - Random token to protect login request.
41+
* sitename - Name of site.,
42+
* logintoken - Random token to protect login request.,
43+
* maintenance - Maintenance message
4344
4445
Example context (json):
4546
{
@@ -89,7 +90,8 @@
8990
"errorformatted": "",
9091
"logourl": false,
9192
"sitename": "Beer & Chips",
92-
"logintoken": "randomstring"
93+
"logintoken": "randomstring",
94+
"maintenance": "For full access to this site, you need to login in as an admin."
9395
}
9496
}}
9597

@@ -224,6 +226,22 @@
224226
</div>
225227
{{/hasinstructions}}
226228

229+
{{#maintenance}}
230+
<div class="row justify-content-center mt-3">
231+
<div class="col-xl-6 col-sm-8">
232+
<div class="card">
233+
<div class="card-body">
234+
<div class="card-title">
235+
<h2>{{#str}}sitemaintenance, core_admin{{/str}}</h2>
236+
</div>
237+
<div>
238+
{{{maintenance}}}
239+
</div>
240+
</div>
241+
</div>
242+
</div>
243+
</div>
244+
{{/maintenance}}
227245
{{#js}}
228246
{{#error}}
229247
require(['jquery'], function($) {

0 commit comments

Comments
 (0)