From 01df1d3301ab533e92e374594d8cb35692def491 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Fri, 17 Oct 2014 15:40:03 +0200 Subject: [PATCH 1/3] [ticket/11863] Grey out unavailable activation methods when emails disabled Further fall back to USER_ACTIVATION_DISABLE when emails are disabled but evaluate it at runtime. PHPBB3-11863 --- phpBB/includes/acp/acp_board.php | 19 +++++++++---------- phpBB/includes/ucp/ucp_register.php | 3 ++- phpBB/language/en/acp/board.php | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index f4f7512f0c..dd6c731abb 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -792,20 +792,19 @@ class acp_board global $user, $config; $act_ary = array( - 'ACC_DISABLE' => USER_ACTIVATION_DISABLE, - 'ACC_NONE' => USER_ACTIVATION_NONE, + 'ACC_DISABLE' => array(true, USER_ACTIVATION_DISABLE), + 'ACC_NONE' => array(true, USER_ACTIVATION_NONE), + 'ACC_USER' => array($config['email_enable'], USER_ACTIVATION_SELF), + 'ACC_ADMIN' => array($config['email_enable'], USER_ACTIVATION_ADMIN), ); - if ($config['email_enable']) - { - $act_ary['ACC_USER'] = USER_ACTIVATION_SELF; - $act_ary['ACC_ADMIN'] = USER_ACTIVATION_ADMIN; - } - $act_options = ''; - foreach ($act_ary as $key => $value) + $act_options = ''; + foreach ($act_ary as $key => $data) { + list($available, $value) = $data; $selected = ($selected_value == $value) ? ' selected="selected"' : ''; - $act_options .= ''; + $class = (!$available) ? ' class="disabled-option"' : ''; + $act_options .= ''; } return $act_options; diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index 9a15967bae..af21a6c1ed 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -33,7 +33,8 @@ class ucp_register global $request, $phpbb_container; // - if ($config['require_activation'] == USER_ACTIVATION_DISABLE) + if ($config['require_activation'] == USER_ACTIVATION_DISABLE || + (in_array($config['require_activation'], array(USER_ACTIVATION_SELF, USER_ACTIVATION_ADMIN)) && !$config['email_enable'])) { trigger_error('UCP_REGISTER_DISABLE'); } diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index ae7565d608..a2bfb43be7 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -221,7 +221,7 @@ $lang = array_merge($lang, array( 'ACP_REGISTER_SETTINGS_EXPLAIN' => 'Here you are able to define registration and profile related settings.', 'ACC_ACTIVATION' => 'Account activation', - 'ACC_ACTIVATION_EXPLAIN' => 'This determines whether users have immediate access to the board or if confirmation is required. You can also completely disable new registrations. “Board-wide email” must be enabled in order to use user or admin activation.', + 'ACC_ACTIVATION_EXPLAIN' => 'This determines whether users have immediate access to the board or if confirmation is required. You can also completely disable new registrations. “Board-wide email” must be enabled in order to use user or admin activation.', 'NEW_MEMBER_POST_LIMIT' => 'New member post limit', 'NEW_MEMBER_POST_LIMIT_EXPLAIN' => 'New members are within the Newly Registered Users group until they reach this number of posts. You can use this group to keep them from using the PM system or to review their posts. A value of 0 disables this feature.', 'NEW_MEMBER_GROUP_DEFAULT' => 'Set Newly Registered Users group to default', @@ -556,7 +556,7 @@ $lang = array_merge($lang, array( 'EMAIL_SIG' => 'Email signature', 'EMAIL_SIG_EXPLAIN' => 'This text will be attached to all emails the board sends.', 'ENABLE_EMAIL' => 'Enable board-wide emails', - 'ENABLE_EMAIL_EXPLAIN' => 'If this is set to disabled no emails will be sent by the board at all. Note the user and admin account activation settings require this setting to be enabled. If currently using “user” or “admin” activation in the activation settings, disabling this setting will require no activation of new accounts.', + 'ENABLE_EMAIL_EXPLAIN' => 'If this is set to disabled no emails will be sent by the board at all. Note the user and admin account activation settings require this setting to be enabled. If currently using “user” or “admin” activation in the activation settings, disabling this setting will disable registration.', 'SMTP_AUTH_METHOD' => 'Authentication method for SMTP', 'SMTP_AUTH_METHOD_EXPLAIN' => 'Only used if a username/password is set, ask your provider if you are unsure which method to use.', 'SMTP_CRAM_MD5' => 'CRAM-MD5', From f049fcd6046bbbeea035b02a78638bbacee7dce1 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Fri, 17 Oct 2014 15:42:11 +0200 Subject: [PATCH 2/3] [ticket/11863] Display warning to user because of activation method PHPBB3-11863 --- phpBB/includes/acp/acp_board.php | 10 +++++++++- phpBB/language/en/acp/board.php | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index dd6c731abb..63e2647f02 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -615,7 +615,15 @@ class acp_board { add_log('admin', 'LOG_CONFIG_' . strtoupper($mode)); - trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action)); + $message = $user->lang('CONFIG_UPDATED'); + $message_type = E_USER_NOTICE; + if (!$config['email_enable'] && in_array($mode, array('email', 'registration')) && + in_array($config['require_activation'], array(USER_ACTIVATION_SELF, USER_ACTIVATION_ADMIN))) + { + $message .= '

' . $user->lang('ACC_ACTIVATION_WARNING'); + $message_type = E_USER_WARNING; + } + trigger_error($message . adm_back_link($this->u_action), $message_type); } $this->tpl_name = 'acp_board'; diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index a2bfb43be7..8d6c1c141d 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -222,6 +222,7 @@ $lang = array_merge($lang, array( 'ACC_ACTIVATION' => 'Account activation', 'ACC_ACTIVATION_EXPLAIN' => 'This determines whether users have immediate access to the board or if confirmation is required. You can also completely disable new registrations. “Board-wide email” must be enabled in order to use user or admin activation.', + 'ACC_ACTIVATION_WARNING' => 'Please note that the currently selected activation method requires emails to be enabled, otherwise registration will be disabled. We recommend to either select a different activation method or reenable emails.', 'NEW_MEMBER_POST_LIMIT' => 'New member post limit', 'NEW_MEMBER_POST_LIMIT_EXPLAIN' => 'New members are within the Newly Registered Users group until they reach this number of posts. You can use this group to keep them from using the PM system or to review their posts. A value of 0 disables this feature.', 'NEW_MEMBER_GROUP_DEFAULT' => 'Set Newly Registered Users group to default', From 0ba3bd9aed71a6a9eecacd9bff3ecc6a3d778057 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Fri, 17 Oct 2014 21:06:13 +0200 Subject: [PATCH 3/3] [ticket/11863] Add functional test PHPBB3-11863 --- tests/functional/acp_registration_test.php | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tests/functional/acp_registration_test.php diff --git a/tests/functional/acp_registration_test.php b/tests/functional/acp_registration_test.php new file mode 100644 index 0000000000..ef9843679e --- /dev/null +++ b/tests/functional/acp_registration_test.php @@ -0,0 +1,55 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +/** +* @group functional +*/ +class phpbb_functional_acp_registration_test extends phpbb_functional_test_case +{ + protected function set_email_enable($db, $status) + { + $sql = "UPDATE phpbb_config + SET config_value = '" . (($status) ? '1' : '0') . "' + WHERE config_name = 'email_enable'"; + $db->sql_query($sql); + + $this->purge_cache(); + } + + public function test_submitting_activation_method() + { + $db = $this->get_db(); + + $this->set_email_enable($db, false); + + $this->add_lang('acp/board'); + $this->login(); + $this->admin_login(); + + $crawler = self::request('GET', 'adm/index.php?i=acp_board&mode=registration&sid=' . $this->sid); + $this->assertContainsLang('ACP_REGISTER_SETTINGS_EXPLAIN', $this->get_content()); + + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['config[require_activation]']->select(USER_ACTIVATION_ADMIN); + $crawler = self::submit($form); + $this->assertContainsLang('ACC_ACTIVATION_WARNING', $crawler->filter('div.main')->text()); + + $crawler = self::request('GET', 'adm/index.php?i=acp_board&mode=registration&sid=' . $this->sid); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['config[require_activation]']->select(USER_ACTIVATION_NONE); + $crawler = self::submit($form); + $this->assertNotContainsLang('ACC_ACTIVATION_WARNING', $crawler->filter('div.main')->text()); + + $this->set_email_enable($db, true); + } +}