summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/controllers/Users.class.php21
-rw-r--r--src/views/pages/users/new-locked.html.php9
2 files changed, 29 insertions, 1 deletions
diff --git a/src/controllers/Users.class.php b/src/controllers/Users.class.php
index a5d23fc..27efbcd 100644
--- a/src/controllers/Users.class.php
+++ b/src/controllers/Users.class.php
@@ -22,7 +22,12 @@ class Users extends Controller {
switch ($method) {
case 'POST':
// We're POSTing a new user.
- $this->create_user();
+ if ($this->registrationOpen()) {
+ $this->create_user();
+ } else {
+ $this->showView('users/new-locked', array());
+ exit();
+ }
break;
case 'HEAD': // fall-through to GET
case 'GET':
@@ -61,6 +66,10 @@ class Users extends Controller {
$this->showView('users/new-logged-in', array());
exit();
}
+ if (!$this->registrationOpen()) {
+ $this->showView('users/new-locked', array());
+ exit();
+ }
if (!isset($vars['errors'])) $vars['errors'] = array();
global $mm; $pm = $mm->pluginManager();
$vars['antispam_html'] = $pm->callHook('antispam_html');
@@ -404,4 +413,14 @@ class Users extends Controller {
$attribs[] = $this->attrib('auth_name', 'Username');
return $attribs;
}
+
+ private function registrationOpen() {
+ global $mm; $db = $mm->database();
+ $val = $db->getSysConf('registration_open');
+ switch ($val) {
+ case 'true': return true;
+ case 'false': return false;
+ default: return true;
+ }
+ }
}
diff --git a/src/views/pages/users/new-locked.html.php b/src/views/pages/users/new-locked.html.php
new file mode 100644
index 0000000..dc7ad0d
--- /dev/null
+++ b/src/views/pages/users/new-locked.html.php
@@ -0,0 +1,9 @@
+<?php global $VARS;
+$t = $VARS['template'];
+
+$t->status('403 Forbidden');
+$t->header('Create new user');
+
+$t->paragraph("Sorry, new user registration is disabled.");
+
+$t->footer();