aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_user.php
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2007-05-11 12:25:28 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2007-05-11 12:25:28 +0000
commit9e270489eb1dfbb59f176dd2abdb10f94055265a (patch)
treeeb39a1017598e6eaa239ad5a391559e78045ddf3 /phpBB/includes/functions_user.php
parentecaeeff5dffb94be405f5d1517bd5e561b4ac458 (diff)
downloadforums-9e270489eb1dfbb59f176dd2abdb10f94055265a.tar
forums-9e270489eb1dfbb59f176dd2abdb10f94055265a.tar.gz
forums-9e270489eb1dfbb59f176dd2abdb10f94055265a.tar.bz2
forums-9e270489eb1dfbb59f176dd2abdb10f94055265a.tar.xz
forums-9e270489eb1dfbb59f176dd2abdb10f94055265a.zip
We do not support nesting code tags - #10763
#10741 Confirm box on pruning forums - #10619 Not stripping empty lines on parsing messages - #10579 Remove reports alongside with users - #10501 git-svn-id: file:///svn/phpbb/trunk@7527 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions_user.php')
-rw-r--r--phpBB/includes/functions_user.php59
1 files changed, 59 insertions, 0 deletions
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index 0dab76e7c0..87e88f5ac2 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -293,6 +293,65 @@ function user_delete($mode, $user_id, $post_username = false)
$db->sql_transaction('begin');
+ // Before we begin, we will remove the reports the user issued.
+ $sql = 'SELECT r.post_id, p.topic_id
+ FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p
+ WHERE r.user_id = ' . $user_id . '
+ AND p.post_id = r.post_id';
+ $result = $db->sql_query($sql);
+
+ $report_posts = $report_topics = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $report_posts[] = $row['post_id'];
+ $report_topics[] = $row['topic_id'];
+ }
+ $db->sql_freeresult($result);
+
+ if (sizeof($report_posts))
+ {
+ $report_posts = array_unique($report_posts);
+ $report_topics = array_unique($report_topics);
+
+ // Get a list of topics that still contain reported posts
+ $sql = 'SELECT DISTINCT topic_id
+ FROM ' . POSTS_TABLE . '
+ WHERE ' . $db->sql_in_set('topic_id', $report_topics) . '
+ AND post_reported = 1
+ AND ' . $db->sql_in_set('post_id', $report_posts, true);
+ $result = $db->sql_query($sql);
+
+ $keep_report_topics = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $keep_report_topics[] = $row['topic_id'];
+ }
+ $db->sql_freeresult($result);
+
+ if (sizeof($keep_report_topics))
+ {
+ $report_topics = array_diff($report_topics, $keep_report_topics);
+ }
+ unset($keep_report_topics);
+
+ // Now set the flags back
+ $sql = 'UPDATE ' . POSTS_TABLE . '
+ SET post_reported = 0
+ WHERE ' . $db->sql_in_set('post_id', $report_posts);
+ $db->sql_query($sql);
+
+ if (sizeof($report_topics))
+ {
+ $sql = 'UPDATE ' . TOPICS_TABLE . '
+ SET topic_reported = 0
+ WHERE ' . $db->sql_in_set('topic_id', $report_topics);
+ $db->sql_query($sql);
+ }
+ }
+
+ // Remove reports
+ $db->sql_query('DELETE FROM ' . REPORTS_TABLE . ' WHERE user_id = ' . $user_id);
+
switch ($mode)
{
case 'retain':