1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-06 16:56:44 +02:00

Merge branch 'develop' of github.com:EXreaction/phpbb3 into ticket/11103

Conflicts:
	phpBB/install/schemas/mssql_schema.sql
	phpBB/report.php
	phpBB/styles/prosilver/template/ucp_prefs_personal.html
	phpBB/styles/subsilver2/template/ucp_prefs_personal.html
This commit is contained in:
Nathaniel Guse
2012-11-10 10:58:44 -06:00
290 changed files with 2456 additions and 1755 deletions

View File

@@ -1151,6 +1151,23 @@ function phpbb_delete_user_pms($user_id)
return false;
}
return phpbb_delete_users_pms(array($user_id));
}
/**
* Delete all PM(s) for given users and delete the ones without references
*
* @param array $user_ids IDs of the users whose private messages we want to delete
*
* @return boolean False if there were no pms found, true otherwise.
*/
function phpbb_delete_users_pms($user_ids)
{
global $db, $user, $phpbb_root_path, $phpEx;
$user_id_sql = $db->sql_in_set('user_id', $user_ids);
$author_id_sql = $db->sql_in_set('author_id', $user_ids);
// Get PM Information for later deleting
// The two queries where split, so we can use our indexes
$undelivered_msg = $delete_ids = array();
@@ -1158,7 +1175,7 @@ function phpbb_delete_user_pms($user_id)
// Part 1: get PMs the user received
$sql = 'SELECT msg_id
FROM ' . PRIVMSGS_TO_TABLE . '
WHERE user_id = ' . $user_id;
WHERE ' . $user_id_sql;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
@@ -1168,12 +1185,12 @@ function phpbb_delete_user_pms($user_id)
}
$db->sql_freeresult($result);
// Part 2: get PMs the user sent, but have yet to be received
// We cannot simply delete them. First we have to check,
// Part 2: get PMs the users sent, but are yet to be received.
// We cannot simply delete them. First we have to check
// whether another user already received and read the message.
$sql = 'SELECT msg_id
FROM ' . PRIVMSGS_TO_TABLE . '
WHERE author_id = ' . $user_id . '
WHERE ' . $author_id_sql . '
AND folder_id = ' . PRIVMSGS_NO_BOX;
$result = $db->sql_query($sql);
@@ -1199,7 +1216,7 @@ function phpbb_delete_user_pms($user_id)
// received them.
$sql = 'SELECT msg_id
FROM ' . PRIVMSGS_TO_TABLE . '
WHERE author_id = ' . $user_id . '
WHERE ' . $author_id_sql . '
AND folder_id <> ' . PRIVMSGS_NO_BOX . '
AND folder_id <> ' . PRIVMSGS_OUTBOX . '
AND folder_id <> ' . PRIVMSGS_SENTBOX;
@@ -1219,7 +1236,7 @@ function phpbb_delete_user_pms($user_id)
// Count the messages we delete, so we can correct the user pm data
$sql = 'SELECT user_id, COUNT(msg_id) as num_undelivered_privmsgs
FROM ' . PRIVMSGS_TO_TABLE . '
WHERE author_id = ' . $user_id . '
WHERE ' . $author_id_sql . '
AND folder_id = ' . PRIVMSGS_NO_BOX . '
AND ' . $db->sql_in_set('msg_id', array_merge($undelivered_msg, $delivered_msg)) . '
GROUP BY user_id';
@@ -1281,12 +1298,12 @@ function phpbb_delete_user_pms($user_id)
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_new_privmsg = 0,
user_unread_privmsg = 0
WHERE user_id = ' . $user_id;
WHERE ' . $user_id_sql;
$db->sql_query($sql);
// Delete private message data of the user
$sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . '
WHERE user_id = ' . (int) $user_id;
WHERE ' . $user_id_sql;
$db->sql_query($sql);
if (!empty($delete_ids))
@@ -1325,12 +1342,12 @@ function phpbb_delete_user_pms($user_id)
// 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;
WHERE ' . $author_id_sql;
$db->sql_query($sql);
$sql = 'UPDATE ' . PRIVMSGS_TABLE . '
SET author_id = ' . ANONYMOUS . '
WHERE author_id = ' . $user_id;
WHERE ' . $author_id_sql;
$db->sql_query($sql);
$db->sql_transaction('commit');