From 3e07263ae9023ba39c6644b411860984dfee4d9b Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Sun, 30 Jun 2013 12:29:52 +0200 Subject: [PATCH] Removed registration configuration option * Removed old registration configuration option from config file * Changed database registration option to allow registrations by default * Changed admin settings template for new DB option * Changed registration controllers for new DB option Fixes an issue with registrations not working if settings table is empty. --- public/include/config/global.inc.dist.php | 1 - public/include/pages/admin/settings.inc.php | 3 ++- public/include/pages/register.inc.php | 2 +- public/include/pages/register/register.inc.php | 8 ++++---- .../templates/mmcFE/admin/settings/default.tpl | 16 +++++++++++++--- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/public/include/config/global.inc.dist.php b/public/include/config/global.inc.dist.php index 8f28e8df..cf67a425 100644 --- a/public/include/config/global.inc.dist.php +++ b/public/include/config/global.inc.dist.php @@ -39,7 +39,6 @@ $config = array( 'theme' => 'mmcFE', // Overall default theme 'mobile' => true, // Allow overwriting theme for mobile devices 'mobile_theme' => 'mobile', // Set default or custom mobile theme - 'registration' => true, // Allow new users to register 'name' => 'The Pool', 'slogan' => 'Resistance is futile', 'email' => 'test@example.com', // Mail address used for notifications diff --git a/public/include/pages/admin/settings.inc.php b/public/include/pages/admin/settings.inc.php index ecea2d02..d831d024 100644 --- a/public/include/pages/admin/settings.inc.php +++ b/public/include/pages/admin/settings.inc.php @@ -18,7 +18,8 @@ if ($_REQUEST['do'] == 'save' && !empty($_REQUEST['data'])) { // Fetch settings to propagate to template $smarty->assign("MAINTENANCE", $setting->getValue('maintenance')); -$smarty->assign("REGISTRATION", $setting->getValue('registration')); +var_dump($setting->getValue('lock_registration')); +$smarty->assign("LOCKREGISTRATION", $setting->getValue('lock_registration')); // Tempalte specifics $smarty->assign("CONTENT", "default.tpl"); diff --git a/public/include/pages/register.inc.php b/public/include/pages/register.inc.php index 0d3df916..d47c67ed 100644 --- a/public/include/pages/register.inc.php +++ b/public/include/pages/register.inc.php @@ -3,7 +3,7 @@ // Make sure we are called from index.php if (!defined('SECURITY')) die('Hacking attempt'); -if (!$config['website']['registration'] || !$setting->getValue('registration')) { +if ($setting->getValue('lock_registration')) { $_SESSION['POPUP'][] = array('CONTENT' => 'Account registration is currently disabled. Please try again later.', 'TYPE' => 'errormsg'); $smarty->assign("CONTENT", "disabled.tpl"); } else { diff --git a/public/include/pages/register/register.inc.php b/public/include/pages/register/register.inc.php index 063c5cc4..01a27e10 100644 --- a/public/include/pages/register/register.inc.php +++ b/public/include/pages/register/register.inc.php @@ -17,9 +17,9 @@ if ($config['recaptcha']['enabled']) { if($config['recaptcha']['enabled'] && $_POST["recaptcha_response_field"] && $_POST["recaptcha_response_field"]!=''){ if ($rsp->is_valid) { $smarty->assign("RECAPTCHA", recaptcha_get_html($config['recaptcha']['public_key'])); - if (!$config['website']['registration'] || !$setting->getValue('registration')) { + if ($setting->getValue('lock_registration')) { $_SESSION['POPUP'][] = array('CONTENT' => 'Account registration is currently disabled. Please try again later.', 'TYPE' => 'errormsg'); - } else if ($user->register($_POST['username'], $_POST['password1'], $_POST['password2'], $_POST['pin'], $_POST['email1'], $_POST['email2']) && ($config['website']['registration'] || $setting->getValue('registration'))) { + } else if ($user->register($_POST['username'], $_POST['password1'], $_POST['password2'], $_POST['pin'], $_POST['email1'], $_POST['email2']) && !$setting->getValue('lock_registration')) { $_SESSION['POPUP'][] = array('CONTENT' => 'Account created, please login'); } else { $_SESSION['POPUP'][] = array('CONTENT' => 'Unable to create account: ' . $user->getError(), 'TYPE' => 'errormsg'); @@ -34,9 +34,9 @@ if($config['recaptcha']['enabled'] && $_POST["recaptcha_response_field"] && $_PO $_SESSION['POPUP'][] = array('CONTENT' => 'Empty Captcha, please try again.', 'TYPE' => 'errormsg'); // Captcha disabled } else { - if (!$config['website']['registration'] || !$setting->getValue('registration')) { + if ($setting->getValue('lock_registration')) { $_SESSION['POPUP'][] = array('CONTENT' => 'Account registration is currently disabled. Please try again later.', 'TYPE' => 'errormsg'); - } else if ($user->register($_POST['username'], $_POST['password1'], $_POST['password2'], $_POST['pin'], $_POST['email1'], $_POST['email2']) && $config['website']['registration']) { + } else if ($user->register($_POST['username'], $_POST['password1'], $_POST['password2'], $_POST['pin'], $_POST['email1'], $_POST['email2']) && !$setting->getValue('lock_registration')) { $_SESSION['POPUP'][] = array('CONTENT' => 'Account created, please login'); } else { $_SESSION['POPUP'][] = array('CONTENT' => 'Unable to create account: ' . $user->getError(), 'TYPE' => 'errormsg'); diff --git a/public/templates/mmcFE/admin/settings/default.tpl b/public/templates/mmcFE/admin/settings/default.tpl index f7bca77e..3cd67f4e 100644 --- a/public/templates/mmcFE/admin/settings/default.tpl +++ b/public/templates/mmcFE/admin/settings/default.tpl @@ -13,12 +13,22 @@ Maintenance Mode - + + + - User Registration + Disable Registration - + + +