aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/acp/acp_forums.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/acp/acp_forums.php')
-rw-r--r--phpBB/includes/acp/acp_forums.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php
index e9e75ed57d..aad3306f3e 100644
--- a/phpBB/includes/acp/acp_forums.php
+++ b/phpBB/includes/acp/acp_forums.php
@@ -1315,6 +1315,20 @@ class acp_forums
delete_attachments('topic', $topic_ids, false);
+ // Before we remove anything we make sure we are able to adjust the post counts later. ;)
+ $sql = 'SELECT poster_id
+ FROM ' . POSTS_TABLE . '
+ WHERE forum_id = ' . $forum_id . '
+ AND post_postcount = 1';
+ $result = $db->sql_query($sql);
+
+ $post_counts = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $post_counts[$row['poster_id']] = (!empty($post_counts[$row['poster_id']])) ? $post_counts[$row['poster_id']] + 1 : 1;
+ }
+ $db->sql_freeresult($result);
+
switch (SQL_LAYER)
{
case 'mysql4':
@@ -1416,6 +1430,18 @@ class acp_forums
$db->sql_query("UPDATE $table SET forum_id = 0 WHERE forum_id = $forum_id");
}
+ // Adjust users post counts
+ if (sizeof($post_counts))
+ {
+ foreach ($post_counts as $poster_id => $substract)
+ {
+ $sql = 'UPDATE ' . USERS_TABLE . '
+ SET user_posts = user_posts - ' . $substract . '
+ WHERE user_id = ' . $poster_id;
+ $db->sql_query($sql);
+ }
+ }
+
$db->sql_transaction('commit');
// Make sure the overall post/topic count is correct...