Skip to content

Commit f514109

Browse files
committed
Hide register form if register is disabled
1 parent f2b688a commit f514109

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/controllers/User/Register.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ public function &run(Router &$router, View &$view, array &$args) {
3838
$model->username_max_len =
3939
$conf->bnetdocs->user_register_requirements->username_length_max;
4040

41-
if ($router->getRequestMethod() == 'POST') {
41+
if (Common::$config->bnetdocs->user_register_disabled) {
42+
$model->error = 'REGISTER_DISABLED';
43+
} else if ($router->getRequestMethod() == 'POST') {
4244
$this->tryRegister($router, $model);
4345
}
4446

src/templates/User/Register.phtml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ switch ($this->getContext()->error) {
7171
break;
7272
case "REGISTER_DISABLED":
7373
$af = null;
74-
$message = "Creating accounts has been administratively disabled "
75-
. "indefinitely.";
74+
$message = "Creating accounts is currently administratively disabled.";
7675
break;
7776
case "EMAIL_ALREADY_USED":
7877
$af = "email";
@@ -96,6 +95,8 @@ switch ($this->getContext()->error) {
9695
$message = $this->getContext()->error;
9796
}
9897

98+
$register_disabled = ($this->getContext()->error == 'REGISTER_DISABLED');
99+
99100
$safe_email = htmlentities($this->getContext()->email , ENT_HTML5, "UTF-8");
100101
$safe_username = htmlentities($this->getContext()->username, ENT_HTML5, "UTF-8");
101102

@@ -105,12 +106,13 @@ require("./header.inc.phtml");
105106
<article>
106107
<?php if ($this->getContext()->error !== false) { ?>
107108
<script async defer="defer" src="https://www.google.com/recaptcha/api.js"><![CDATA[]]></script>
108-
<header>Create Account</header>
109+
<header<?=($register_disabled ? ' class="red"' : '')?>>Create Account</header>
109110
<?php if (!empty($message)) { ?>
110111
<section class="red">
111112
<p><?php echo $message; ?></p>
112113
</section>
113114
<?php } ?>
115+
<?php if (!$register_disabled) { ?>
114116
<form method="POST" action="?">
115117
<section>
116118
<table><tbody><tr>
@@ -138,6 +140,7 @@ require("./header.inc.phtml");
138140
</tr></tbody></table>
139141
</section>
140142
</form>
143+
<?php } ?>
141144
<?php } else { ?>
142145
<header class="green">Account Created</header>
143146
<section class="green">

0 commit comments

Comments
 (0)