From 7682706a46a20e3e58a9afd8ba208d5b0c040499 Mon Sep 17 00:00:00 2001 From: nickw Date: Fri, 7 May 2010 21:49:19 +0000 Subject: Adding an option to restrict new user registration in advanced site settings. This is the first step in fully merging "Walled Garden" plugin into core Elgg engine. git-svn-id: http://code.elgg.org/elgg/trunk@5981 36083f99-b078-4883-b0ff-0f9b5a30f544 --- actions/admin/site/update_advanced.php | 7 +++++++ actions/register.php | 2 +- actions/systemsettings/install.php | 1 + engine/lib/upgrades/2010050701.php | 15 +++++++++++++++ version.php | 2 +- views/default/account/forms/login.php | 4 +--- views/default/account/forms/login_dropdown.php | 7 ++----- views/default/admin/site/advanced.php | 8 ++++++++ 8 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 engine/lib/upgrades/2010050701.php diff --git a/actions/admin/site/update_advanced.php b/actions/admin/site/update_advanced.php index c9b78c261..7e6bd0cc6 100644 --- a/actions/admin/site/update_advanced.php +++ b/actions/admin/site/update_advanced.php @@ -49,6 +49,13 @@ if (datalist_get('default_site')) { } else { unset_config('debug', $site->getGUID()); } + + // allow new user registration? + if (get_input('allow_registration', FALSE)) { + set_config('allow_registration', TRUE, $site->getGUID()); + } else { + set_config('allow_registration', FALSE, $site->getGUID()); + } $https_login = get_input('https_login'); if ($https_login) { diff --git a/actions/register.php b/actions/register.php index 081a4e454..556bad4cd 100644 --- a/actions/register.php +++ b/actions/register.php @@ -24,7 +24,7 @@ if (is_array($admin)) { $admin = $admin[0]; } -if (!$CONFIG->disable_registration) { +if ($CONFIG->allow_registration) { // For now, just try and register the user try { $guid = register_user($username, $password, $name, $email, false, $friend_guid, $invitecode); diff --git a/actions/systemsettings/install.php b/actions/systemsettings/install.php index 589e3a06c..3516a2ff2 100644 --- a/actions/systemsettings/install.php +++ b/actions/systemsettings/install.php @@ -68,6 +68,7 @@ if (get_input('settings') == 'go') { set_config('view', get_input('view'), $site->getGUID()); set_config('language', get_input('language'), $site->getGUID()); set_config('default_access', get_input('default_access'), $site->getGUID()); + set_config('allow_registration', TRUE, $site->getGUID()); $debug = get_input('debug'); if ($debug) { diff --git a/engine/lib/upgrades/2010050701.php b/engine/lib/upgrades/2010050701.php new file mode 100644 index 000000000..33e4b5bae --- /dev/null +++ b/engine/lib/upgrades/2010050701.php @@ -0,0 +1,15 @@ +" . elgg_echo('username') . "
" . elgg_view('input/text', array('internalname' => 'username', 'class' => 'login_textarea')) . ""; $form_body .= "
"; $form_body .= "
"; @@ -19,7 +17,7 @@ $form_body .= elgg_view('input/hidden', array('internalname' => 'returntoreferer $form_body .= elgg_view('input/submit', array('value' => elgg_echo('login'))); $form_body .= "
"; $form_body .= "

"; -$form_body .= (!isset($CONFIG->disable_registration) || !($CONFIG->disable_registration)) ? "" . elgg_echo('register') . " | " : ""; +$form_body .= $CONFIG->allow_registration ? "" . elgg_echo('register') . ' | ' : ''; $form_body .= "" . elgg_echo('user:password:lost') . "

"; $login_url = $vars['url']; diff --git a/views/default/account/forms/login_dropdown.php b/views/default/account/forms/login_dropdown.php index 352e32e60..16f7ee78b 100644 --- a/views/default/account/forms/login_dropdown.php +++ b/views/default/account/forms/login_dropdown.php @@ -4,10 +4,7 @@ * */ -if (!isloggedin()){ - - global $CONFIG; - +if (!isloggedin()) { $form_body = "

" . elgg_view('input/text', array('internalname' => 'username', 'class' => 'login_textarea name')); $form_body .= "" . elgg_view('input/password', array('internalname' => 'password', 'class' => 'login_textarea')); $form_body .= elgg_view('input/submit', array('value' => elgg_echo('login'))) . "

"; @@ -15,7 +12,7 @@ if (!isloggedin()){ $form_body .= elgg_view('login/extend'); $form_body .= "

"; - $form_body .= (!isset($CONFIG->disable_registration) || !($CONFIG->disable_registration)) ? "" . elgg_echo('register') . " | " : ""; + $form_body .= $CONFIG->allow_registration ? "" . elgg_echo('register') . ' | ' : ''; $form_body .= "" . elgg_echo('user:password:lost') . "

"; $form_body .= ""; diff --git a/views/default/admin/site/advanced.php b/views/default/admin/site/advanced.php index da7b98a1a..e8c6e9b9a 100644 --- a/views/default/admin/site/advanced.php +++ b/views/default/admin/site/advanced.php @@ -33,6 +33,14 @@ $form_body .= "

" . elgg_echo('installation:debug'); $form_body .= elgg_view('input/pulldown', array('options_values' => $debug_options, 'internalname' => 'debug', 'value' => $vars['config']->debug)); $form_body .= '

'; +$options = array( + 'options' => array(elgg_echo('installation:registration:label')), + 'internalname' => 'allow_registration', + 'value' => $vars['config']->allow_registration ? elgg_echo('installation:registration:label') : '', +); +$form_body .= '

' . elgg_echo('installation:registration:description'); +$form_body .= '
' .elgg_view('input/checkboxes', $options) . '

'; + $form_body .= "

" . elgg_echo('installation:httpslogin') . "
" .elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:httpslogin:label')), 'internalname' => 'https_login', 'value' => ($vars['config']->https_login ? elgg_echo('installation:httpslogin:label') : "") )) . "

"; $form_body .= "

" . elgg_echo('installation:disableapi') . "
"; -- cgit v1.2.3