aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/adm/style/acp_logs.html2
-rw-r--r--phpBB/adm/style/admin.css9
-rw-r--r--phpBB/assets/javascript/editor.js4
-rw-r--r--phpBB/includes/functions_privmsgs.php2
-rw-r--r--phpBB/includes/functions_user.php41
-rw-r--r--phpBB/phpbb/session.php7
-rw-r--r--phpBB/phpbb/template/base.php6
-rw-r--r--phpBB/styles/prosilver/theme/forms.css6
-rw-r--r--phpBB/styles/prosilver/theme/responsive.css25
-rw-r--r--tests/functions_user/delete_user_test.php440
-rw-r--r--tests/functions_user/fixtures/delete_user.xml549
-rw-r--r--tests/session/fixtures/sessions_empty.xml7
12 files changed, 1062 insertions, 36 deletions
diff --git a/phpBB/adm/style/acp_logs.html b/phpBB/adm/style/acp_logs.html
index 4f67f46e24..76ea801de0 100644
--- a/phpBB/adm/style/acp_logs.html
+++ b/phpBB/adm/style/acp_logs.html
@@ -8,7 +8,7 @@
<form id="list" method="post" action="{U_ACTION}">
-<fieldset class="display-options" style="float: left">
+<fieldset class="display-options search-box">
{L_SEARCH_KEYWORDS}{L_COLON} <input type="text" name="keywords" value="{S_KEYWORDS}" />&nbsp;<input type="submit" class="button2" name="filter" value="{L_SEARCH}" />
</fieldset>
diff --git a/phpBB/adm/style/admin.css b/phpBB/adm/style/admin.css
index b83750875a..b03cb0ba24 100644
--- a/phpBB/adm/style/admin.css
+++ b/phpBB/adm/style/admin.css
@@ -109,6 +109,14 @@ hr {
text-align: center;
}
+.search-box {
+ float: left;
+}
+
+.rtl .search-box {
+ float: right;
+}
+
.small {
font-size: 0.85em;
}
@@ -1773,6 +1781,7 @@ li.pagination ul {
margin: 10px 0;
color: #FFFFFF;
text-align: center;
+ clear: both;
}
.success {
diff --git a/phpBB/assets/javascript/editor.js b/phpBB/assets/javascript/editor.js
index dfc7dab525..5fd4f7eae3 100644
--- a/phpBB/assets/javascript/editor.js
+++ b/phpBB/assets/javascript/editor.js
@@ -266,10 +266,6 @@ function mozWrap(txtarea, open, close) {
var selEnd = txtarea.selectionEnd;
var scrollTop = txtarea.scrollTop;
- if (selEnd === 1 || selEnd === 2) {
- selEnd = selLength;
- }
-
var s1 = (txtarea.value).substring(0,selStart);
var s2 = (txtarea.value).substring(selStart, selEnd);
var s3 = (txtarea.value).substring(selEnd, selLength);
diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php
index 29cea477e4..ad142b1cca 100644
--- a/phpBB/includes/functions_privmsgs.php
+++ b/phpBB/includes/functions_privmsgs.php
@@ -1573,7 +1573,7 @@ function get_folder_status($folder_id, $folder)
'cur' => $folder['num_messages'],
'remaining' => ($user->data['message_limit']) ? $user->data['message_limit'] - $folder['num_messages'] : 0,
'max' => $user->data['message_limit'],
- 'percent' => ($user->data['message_limit']) ? (($user->data['message_limit'] > 0) ? round(($folder['num_messages'] / $user->data['message_limit']) * 100) : 100) : 0,
+ 'percent' => ($user->data['message_limit']) ? (($user->data['message_limit'] > 0) ? floor(($folder['num_messages'] / $user->data['message_limit']) * 100) : 100) : 0,
);
$return['message'] = $user->lang('FOLDER_STATUS_MSG', $user->lang('MESSAGES_COUNT', (int) $return['max']), $return['cur'], $return['percent']);
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index 38ae34c66c..e4479f07b0 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -363,12 +363,16 @@ function user_add($user_row, $cp_data = false)
}
/**
-* Remove User
-* @param $mode Either 'retain' or 'remove'
-*/
+ * Remove User
+ *
+ * @param string $mode Either 'retain' or 'remove'
+ * @param mixed $user_ids Either an array of integers or an integer
+ * @param bool $retain_username
+ * @return bool
+ */
function user_delete($mode, $user_ids, $retain_username = true)
{
- global $cache, $config, $db, $user, $auth, $phpbb_dispatcher;
+ global $cache, $config, $db, $user, $phpbb_dispatcher;
global $phpbb_root_path, $phpEx;
$db->sql_transaction('begin');
@@ -555,11 +559,6 @@ function user_delete($mode, $user_ids, $retain_username = true)
WHERE ' . $db->sql_in_set('poster_id', $user_ids);
$db->sql_query($sql);
- $sql = 'UPDATE ' . POSTS_TABLE . '
- SET post_edit_user = ' . ANONYMOUS . '
- WHERE ' . $db->sql_in_set('post_edit_user', $user_ids);
- $db->sql_query($sql);
-
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_posts = user_posts + ' . $added_guest_posts . '
WHERE user_id = ' . ANONYMOUS;
@@ -589,6 +588,30 @@ function user_delete($mode, $user_ids, $retain_username = true)
$cache->destroy('sql', MODERATOR_CACHE_TABLE);
+ // Change user_id to anonymous for posts edited by this user
+ $sql = 'UPDATE ' . POSTS_TABLE . '
+ SET post_edit_user = ' . ANONYMOUS . '
+ WHERE ' . $db->sql_in_set('post_edit_user', $user_ids);
+ $db->sql_query($sql);
+
+ // Change user_id to anonymous for pms edited by this user
+ $sql = 'UPDATE ' . PRIVMSGS_TABLE . '
+ SET message_edit_user = ' . ANONYMOUS . '
+ WHERE ' . $db->sql_in_set('message_edit_user', $user_ids);
+ $db->sql_query($sql);
+
+ // Change user_id to anonymous for posts deleted by this user
+ $sql = 'UPDATE ' . POSTS_TABLE . '
+ SET post_delete_user = ' . ANONYMOUS . '
+ WHERE ' . $db->sql_in_set('post_delete_user', $user_ids);
+ $db->sql_query($sql);
+
+ // Change user_id to anonymous for topics deleted by this user
+ $sql = 'UPDATE ' . TOPICS_TABLE . '
+ SET topic_delete_user = ' . ANONYMOUS . '
+ WHERE ' . $db->sql_in_set('topic_delete_user', $user_ids);
+ $db->sql_query($sql);
+
// Delete user log entries about this user
$sql = 'DELETE FROM ' . LOG_TABLE . '
WHERE ' . $db->sql_in_set('reportee_id', $user_ids);
diff --git a/phpBB/phpbb/session.php b/phpBB/phpbb/session.php
index 30b364821d..da8b848fa5 100644
--- a/phpBB/phpbb/session.php
+++ b/phpBB/phpbb/session.php
@@ -441,12 +441,13 @@ class session
if (!$session_expired)
{
- // Only update session DB a minute or so after last update or if page changes and is not ajax request
- if (($this->time_now - $this->data['session_time'] > 60 || ($this->update_session_page && $this->data['session_page'] != $this->page['page'])) && !$request->is_ajax())
+ // Only update session DB a minute or so after last update or if page changes
+ if ($this->time_now - $this->data['session_time'] > 60 || ($this->update_session_page && $this->data['session_page'] != $this->page['page']))
{
$sql_ary = array('session_time' => $this->time_now);
- if ($this->update_session_page)
+ // Do not update the session page for ajax requests, so the view online still works as intended
+ if ($this->update_session_page && !$request->is_ajax())
{
$sql_ary['session_page'] = substr($this->page['page'], 0, 199);
$sql_ary['session_forum_id'] = $this->page['forum'];
diff --git a/phpBB/phpbb/template/base.php b/phpBB/phpbb/template/base.php
index ab0e1f281d..9a40702ba8 100644
--- a/phpBB/phpbb/template/base.php
+++ b/phpBB/phpbb/template/base.php
@@ -142,11 +142,11 @@ abstract class base implements template
{
global $phpbb_hook;
- if (!empty($phpbb_hook) && $phpbb_hook->call_hook(array(__CLASS__, $method), $handle, $this))
+ if (!empty($phpbb_hook) && $phpbb_hook->call_hook(array('template', $method), $handle, $this))
{
- if ($phpbb_hook->hook_return(array(__CLASS__, $method)))
+ if ($phpbb_hook->hook_return(array('template', $method)))
{
- $result = $phpbb_hook->hook_return_result(array(__CLASS__, $method));
+ $result = $phpbb_hook->hook_return_result(array('template', $method));
return array($result);
}
}
diff --git a/phpBB/styles/prosilver/theme/forms.css b/phpBB/styles/prosilver/theme/forms.css
index cbdeab11f9..f08a8a9691 100644
--- a/phpBB/styles/prosilver/theme/forms.css
+++ b/phpBB/styles/prosilver/theme/forms.css
@@ -129,6 +129,10 @@ dd select {
width: auto;
}
+dd select[multiple] {
+ width: 100%;
+}
+
dd textarea {
width: 85%;
}
@@ -410,7 +414,7 @@ input.button1:focus, input.button2:focus, input.button3:focus {
.search-header a.button {
border: 0;
- border-left: 1;
+ border-left: 1px;
padding: 3px 5px 3px 4px;
}
diff --git a/phpBB/styles/prosilver/theme/responsive.css b/phpBB/styles/prosilver/theme/responsive.css
index 698b9efd75..ed3ba61334 100644
--- a/phpBB/styles/prosilver/theme/responsive.css
+++ b/phpBB/styles/prosilver/theme/responsive.css
@@ -161,8 +161,7 @@ ul.topiclist.forums dd.topics dfn, ul.topiclist.topics dd.posts dfn {
font-weight: normal;
}
-@media only screen and (max-width: 550px), only screen and (max-device-width: 550px)
-{
+@media only screen and (max-width: 550px), only screen and (max-device-width: 550px) {
ul.topiclist.forums dt {
margin-right: 0;
}
@@ -191,8 +190,7 @@ ul.topiclist li.row dt a.subforum {
/* Notifications list
----------------------------------------*/
-@media only screen and (max-width: 350px), only screen and (max-device-width: 350px)
-{
+@media only screen and (max-width: 350px), only screen and (max-device-width: 350px) {
.dropdown-extended .dropdown-contents {
width: auto;
}
@@ -344,22 +342,23 @@ fieldset.quick-login label[for="autologin"] {
min-width: 50%;
}
-@media only screen and (max-width: 500px), only screen and (max-device-width: 500px)
-{
+@media only screen and (max-width: 500px), only screen and (max-device-width: 500px) {
+ dd label {
+ white-space: normal;
+ }
+
select, .inputbox {
max-width: 260px;
}
}
-@media only screen and (max-width: 430px), only screen and (max-device-width: 430px)
-{
+@media only screen and (max-width: 430px), only screen and (max-device-width: 430px) {
.section-viewtopic .search-box .inputbox {
width: 110px;
}
}
-@media only screen and (max-width: 320px), only screen and (max-device-width: 320px)
-{
+@media only screen and (max-width: 320px), only screen and (max-device-width: 320px) {
select, .inputbox {
max-width: 240px;
}
@@ -372,8 +371,7 @@ fieldset.quick-login label[for="autologin"] {
width: auto;
}
-@media only screen and (max-width: 500px), only screen and (max-device-width: 500px)
-{
+@media only screen and (max-width: 500px), only screen and (max-device-width: 500px) {
dl.details dt, dl.details dd {
width: auto;
float: none;
@@ -513,8 +511,7 @@ fieldset.display-actions {
width: 100%;
}
-@media only screen and (max-width: 500px), only screen and (max-device-width: 500px)
-{
+@media only screen and (max-width: 500px), only screen and (max-device-width: 500px) {
p.responsive-center {
float: none;
text-align: center;
diff --git a/tests/functions_user/delete_user_test.php b/tests/functions_user/delete_user_test.php
new file mode 100644
index 0000000000..d5c78c64ad
--- /dev/null
+++ b/tests/functions_user/delete_user_test.php
@@ -0,0 +1,440 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2014 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php';
+
+class phpbb_functions_user_delete_user_test extends phpbb_database_test_case
+{
+ /** @var \phpbb\db\driver\driver_interface */
+ protected $db;
+
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/delete_user.xml');
+ }
+
+ protected function setUp()
+ {
+ parent::setUp();
+
+ global $cache, $config, $db, $phpbb_dispatcher, $phpbb_container;
+
+ $db = $this->db = $this->new_dbal();
+ $config = new \phpbb\config\config(array(
+ 'load_online_time' => 5,
+ 'search_type' => '\phpbb\search\fulltext_mysql',
+ ));
+ set_config(false, false, false, $config);
+ set_config_count(false, false, false, $config);
+ $cache = new phpbb_mock_null_cache();
+ $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
+ $phpbb_container = new phpbb_mock_container_builder();
+ $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager());
+ }
+
+ public function first_last_post_data()
+ {
+ return array(
+ array(
+ 'retain', false,
+ array(
+ array('post_id' => 1, 'poster_id' => ANONYMOUS, 'post_username' => ''),
+ array('post_id' => 2, 'poster_id' => ANONYMOUS, 'post_username' => 'Other'),
+ array('post_id' => 3, 'poster_id' => ANONYMOUS, 'post_username' => ''),
+ array('post_id' => 4, 'poster_id' => ANONYMOUS, 'post_username' => 'Other'),
+ ),
+ array(
+ array(
+ 'topic_id' => 1,
+ 'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => '', 'topic_first_poster_colour' => '',
+ 'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => '', 'topic_last_poster_colour' => '',
+ ),
+ array(
+ 'topic_id' => 2,
+ 'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => 'Other', 'topic_first_poster_colour' => '',
+ 'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => 'Other', 'topic_last_poster_colour' => '',
+ ),
+ array(
+ 'topic_id' => 3,
+ 'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => '', 'topic_first_poster_colour' => '',
+ 'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => '', 'topic_last_poster_colour' => '',
+ ),
+ array(
+ 'topic_id' => 4,
+ 'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => 'Other', 'topic_first_poster_colour' => '',
+ 'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => 'Other', 'topic_last_poster_colour' => '',
+ ),
+ ),
+ array(
+ array('forum_id' => 1, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => '', 'forum_last_poster_colour' => ''),
+ array('forum_id' => 2, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => 'Other', 'forum_last_poster_colour' => ''),
+ array('forum_id' => 3, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => '', 'forum_last_poster_colour' => ''),
+ array('forum_id' => 4, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => 'Other', 'forum_last_poster_colour' => ''),
+ ),
+ ),
+ array(
+ 'remove', false,
+ array(
+ array('post_id' => 2, 'poster_id' => ANONYMOUS, 'post_username' => 'Other'),
+ array('post_id' => 4, 'poster_id' => ANONYMOUS, 'post_username' => 'Other'),
+ ),
+ array(
+ array(
+ 'topic_id' => 2,
+ 'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => 'Other', 'topic_first_poster_colour' => '',
+ 'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => 'Other', 'topic_last_poster_colour' => '',
+ ),
+ array(
+ 'topic_id' => 4,
+ 'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => 'Other', 'topic_first_poster_colour' => '',
+ 'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => 'Other', 'topic_last_poster_colour' => '',
+ ),
+ ),
+ array(
+ array('forum_id' => 1, 'forum_last_poster_id' => 0, 'forum_last_poster_name' => '', 'forum_last_poster_colour' => ''),
+ array('forum_id' => 2, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => 'Other', 'forum_last_poster_colour' => ''),
+ array('forum_id' => 3, 'forum_last_poster_id' => 0, 'forum_last_poster_name' => '', 'forum_last_poster_colour' => ''),
+ array('forum_id' => 4, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => 'Other', 'forum_last_poster_colour' => ''),
+ ),
+ ),
+ array(
+ 'retain', true,
+ array(
+ array('post_id' => 1, 'poster_id' => ANONYMOUS, 'post_username' => 'Foobar'),
+ array('post_id' => 2, 'poster_id' => ANONYMOUS, 'post_username' => 'Other'),
+ array('post_id' => 3, 'poster_id' => ANONYMOUS, 'post_username' => 'Foobar'),
+ array('post_id' => 4, 'poster_id' => ANONYMOUS, 'post_username' => 'Other'),
+ ),
+ array(
+ array(
+ 'topic_id' => 1,
+ 'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => 'Foobar', 'topic_first_poster_colour' => '',
+ 'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => 'Foobar', 'topic_last_poster_colour' => '',
+ ),
+ array(
+ 'topic_id' => 2,
+ 'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => 'Other', 'topic_first_poster_colour' => '',
+ 'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => 'Other', 'topic_last_poster_colour' => '',
+ ),
+ array(
+ 'topic_id' => 3,
+ 'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => 'Foobar', 'topic_first_poster_colour' => '',
+ 'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => 'Foobar', 'topic_last_poster_colour' => '',
+ ),
+ array(
+ 'topic_id' => 4,
+ 'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => 'Other', 'topic_first_poster_colour' => '',
+ 'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => 'Other', 'topic_last_poster_colour' => '',
+ ),
+ ),
+ array(
+ array('forum_id' => 1, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => 'Foobar', 'forum_last_poster_colour' => ''),
+ array('forum_id' => 2, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => 'Other', 'forum_last_poster_colour' => ''),
+ array('forum_id' => 3, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => 'Foobar', 'forum_last_poster_colour' => ''),
+ array('forum_id' => 4, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => 'Other', 'forum_last_poster_colour' => ''),
+ ),
+ ),
+ array(
+ 'remove', true,
+ array(
+ array('post_id' => 2, 'poster_id' => ANONYMOUS, 'post_username' => 'Other'),
+ array('post_id' => 4, 'poster_id' => ANONYMOUS, 'post_username' => 'Other'),
+ ),
+ array(
+ array(
+ 'topic_id' => 2,
+ 'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => 'Other', 'topic_first_poster_colour' => '',
+ 'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => 'Other', 'topic_last_poster_colour' => '',
+ ),
+ array(
+ 'topic_id' => 4,
+ 'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => 'Other', 'topic_first_poster_colour' => '',
+ 'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => 'Other', 'topic_last_poster_colour' => '',
+ ),
+ ),
+ array(
+ array('forum_id' => 1, 'forum_last_poster_id' => 0, 'forum_last_poster_name' => '', 'forum_last_poster_colour' => ''),
+ array('forum_id' => 2, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => 'Other', 'forum_last_poster_colour' => ''),
+ array('forum_id' => 3, 'forum_last_poster_id' => 0, 'forum_last_poster_name' => '', 'forum_last_poster_colour' => ''),
+ array('forum_id' => 4, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => 'Other', 'forum_last_poster_colour' => ''),
+ ),
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider first_last_post_data
+ */
+ public function test_first_last_post_info($mode, $retain_username, $expected_posts, $expected_topics, $expected_forums)
+ {
+ $this->assertFalse(user_delete($mode, 2, $retain_username));
+
+ $sql = 'SELECT post_id, poster_id, post_username
+ FROM ' . POSTS_TABLE . '
+ ORDER BY post_id ASC';
+ $result = $this->db->sql_query($sql);
+ $this->assertEquals($expected_posts, $this->db->sql_fetchrowset($result), 'Post table poster info is mismatching after deleting a user.');
+ $this->db->sql_freeresult($result);
+
+ $sql = 'SELECT topic_id, topic_poster, topic_first_poster_name, topic_first_poster_colour, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour
+ FROM ' . TOPICS_TABLE . '
+ ORDER BY topic_id ASC';
+ $result = $this->db->sql_query($sql);
+ $this->assertEquals($expected_topics, $this->db->sql_fetchrowset($result), 'Topic table first/last poster info is mismatching after deleting a user.');
+ $this->db->sql_freeresult($result);
+
+ $sql = 'SELECT forum_id, forum_last_poster_id, forum_last_poster_name, forum_last_poster_colour
+ FROM ' . FORUMS_TABLE . '
+ ORDER BY forum_id ASC';
+ $result = $this->db->sql_query($sql);
+ $this->assertEquals($expected_forums, $this->db->sql_fetchrowset($result), 'Forum table last poster info is mismatching after deleting a user.');
+ $this->db->sql_freeresult($result);
+ }
+
+ public function report_attachment_data()
+ {
+ return array(
+ array(
+ 'retain',
+ array(
+ array('post_id' => 1, 'post_reported' => 1, 'post_edit_user' => 1, 'post_delete_user' => 1),
+ array('post_id' => 2, 'post_reported' => 1, 'post_edit_user' => 1, 'post_delete_user' => 1),
+ array('post_id' => 3, 'post_reported' => 0, 'post_edit_user' => 1, 'post_delete_user' => 1),
+ array('post_id' => 4, 'post_reported' => 0, 'post_edit_user' => 1, 'post_delete_user' => 1),
+ ),
+ array(
+ array('report_id' => 1, 'post_id' => 1, 'user_id' => 1),
+ array('report_id' => 3, 'post_id' => 2, 'user_id' => 1),
+ ),
+ array(
+ array('topic_id' => 1, 'topic_reported' => 1, 'topic_delete_user' => 1),
+ array('topic_id' => 2, 'topic_reported' => 1, 'topic_delete_user' => 1),
+ array('topic_id' => 3, 'topic_reported' => 0, 'topic_delete_user' => 1),
+ array('topic_id' => 4, 'topic_reported' => 0, 'topic_delete_user' => 1),
+ ),
+ array(
+ array('attach_id' => 1, 'post_msg_id' => 1, 'poster_id' => 1),
+ array('attach_id' => 2, 'post_msg_id' => 2, 'poster_id' => 1),
+ array('attach_id' => 3, 'post_msg_id' => 0, 'poster_id' => 1), // TODO should be deleted: PHPBB3-13089
+ ),
+ ),
+ array(
+ 'remove',
+ array(
+ array('post_id' => 2, 'post_reported' => 1, 'post_edit_user' => 1, 'post_delete_user' => 1),
+ array('post_id' => 4, 'post_reported' => 0, 'post_edit_user' => 1, 'post_delete_user' => 1),
+ ),
+ array(
+ array('report_id' => 3, 'post_id' => 2, 'user_id' => 1),
+ ),
+ array(
+ array('topic_id' => 2, 'topic_reported' => 1, 'topic_delete_user' => 1),
+ array('topic_id' => 4, 'topic_reported' => 0, 'topic_delete_user' => 1),
+ ),
+ array(
+ array('attach_id' => 2, 'post_msg_id' => 2, 'poster_id' => 1),
+ array('attach_id' => 3, 'post_msg_id' => 0, 'poster_id' => 2), // TODO should be deleted: PHPBB3-13089
+ ),
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider report_attachment_data
+ */
+ public function test_report_attachment_info($mode, $expected_posts, $expected_reports, $expected_topics, $expected_attach)
+ {
+ $this->assertFalse(user_delete($mode, 2));
+
+ $sql = 'SELECT post_id, post_reported, post_edit_user, post_delete_user
+ FROM ' . POSTS_TABLE . '
+ ORDER BY post_id ASC';
+ $result = $this->db->sql_query($sql);
+ $this->assertEquals($expected_posts, $this->db->sql_fetchrowset($result), 'Post report status content is mismatching after deleting a user.');
+ $this->db->sql_freeresult($result);
+
+ $sql = 'SELECT report_id, post_id, user_id
+ FROM ' . REPORTS_TABLE . '
+ ORDER BY report_id ASC';
+ $result = $this->db->sql_query($sql);
+ $this->assertEquals($expected_reports, $this->db->sql_fetchrowset($result), 'Report table content is mismatching after deleting a user.');
+ $this->db->sql_freeresult($result);
+
+ $sql = 'SELECT topic_id, topic_reported, topic_delete_user
+ FROM ' . TOPICS_TABLE . '
+ ORDER BY topic_id ASC';
+ $result = $this->db->sql_query($sql);
+ $this->assertEquals($expected_topics, $this->db->sql_fetchrowset($result), 'Topic report status is mismatching after deleting a user.');
+ $this->db->sql_freeresult($result);
+
+ $sql = 'SELECT attach_id, post_msg_id, poster_id
+ FROM ' . ATTACHMENTS_TABLE . '
+ ORDER BY attach_id ASC';
+ $result = $this->db->sql_query($sql);
+ $this->assertEquals($expected_attach, $this->db->sql_fetchrowset($result), 'Attachment table content is mismatching after deleting a user.');
+ $this->db->sql_freeresult($result);
+ }
+
+ public function delete_data()
+ {
+ return array(
+ array(
+ 'retain',
+ array(array('user_id' => 1, 'user_posts' => 4)),
+ array(array('user_id' => 1, 'zebra_id' => 3)),
+ array(array('ban_id' => 2), array('ban_id' => 3)),
+ array(array('session_id' => '12345678901234567890123456789013')),
+ array(
+ array('log_id' => 2, 'user_id' => 1, 'reportee_id' => 1),
+ array('log_id' => 3, 'user_id' => 1, 'reportee_id' => 1),
+ ),
+ array(
+ array('msg_id' => 1, 'author_id' => 3, 'message_edit_user' => 3),
+ array('msg_id' => 2, 'author_id' => 1, 'message_edit_user' => 1),
+ ),
+ ),
+ array(
+ 'remove',
+ array(array('user_id' => 1, 'user_posts' => 2)),
+ array(array('user_id' => 1, 'zebra_id' => 3)),
+ array(array('ban_id' => 2), array('ban_id' => 3)),
+ array(array('session_id' => '12345678901234567890123456789013')),
+ array(
+ array('log_id' => 2, 'user_id' => 1, 'reportee_id' => 1),
+ array('log_id' => 3, 'user_id' => 1, 'reportee_id' => 1),
+ ),
+ array(
+ array('msg_id' => 1, 'author_id' => 3, 'message_edit_user' => 3),
+ array('msg_id' => 2, 'author_id' => 1, 'message_edit_user' => 1),
+ ),
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider delete_data
+ */
+ public function test_delete_data($mode, $expected_users, $expected_zebra, $expected_ban, $expected_sessions, $expected_logs, $expected_pms)
+ {
+ $this->assertFalse(user_delete($mode, 2));
+
+ $sql = 'SELECT user_id, user_posts
+ FROM ' . USERS_TABLE . '
+ ORDER BY user_id ASC';
+ $result = $this->db->sql_query($sql);
+ $this->assertEquals($expected_users, $this->db->sql_fetchrowset($result), 'User table content is mismatching after deleting a user.');
+ $this->db->sql_freeresult($result);
+
+ $sql = 'SELECT user_id, zebra_id
+ FROM ' . ZEBRA_TABLE . '
+ ORDER BY user_id ASC, zebra_id ASC';
+ $result = $this->db->sql_query($sql);
+ $this->assertEquals($expected_zebra, $this->db->sql_fetchrowset($result), 'Zebra table content is mismatching after deleting a user.');
+ $this->db->sql_freeresult($result);
+
+ $sql = 'SELECT ban_id
+ FROM ' . BANLIST_TABLE . '
+ ORDER BY ban_id ASC';
+ $result = $this->db->sql_query($sql);
+ $this->assertEquals($expected_ban, $this->db->sql_fetchrowset($result), 'Ban table content is mismatching after deleting a user.');
+ $this->db->sql_freeresult($result);
+
+ $sql = 'SELECT session_id
+ FROM ' . SESSIONS_TABLE . '
+ ORDER BY session_id ASC';
+ $result = $this->db->sql_query($sql);
+ $this->assertEquals($expected_sessions, $this->db->sql_fetchrowset($result), 'Session table content is mismatching after deleting a user.');
+ $this->db->sql_freeresult($result);
+
+ $sql = 'SELECT log_id, user_id, reportee_id
+ FROM ' . LOG_TABLE . '
+ ORDER BY log_id ASC';
+ $result = $this->db->sql_query($sql);
+ $this->assertEquals($expected_logs, $this->db->sql_fetchrowset($result), 'Log table content is mismatching after deleting a user.');
+ $this->db->sql_freeresult($result);
+
+ $sql = 'SELECT msg_id, author_id, message_edit_user
+ FROM ' . PRIVMSGS_TABLE . '
+ ORDER BY msg_id ASC';
+ $result = $this->db->sql_query($sql);
+ $this->assertEquals($expected_pms, $this->db->sql_fetchrowset($result), 'Private messages table content is mismatching after deleting a user.');
+ $this->db->sql_freeresult($result);
+ }
+
+ public function delete_user_id_data()
+ {
+ return array(
+ array(
+ 'retain',
+ array(
+ USER_GROUP_TABLE,
+ TOPICS_WATCH_TABLE,
+ FORUMS_WATCH_TABLE,
+ ACL_USERS_TABLE,
+ TOPICS_TRACK_TABLE,
+ TOPICS_POSTED_TABLE,
+ FORUMS_TRACK_TABLE,
+ PROFILE_FIELDS_DATA_TABLE,
+ MODERATOR_CACHE_TABLE,
+ DRAFTS_TABLE,
+ BOOKMARKS_TABLE,
+ SESSIONS_KEYS_TABLE,
+ PRIVMSGS_FOLDER_TABLE,
+ PRIVMSGS_RULES_TABLE,
+ ),
+ ),
+ array(
+ 'remove',
+ array(
+ USER_GROUP_TABLE,
+ TOPICS_WATCH_TABLE,
+ FORUMS_WATCH_TABLE,
+ ACL_USERS_TABLE,
+ TOPICS_TRACK_TABLE,
+ TOPICS_POSTED_TABLE,
+ FORUMS_TRACK_TABLE,
+ PROFILE_FIELDS_DATA_TABLE,
+ MODERATOR_CACHE_TABLE,
+ DRAFTS_TABLE,
+ BOOKMARKS_TABLE,
+ SESSIONS_KEYS_TABLE,
+ PRIVMSGS_FOLDER_TABLE,
+ PRIVMSGS_RULES_TABLE,
+ ),
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider delete_user_id_data
+ */
+ public function test_delete_user_id_data($mode, $cleaned_tables)
+ {
+ $this->assertFalse(user_delete($mode, 2));
+
+ foreach ($cleaned_tables as $table)
+ {
+ $sql = 'SELECT user_id
+ FROM ' . $table . '
+ WHERE user_id = 2';
+ $result = $this->db->sql_query($sql);
+ $this->assertFalse($this->db->sql_fetchfield('user_id'), 'Found data for deleted user in table: ' . $table);
+ $this->db->sql_freeresult($result);
+
+ $sql = 'SELECT user_id
+ FROM ' . $table . '
+ WHERE user_id = 3';
+ $result = $this->db->sql_query($sql);
+ $this->assertEquals(3, $this->db->sql_fetchfield('user_id'), 'Missing data for user in table: ' . $table);
+ $this->db->sql_freeresult($result);
+ }
+ }
+}
diff --git a/tests/functions_user/fixtures/delete_user.xml b/tests/functions_user/fixtures/delete_user.xml
new file mode 100644
index 0000000000..56014b35d1
--- /dev/null
+++ b/tests/functions_user/fixtures/delete_user.xml
@@ -0,0 +1,549 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_attachments">
+ <column>attach_id</column>
+ <column>post_msg_id</column>
+ <column>topic_id</column>
+ <column>in_message</column>
+ <column>poster_id</column>
+ <column>is_orphan</column>
+ <column>attach_comment</column>
+ <row>
+ <value>1</value>
+ <value>1</value>
+ <value>1</value>
+ <value>0</value>
+ <value>2</value>
+ <value>0</value>
+ <value></value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>2</value>
+ <value>2</value>
+ <value>0</value>
+ <value>1</value>
+ <value>0</value>
+ <value></value>
+ </row>
+ <row>
+ <value>3</value>
+ <value>0</value>
+ <value>0</value>
+ <value>0</value>
+ <value>2</value>
+ <value>1</value>
+ <value></value>
+ </row>
+ </table>
+ <table name="phpbb_banlist">
+ <column>ban_id</column>
+ <column>ban_userid</column>
+ <column>ban_email</column>
+ <column>ban_reason</column>
+ <column>ban_give_reason</column>
+ <row>
+ <value>1</value>
+ <value>2</value>
+ <value></value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>3</value>
+ <value></value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>3</value>
+ <value>0</value>
+ <value></value>
+ <value></value>
+ <value></value>
+ </row>
+ </table>
+ <table name="phpbb_forums">
+ <column>forum_id</column>
+ <column>forum_last_poster_id</column>
+ <column>forum_last_poster_name</column>
+ <column>forum_last_poster_colour</column>
+ <column>forum_parents</column>
+ <column>forum_desc</column>
+ <column>forum_rules</column>
+ <row>
+ <value>1</value>
+ <value>2</value>
+ <value></value>
+ <value>00AA00</value>
+ <value></value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>1</value>
+ <value>Other</value>
+ <value></value>
+ <value></value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>3</value>
+ <value>2</value>
+ <value></value>
+ <value>00AA00</value>
+ <value></value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>4</value>
+ <value>1</value>
+ <value>Other</value>
+ <value></value>
+ <value></value>
+ <value></value>
+ <value></value>
+ </row>
+ </table>
+ <table name="phpbb_log">
+ <column>log_id</column>
+ <column>user_id</column>
+ <column>reportee_id</column>
+ <column>log_operation</column>
+ <column>log_data</column>
+ <row>
+ <value>1</value>
+ <value>1</value>
+ <value>2</value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>2</value>
+ <value>1</value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>3</value>
+ <value>1</value>
+ <value>1</value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>4</value>
+ <value>2</value>
+ <value>2</value>
+ <value></value>
+ <value></value>
+ </row>
+ </table>
+ <table name="phpbb_posts">
+ <column>post_id</column>
+ <column>poster_id</column>
+ <column>post_edit_user</column>
+ <column>post_delete_user</column>
+ <column>post_username</column>
+ <column>topic_id</column>
+ <column>forum_id</column>
+ <column>post_visibility</column>
+ <column>post_time</column>
+ <column>post_text</column>
+ <column>post_reported</column>
+ <row>
+ <value>1</value>
+ <value>2</value>
+ <value>2</value>
+ <value>2</value>
+ <value></value>
+ <value>1</value>
+ <value>1</value>
+ <value>1</value>
+ <value>1</value>
+ <value></value>
+ <value>1</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>1</value>
+ <value>1</value>
+ <value>1</value>
+ <value>Other</value>
+ <value>2</value>
+ <value>2</value>
+ <value>1</value>
+ <value>1</value>
+ <value></value>
+ <value>1</value>
+ </row>
+ <row>
+ <value>3</value>
+ <value>2</value>
+ <value>2</value>
+ <value>2</value>
+ <value></value>
+ <value>3</value>
+ <value>3</value>
+ <value>1</value>
+ <value>1</value>
+ <value></value>
+ <value>1</value>
+ </row>
+ <row>
+ <value>4</value>
+ <value>1</value>
+ <value>1</value>
+ <value>1</value>
+ <value>Other</value>
+ <value>4</value>
+ <value>4</value>
+ <value>1</value>
+ <value>1</value>
+ <value></value>
+ <value>1</value>
+ </row>
+ </table>
+ <table name="phpbb_privmsgs">
+ <column>msg_id</column>
+ <column>author_id</column>
+ <column>message_edit_user</column>
+ <column>message_text</column>
+ <column>to_address</column>
+ <column>bcc_address</column>
+ <row>
+ <value>1</value>
+ <value>3</value>
+ <value>3</value>
+ <value></value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>2</value>
+ <value>2</value>
+ <value></value>
+ <value></value>
+ <value></value>
+ </row>
+ </table>
+ <table name="phpbb_privmsgs_to">
+ <column>msg_id</column>
+ <column>user_id</column>
+ <column>author_id</column>
+ <row>
+ <value>1</value>
+ <value>3</value>
+ <value>3</value>
+ </row>
+ <row>
+ <value>1</value>
+ <value>2</value>
+ <value>3</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>3</value>
+ <value>2</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>2</value>
+ <value>2</value>
+ </row>
+ </table>
+ <table name="phpbb_reports">
+ <column>report_id</column>
+ <column>post_id</column>
+ <column>user_id</column>
+ <column>report_text</column>
+ <column>reported_post_text</column>
+ <row>
+ <value>1</value>
+ <value>1</value>
+ <value>1</value>
+ <value>Post Removed?</value>
+ <value></value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>3</value>
+ <value>2</value>
+ <value>Post Removed?</value>
+ <value></value>
+ </row>
+ <row>
+ <value>3</value>
+ <value>2</value>
+ <value>1</value>
+ <value>Keep</value>
+ <value></value>
+ </row>
+ <row>
+ <value>4</value>
+ <value>4</value>
+ <value>2</value>
+ <value>Remove Report</value>
+ <value></value>
+ </row>
+ </table>
+ <table name="phpbb_sessions">
+ <column>session_id</column>
+ <column>session_user_id</column>
+ <column>session_page</column>
+ <row>
+ <value>12345678901234567890123456789012</value>
+ <value>2</value>
+ <value></value>
+ </row>
+ <row>
+ <value>12345678901234567890123456789013</value>
+ <value>3</value>
+ <value></value>
+ </row>
+ </table>
+ <table name="phpbb_topics">
+ <column>topic_id</column>
+ <column>forum_id</column>
+ <column>topic_reported</column>
+ <column>topic_poster</column>
+ <column>topic_delete_user</column>
+ <column>topic_first_poster_name</column>
+ <column>topic_first_poster_colour</column>
+ <column>topic_last_poster_id</column>
+ <column>topic_last_poster_name</column>
+ <column>topic_last_poster_colour</column>
+ <row>
+ <value>1</value>
+ <value>1</value>
+ <value>1</value>
+ <value>2</value>
+ <value>2</value>
+ <value></value>
+ <value>00AA00</value>
+ <value>2</value>
+ <value></value>
+ <value>00AA00</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>2</value>
+ <value>1</value>
+ <value>1</value>
+ <value>1</value>
+ <value>Other</value>
+ <value></value>
+ <value>1</value>
+ <value>Other</value>
+ <value></value>
+ </row>
+ <row>
+ <value>3</value>
+ <value>3</value>
+ <value>1</value>
+ <value>2</value>
+ <value>2</value>
+ <value></value>
+ <value>00AA00</value>
+ <value>2</value>
+ <value></value>
+ <value>00AA00</value>
+ </row>
+ <row>
+ <value>4</value>
+ <value>4</value>
+ <value>1</value>
+ <value>1</value>
+ <value>1</value>
+ <value>Other</value>
+ <value></value>
+ <value>1</value>
+ <value>Other</value>
+ <value></value>
+ </row>
+ </table>
+ <table name="phpbb_users">
+ <column>user_id</column>
+ <column>username</column>
+ <column>username_clean</column>
+ <column>user_permissions</column>
+ <column>user_sig</column>
+ <column>user_posts</column>
+ <row>
+ <value>1</value>
+ <value>Anonymous</value>
+ <value>anonymous</value>
+ <value></value>
+ <value></value>
+ <value>2</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>Foobar</value>
+ <value>foobar</value>
+ <value></value>
+ <value></value>
+ <value>2</value>
+ </row>
+ </table>
+ <table name="phpbb_zebra">
+ <column>user_id</column>
+ <column>zebra_id</column>
+ <row>
+ <value>1</value>
+ <value>2</value>
+ </row>
+ <row>
+ <value>1</value>
+ <value>3</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>1</value>
+ </row>
+ </table>
+ <table name="phpbb_user_group">
+ <column>user_id</column>
+ <row>
+ <value>2</value>
+ </row>
+ <row>
+ <value>3</value>
+ </row>
+ </table>
+ <table name="phpbb_topics_watch">
+ <column>user_id</column>
+ <row>
+ <value>2</value>
+ </row>
+ <row>
+ <value>3</value>
+ </row>
+ </table>
+ <table name="phpbb_forums_watch">
+ <column>user_id</column>
+ <row>
+ <value>2</value>
+ </row>
+ <row>
+ <value>3</value>
+ </row>
+ </table>
+ <table name="phpbb_acl_users">
+ <column>user_id</column>
+ <row>
+ <value>2</value>
+ </row>
+ <row>
+ <value>3</value>
+ </row>
+ </table>
+ <table name="phpbb_topics_track">
+ <column>user_id</column>
+ <row>
+ <value>2</value>
+ </row>
+ <row>
+ <value>3</value>
+ </row>
+ </table>
+ <table name="phpbb_forums_track">
+ <column>user_id</column>
+ <row>
+ <value>2</value>
+ </row>
+ <row>
+ <value>3</value>
+ </row>
+ </table>
+ <table name="phpbb_topics_posted">
+ <column>user_id</column>
+ <row>
+ <value>2</value>
+ </row>
+ <row>
+ <value>3</value>
+ </row>
+ </table>
+ <table name="phpbb_profile_fields_data">
+ <column>user_id</column>
+ <column>pf_phpbb_interests</column>
+ <column>pf_phpbb_occupation</column>
+ <row>
+ <value>2</value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>3</value>
+ <value></value>
+ <value></value>
+ </row>
+ </table>
+ <table name="phpbb_moderator_cache">
+ <column>user_id</column>
+ <row>
+ <value>2</value>
+ </row>
+ <row>
+ <value>3</value>
+ </row>
+ </table>
+ <table name="phpbb_bookmarks">
+ <column>user_id</column>
+ <row>
+ <value>2</value>
+ </row>
+ <row>
+ <value>3</value>
+ </row>
+ </table>
+ <table name="phpbb_sessions_keys">
+ <column>user_id</column>
+ <row>
+ <value>2</value>
+ </row>
+ <row>
+ <value>3</value>
+ </row>
+ </table>
+ <table name="phpbb_privmsgs_folder">
+ <column>user_id</column>
+ <row>
+ <value>2</value>
+ </row>
+ <row>
+ <value>3</value>
+ </row>
+ </table>
+ <table name="phpbb_privmsgs_rules">
+ <column>user_id</column>
+ <column>rule_string</column>
+ <row>
+ <value>2</value>
+ <value></value>
+ </row>
+ <row>
+ <value>3</value>
+ <value></value>
+ </row>
+ </table>
+ <table name="phpbb_drafts">
+ <column>user_id</column>
+ <column>draft_message</column>
+ <row>
+ <value>2</value>
+ <value></value>
+ </row>
+ <row>
+ <value>3</value>
+ <value></value>
+ </row>
+ </table>
+</dataset>
diff --git a/tests/session/fixtures/sessions_empty.xml b/tests/session/fixtures/sessions_empty.xml
index 2acba58f45..068951dc4c 100644
--- a/tests/session/fixtures/sessions_empty.xml
+++ b/tests/session/fixtures/sessions_empty.xml
@@ -30,4 +30,11 @@
<column>session_ip</column>
<column>session_browser</column>
</table>
+ <table name="phpbb_banlist">
+ <column>ban_id</column>
+ <column>ban_userid</column>
+ <column>ban_email</column>
+ <column>ban_reason</column>
+ <column>ban_give_reason</column>
+ </table>
</dataset>