aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_user.php
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2006-09-01 13:16:22 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2006-09-01 13:16:22 +0000
commit5f30881c2c11ffce73a75c3e5c18d1368e6777da (patch)
tree8e26e09db8abc91b1027e7d2e5756429706200d1 /phpBB/includes/functions_user.php
parent888bbf6ff4e465ff8f60a34f0859796fe4adc09d (diff)
downloadforums-5f30881c2c11ffce73a75c3e5c18d1368e6777da.tar
forums-5f30881c2c11ffce73a75c3e5c18d1368e6777da.tar.gz
forums-5f30881c2c11ffce73a75c3e5c18d1368e6777da.tar.bz2
forums-5f30881c2c11ffce73a75c3e5c18d1368e6777da.tar.xz
forums-5f30881c2c11ffce73a75c3e5c18d1368e6777da.zip
fix some bugs - hopefully not breaking anything...
git-svn-id: file:///svn/phpbb/trunk@6342 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 b5dfecb45f..7183c96e1b 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -343,6 +343,65 @@ function user_delete($mode, $user_id, $post_username = false)
$db->sql_query($sql);
}
+ include_once($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);
+
+ // Remove any undelivered mails...
+ $sql = 'SELECT msg_id, user_id
+ FROM ' . PRIVMSGS_TO_TABLE . '
+ WHERE author_id = ' . $user_id . '
+ AND folder_id = ' . PRIVMSGS_NO_BOX;
+ $result = $db->sql_query($sql);
+
+ $undelivered_msg = $undelivered_user = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $undelivered_msg[] = $row['msg_id'];
+ $undelivered_user[$row['user_id']][] = true;
+ }
+ $db->sql_freeresult($result);
+
+ if (sizeof($undelivered_msg))
+ {
+ $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . '
+ WHERE ' . $db->sql_in_set('msg_id', $undelivered_msg);
+ $db->sql_query($sql);
+ }
+
+ $sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . '
+ WHERE author_id = ' . $user_id . '
+ AND folder_id = ' . PRIVMSGS_NO_BOX;
+ $db->sql_query($sql);
+
+ // Delete all to-informations
+ $sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . '
+ WHERE user_id = ' . $user_id;
+ $db->sql_query($sql);
+
+ // Set the remaining author id to anonymous - this way users are still able to read messages from users being removed
+ $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . '
+ SET author_id = ' . ANONYMOUS . '
+ WHERE author_id = ' . $user_id;
+ $db->sql_query($sql);
+
+ $sql = 'UPDATE ' . PRIVMSGS_TABLE . '
+ SET author_id = ' . ANONYMOUS . '
+ WHERE author_id = ' . $user_id;
+ $db->sql_query($sql);
+
+ foreach ($undelivered_user as $_user_id => $ary)
+ {
+ if ($_user_id == $user_id)
+ {
+ continue;
+ }
+
+ $sql = 'UPDATE ' . USERS_TABLE . '
+ SET user_new_privmsg = user_new_privmsg - ' . sizeof($ary) . ',
+ user_unread_privmsg = user_unread_privmsg - ' . sizeof($ary) . '
+ WHERE user_id = ' . $_user_id;
+ $db->sql_query($sql);
+ }
+
// Reset newest user info if appropriate
if ($config['newest_user_id'] == $user_id)
{