mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[ticket/10950] Delete PMs for users that have not yet read the pm
PHPBB3-10950
This commit is contained in:
parent
a9c091fad4
commit
a3517232f9
2 changed files with 46 additions and 34 deletions
|
@ -1144,7 +1144,9 @@ function phpbb_delete_user_pms($user_id)
|
||||||
if (!empty($undelivered_msg))
|
if (!empty($undelivered_msg))
|
||||||
{
|
{
|
||||||
// A pm is delivered, if for any receipt the message was moved
|
// A pm is delivered, if for any receipt the message was moved
|
||||||
// from their NO_BOX to another folder.
|
// from their NO_BOX to another folder. We do not delete such
|
||||||
|
// messages, but only delete them for users, who have not yet
|
||||||
|
// received them.
|
||||||
$sql = 'SELECT msg_id
|
$sql = 'SELECT msg_id
|
||||||
FROM ' . PRIVMSGS_TO_TABLE . '
|
FROM ' . PRIVMSGS_TO_TABLE . '
|
||||||
WHERE author_id = ' . $user_id . '
|
WHERE author_id = ' . $user_id . '
|
||||||
|
@ -1153,15 +1155,15 @@ function phpbb_delete_user_pms($user_id)
|
||||||
AND folder_id <> ' . PRIVMSGS_SENTBOX;
|
AND folder_id <> ' . PRIVMSGS_SENTBOX;
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
|
$delivered_msg = array();
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$msg_id = (int) $row['msg_id'];
|
$msg_id = (int) $row['msg_id'];
|
||||||
|
$delivered_msg[$msg_id] = $msg_id;
|
||||||
unset($undelivered_msg[$msg_id]);
|
unset($undelivered_msg[$msg_id]);
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
if (!empty($undelivered_msg))
|
|
||||||
{
|
|
||||||
$undelivered_user = array();
|
$undelivered_user = array();
|
||||||
|
|
||||||
// Count the messages we delete, so we can correct the user pm data
|
// Count the messages we delete, so we can correct the user pm data
|
||||||
|
@ -1169,7 +1171,7 @@ function phpbb_delete_user_pms($user_id)
|
||||||
FROM ' . PRIVMSGS_TO_TABLE . '
|
FROM ' . PRIVMSGS_TO_TABLE . '
|
||||||
WHERE author_id = ' . $user_id . '
|
WHERE author_id = ' . $user_id . '
|
||||||
AND folder_id = ' . PRIVMSGS_NO_BOX . '
|
AND folder_id = ' . PRIVMSGS_NO_BOX . '
|
||||||
AND ' . $db->sql_in_set('msg_id', $undelivered_msg) . '
|
AND ' . $db->sql_in_set('msg_id', array_merge($undelivered_msg, $delivered_msg)) . '
|
||||||
GROUP BY user_id';
|
GROUP BY user_id';
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
|
@ -1201,6 +1203,16 @@ function phpbb_delete_user_pms($user_id)
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($delivered_msg))
|
||||||
|
{
|
||||||
|
$sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . '
|
||||||
|
WHERE folder_id = ' . PRIVMSGS_NO_BOX . '
|
||||||
|
AND ' . $db->sql_in_set('msg_id', $delivered_msg);
|
||||||
|
$db->sql_query($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($undelivered_msg))
|
||||||
|
{
|
||||||
$sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . '
|
$sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . '
|
||||||
WHERE ' . $db->sql_in_set('msg_id', $undelivered_msg);
|
WHERE ' . $db->sql_in_set('msg_id', $undelivered_msg);
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
|
|
|
@ -59,7 +59,7 @@ $lang = array_merge($lang, array(
|
||||||
|
|
||||||
'DELETE_POSTS' => 'Delete posts',
|
'DELETE_POSTS' => 'Delete posts',
|
||||||
'DELETE_USER' => 'Delete user',
|
'DELETE_USER' => 'Delete user',
|
||||||
'DELETE_USER_EXPLAIN' => 'Please note that deleting a user is final, they cannot be recovered.',
|
'DELETE_USER_EXPLAIN' => 'Please note that deleting a user is final, they cannot be recovered. Unread private messages sent by this user will be deleted and will not be available to their recipients.',
|
||||||
|
|
||||||
'FORCE_REACTIVATION_SUCCESS' => 'Successfully forced reactivation.',
|
'FORCE_REACTIVATION_SUCCESS' => 'Successfully forced reactivation.',
|
||||||
'FOUNDER' => 'Founder',
|
'FOUNDER' => 'Founder',
|
||||||
|
|
Loading…
Add table
Reference in a new issue