From 587241f3a9d5003f46699ec9fa9d44c7ca77edb2 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 15 Feb 2014 02:26:43 +0100 Subject: [PATCH 1/4] [ticket/12176] Add functional test for founder deletion message. PHPBB3-12176 --- tests/functional/acp_users_test.php | 45 +++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tests/functional/acp_users_test.php diff --git a/tests/functional/acp_users_test.php b/tests/functional/acp_users_test.php new file mode 100644 index 0000000000..50d9a67dc1 --- /dev/null +++ b/tests/functional/acp_users_test.php @@ -0,0 +1,45 @@ +login(); + $this->admin_login(); + $this->add_lang('acp/users'); + } + + public function test_founder_deletion() + { + $username = 'founder-account'; + $user_id = $this->create_user($username); + $this->make_founder($user_id); + + $crawler = self::request('GET', "adm/index.php?i=users&mode=overview&u=$user_id&sid={$this->sid}"); + $form = $crawler->filter('#user_delete')->selectButton($this->lang('SUBMIT'))->form(); + $crawler = self::submit($form); + $this->assertContains($this->lang('CANNOT_REMOVE_FOUNDER'), $this->get_content()); + } + + protected function make_founder($user_id) + { + $crawler = self::request('GET', "adm/index.php?i=users&mode=overview&u=$user_id&sid={$this->sid}"); + $form = $crawler->filter('#user_overview')->selectButton($this->lang('SUBMIT'))->form(); + $data = array('user_founder' => '1'); + $form->setValues($data); + $crawler = self::submit($form); + $this->assertContains($this->lang('USER_OVERVIEW_UPDATED'), $this->get_content()); + } +} From 8960e6d77741b12025229b8e5ad7972fd571722e Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 15 Feb 2014 01:19:28 +0100 Subject: [PATCH 2/4] [ticket/12176] Display correct message when trying to delete founder. PHPBB3-12176 --- phpBB/includes/acp/acp_users.php | 9 +++++++-- phpBB/language/en/acp/users.php | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 70e08f79f2..61d08a49cf 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -172,8 +172,7 @@ class acp_users if ($submit) { - // You can't delete the founder - if ($delete && $user_row['user_type'] != USER_FOUNDER) + if ($delete) { if (!$auth->acl_get('a_userdel')) { @@ -186,6 +185,12 @@ class acp_users trigger_error($user->lang['CANNOT_REMOVE_ANONYMOUS'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } + // Founders can not be deleted. + if ($user_row['user_type'] == USER_FOUNDER) + { + trigger_error($user->lang['CANNOT_REMOVE_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); + } + if ($user_id == $user->data['user_id']) { trigger_error($user->lang['CANNOT_REMOVE_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); diff --git a/phpBB/language/en/acp/users.php b/phpBB/language/en/acp/users.php index 3b82a7022d..25e5ff8269 100644 --- a/phpBB/language/en/acp/users.php +++ b/phpBB/language/en/acp/users.php @@ -52,6 +52,7 @@ $lang = array_merge($lang, array( 'CANNOT_FORCE_REACT_FOUNDER' => 'You are not allowed to force reactivation on founder accounts.', 'CANNOT_FORCE_REACT_YOURSELF' => 'You are not allowed to force reactivation of your own account.', 'CANNOT_REMOVE_ANONYMOUS' => 'You are not able to remove the guest user account.', + 'CANNOT_REMOVE_FOUNDER' => 'You are not allowed to remove founder accounts.', 'CANNOT_REMOVE_YOURSELF' => 'You are not allowed to remove your own user account.', 'CANNOT_SET_FOUNDER_IGNORED' => 'You are not able to promote ignored users to be founders.', 'CANNOT_SET_FOUNDER_INACTIVE' => 'You need to activate users before you promote them to founders, only activated users are able to be promoted.', From ca92ed918a57605e969f0485b1ebca53806f0729 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 12 Mar 2014 19:09:29 +0100 Subject: [PATCH 3/4] [ticket/12176] Add newest_user_colour to config array to ensure it exists PHPBB3-12176 --- tests/test_framework/phpbb_functional_test_case.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 00b31212b2..857112f29e 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -423,6 +423,13 @@ class phpbb_functional_test_case extends phpbb_test_case $config = array(); } + /* + * We need add some configs into the config array here, otherwise + * the set_config() function will try to add the value to the database, + * because some DBMS return 0 for sql_affectedrows() when a row was found, + * but not changed. + */ + $config['newest_user_colour'] = ''; $config['rand_seed'] = ''; $config['rand_seed_last_update'] = time() + 600; From e123b0c0a0791ac68b6099c2942eba8f6acbf56b Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 13 Mar 2014 00:53:07 +0100 Subject: [PATCH 4/4] [ticket/12176] Reword comment about config entries. PHPBB3-12176 --- tests/test_framework/phpbb_functional_test_case.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 857112f29e..5dfe07d380 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -424,10 +424,12 @@ class phpbb_functional_test_case extends phpbb_test_case } /* - * We need add some configs into the config array here, otherwise - * the set_config() function will try to add the value to the database, - * because some DBMS return 0 for sql_affectedrows() when a row was found, - * but not changed. + * Add required config entries to the config array to prevent + * set_config() sending an INSERT query for already existing entries, + * resulting in a SQL error. + * This is because set_config() first sends an UPDATE query, then checks + * sql_affectedrows() which can be 0 (e.g. on MySQL) when the new + * data is already there. */ $config['newest_user_colour'] = ''; $config['rand_seed'] = '';