aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/adm/style/overall_header.html6
-rw-r--r--phpBB/includes/functions_privmsgs.php205
-rw-r--r--phpBB/language/en/acp/users.php2
-rw-r--r--phpBB/styles/prosilver/template/forum_fn.js6
-rw-r--r--phpBB/styles/prosilver/template/login_body.html4
-rw-r--r--phpBB/styles/prosilver/template/overall_header.html4
-rw-r--r--phpBB/styles/prosilver/template/posting_editor.html2
-rw-r--r--phpBB/styles/prosilver/template/search_body.html4
-rw-r--r--phpBB/styles/prosilver/template/simple_header.html4
-rw-r--r--phpBB/styles/prosilver/template/ucp_register.html2
-rw-r--r--phpBB/styles/subsilver2/template/memberlist_search.html6
-rw-r--r--phpBB/styles/subsilver2/template/overall_header.html6
12 files changed, 139 insertions, 112 deletions
diff --git a/phpBB/adm/style/overall_header.html b/phpBB/adm/style/overall_header.html
index f79c0318b5..f6d0e1025f 100644
--- a/phpBB/adm/style/overall_header.html
+++ b/phpBB/adm/style/overall_header.html
@@ -62,11 +62,7 @@ function dE(n, s, type)
*/
function marklist(id, name, state)
{
- var parent = document.getElementById(id);
- if (!parent)
- {
- eval('parent = document.' + id);
- }
+ var parent = document.getElementById(id) || document[id];
if (!parent)
{
diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php
index 8542e3ab0a..089cb06641 100644
--- a/phpBB/includes/functions_privmsgs.php
+++ b/phpBB/includes/functions_privmsgs.php
@@ -1147,127 +1147,166 @@ function phpbb_delete_user_pms($user_id)
// Get PM Information for later deleting
// The two queries where split, so we can use our indexes
+ $undelivered_msg = $delete_ids = array();
+
// Part 1: get PMs the user received
- $sql = 'SELECT msg_id, author_id, folder_id, pm_unread, pm_new
+ $sql = 'SELECT msg_id
FROM ' . PRIVMSGS_TO_TABLE . '
WHERE user_id = ' . $user_id;
$result = $db->sql_query($sql);
- $undelivered_msg = $undelivered_user = $delete_ids = array();
while ($row = $db->sql_fetchrow($result))
{
- if ($row['author_id'] == $user_id && $row['folder_id'] == PRIVMSGS_NO_BOX)
- {
- // Undelivered messages
- $undelivered_msg[] = $row['msg_id'];
-
- if (isset($undelivered_user[$row['user_id']]))
- {
- ++$undelivered_user[$row['user_id']];
- }
- else
- {
- $undelivered_user[$row['user_id']] = 1;
- }
- }
-
- $delete_ids[(int) $row['msg_id']] = (int) $row['msg_id'];
+ $msg_id = (int) $row['msg_id'];
+ $delete_ids[$msg_id] = $msg_id;
}
$db->sql_freeresult($result);
- // Part 2: get PMs the user sent
- $sql = 'SELECT msg_id, author_id, folder_id, pm_unread, pm_new
+ // Part 2: get PMs the user sent, but have 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 . '
- AND folder_id = ' . PRIVMSGS_NO_BOX;
+ AND folder_id = ' . PRIVMSGS_NO_BOX;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
- if ($row['author_id'] == $user_id && $row['folder_id'] == PRIVMSGS_NO_BOX)
- {
- // Undelivered messages
- $undelivered_msg[] = $row['msg_id'];
-
- if (isset($undelivered_user[$row['user_id']]))
- {
- ++$undelivered_user[$row['user_id']];
- }
- else
- {
- $undelivered_user[$row['user_id']] = 1;
- }
- }
-
- $delete_ids[(int) $row['msg_id']] = (int) $row['msg_id'];
+ $msg_id = (int) $row['msg_id'];
+ $undelivered_msg[$msg_id] = $msg_id;
}
$db->sql_freeresult($result);
- if (empty($delete_ids))
+ if (empty($delete_ids) && empty($undelivered_msg))
{
return false;
}
$db->sql_transaction('begin');
- if (sizeof($undelivered_msg))
- {
- $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . '
- WHERE ' . $db->sql_in_set('msg_id', $undelivered_msg);
- $db->sql_query($sql);
- }
+ if (!empty($undelivered_msg))
+ {
+ // A pm is delivered, if for any recipient the message was moved
+ // 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
+ FROM ' . PRIVMSGS_TO_TABLE . '
+ WHERE author_id = ' . $user_id . '
+ AND folder_id <> ' . PRIVMSGS_NO_BOX . '
+ AND folder_id <> ' . PRIVMSGS_OUTBOX . '
+ AND folder_id <> ' . PRIVMSGS_SENTBOX;
+ $result = $db->sql_query($sql);
- // Reset the user�s pm count to 0
- if (isset($undelivered_user[$user_id]))
- {
- $sql = 'UPDATE ' . USERS_TABLE . '
- SET user_new_privmsg = 0,
- user_unread_privmsg = 0
- WHERE user_id = ' . $user_id;
- $db->sql_query($sql);
- unset($undelivered_user[$user_id]);
- }
+ $delivered_msg = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $msg_id = (int) $row['msg_id'];
+ $delivered_msg[$msg_id] = $msg_id;
+ unset($undelivered_msg[$msg_id]);
+ }
+ $db->sql_freeresult($result);
- foreach ($undelivered_user as $_user_id => $count)
- {
- $sql = 'UPDATE ' . USERS_TABLE . '
- SET user_new_privmsg = user_new_privmsg - ' . $count . ',
- user_unread_privmsg = user_unread_privmsg - ' . $count . '
- WHERE user_id = ' . $_user_id;
- $db->sql_query($sql);
- }
+ $undelivered_user = array();
- // Delete private message data
- $sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . "
- WHERE user_id = $user_id
- AND " . $db->sql_in_set('msg_id', $delete_ids);
- $db->sql_query($sql);
+ // 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 . '
+ AND folder_id = ' . PRIVMSGS_NO_BOX . '
+ AND ' . $db->sql_in_set('msg_id', array_merge($undelivered_msg, $delivered_msg)) . '
+ GROUP BY user_id';
+ $result = $db->sql_query($sql);
- // Now we have to check which messages we can delete completely
- $sql = 'SELECT msg_id
- FROM ' . PRIVMSGS_TO_TABLE . '
- WHERE ' . $db->sql_in_set('msg_id', $delete_ids);
- $result = $db->sql_query($sql);
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $num_pms = (int) $row['num_undelivered_privmsgs'];
+ $undelivered_user[$num_pms][] = (int) $row['user_id'];
- while ($row = $db->sql_fetchrow($result))
- {
- unset($delete_ids[$row['msg_id']]);
+ if (sizeof($undelivered_user[$num_pms]) > 50)
+ {
+ // If there are too many users affected the query might get
+ // too long, so we update the value for the first bunch here.
+ $sql = 'UPDATE ' . USERS_TABLE . '
+ SET user_new_privmsg = user_new_privmsg - ' . $num_pms . ',
+ user_unread_privmsg = user_unread_privmsg - ' . $num_pms . '
+ WHERE ' . $db->sql_in_set('user_id', $undelivered_user[$num_pms]);
+ $db->sql_query($sql);
+ unset($undelivered_user[$num_pms]);
+ }
+ }
+ $db->sql_freeresult($result);
+
+ foreach ($undelivered_user as $num_pms => $undelivered_user_set)
+ {
+ $sql = 'UPDATE ' . USERS_TABLE . '
+ SET user_new_privmsg = user_new_privmsg - ' . $num_pms . ',
+ user_unread_privmsg = user_unread_privmsg - ' . $num_pms . '
+ WHERE ' . $db->sql_in_set('user_id', $undelivered_user_set);
+ $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 . '
+ WHERE ' . $db->sql_in_set('msg_id', $undelivered_msg);
+ $db->sql_query($sql);
+
+ $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . '
+ WHERE ' . $db->sql_in_set('msg_id', $undelivered_msg);
+ $db->sql_query($sql);
+ }
}
- $db->sql_freeresult($result);
+
+ // Reset the user's pm count to 0
+ $sql = 'UPDATE ' . USERS_TABLE . '
+ SET user_new_privmsg = 0,
+ user_unread_privmsg = 0
+ WHERE user_id = ' . $user_id;
+ $db->sql_query($sql);
+
+ // Delete private message data of the user
+ $sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . '
+ WHERE user_id = ' . (int) $user_id;
+ $db->sql_query($sql);
if (!empty($delete_ids))
{
- // Check if there are any attachments we need to remove
- if (!function_exists('delete_attachments'))
+ // Now we have to check which messages we can delete completely
+ $sql = 'SELECT msg_id
+ FROM ' . PRIVMSGS_TO_TABLE . '
+ WHERE ' . $db->sql_in_set('msg_id', $delete_ids);
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
{
- include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
+ unset($delete_ids[$row['msg_id']]);
}
+ $db->sql_freeresult($result);
- delete_attachments('message', $delete_ids, false);
+ if (!empty($delete_ids))
+ {
+ // Check if there are any attachments we need to remove
+ if (!function_exists('delete_attachments'))
+ {
+ include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
+ }
- $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . '
- WHERE ' . $db->sql_in_set('msg_id', $delete_ids);
- $db->sql_query($sql);
+ delete_attachments('message', $delete_ids, false);
+
+ $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . '
+ WHERE ' . $db->sql_in_set('msg_id', $delete_ids);
+ $db->sql_query($sql);
+ }
}
// Set the remaining author id to anonymous
diff --git a/phpBB/language/en/acp/users.php b/phpBB/language/en/acp/users.php
index 45cf36469b..865a2a0371 100644
--- a/phpBB/language/en/acp/users.php
+++ b/phpBB/language/en/acp/users.php
@@ -58,7 +58,7 @@ $lang = array_merge($lang, array(
'DELETE_POSTS' => 'Delete posts',
'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.',
'FOUNDER' => 'Founder',
diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js
index 240fe7e51d..995b4b0ab7 100644
--- a/phpBB/styles/prosilver/template/forum_fn.js
+++ b/phpBB/styles/prosilver/template/forum_fn.js
@@ -42,11 +42,7 @@ function jumpto()
*/
function marklist(id, name, state)
{
- var parent = document.getElementById(id);
- if (!parent)
- {
- eval('parent = document.' + id);
- }
+ var parent = document.getElementById(id) || document[id];
if (!parent)
{
diff --git a/phpBB/styles/prosilver/template/login_body.html b/phpBB/styles/prosilver/template/login_body.html
index d8b9b01779..90d8191676 100644
--- a/phpBB/styles/prosilver/template/login_body.html
+++ b/phpBB/styles/prosilver/template/login_body.html
@@ -2,7 +2,9 @@
<script type="text/javascript">
// <![CDATA[
- onload_functions.push('document.getElementById("<!-- IF S_ADMIN_AUTH -->{PASSWORD_CREDENTIAL}<!-- ELSE -->{USERNAME_CREDENTIAL}<!-- ENDIF -->").focus();');
+ onload_functions.push(function () {
+ document.getElementById("<!-- IF S_ADMIN_AUTH -->{PASSWORD_CREDENTIAL}<!-- ELSE -->{USERNAME_CREDENTIAL}<!-- ENDIF -->").focus();
+ });
// ]]>
</script>
diff --git a/phpBB/styles/prosilver/template/overall_header.html b/phpBB/styles/prosilver/template/overall_header.html
index 349309ab4e..43ae83767d 100644
--- a/phpBB/styles/prosilver/template/overall_header.html
+++ b/phpBB/styles/prosilver/template/overall_header.html
@@ -56,7 +56,7 @@
{
for (var i = 0; i < onload_functions.length; i++)
{
- eval(onload_functions[i]);
+ onload_functions[i]();
}
};
@@ -64,7 +64,7 @@
{
for (var i = 0; i < onunload_functions.length; i++)
{
- eval(onunload_functions[i]);
+ onunload_functions[i]();
}
};
diff --git a/phpBB/styles/prosilver/template/posting_editor.html b/phpBB/styles/prosilver/template/posting_editor.html
index d1c86e7e13..99e518d486 100644
--- a/phpBB/styles/prosilver/template/posting_editor.html
+++ b/phpBB/styles/prosilver/template/posting_editor.html
@@ -1,6 +1,6 @@
<script type="text/javascript">
// <![CDATA[
- onload_functions.push('apply_onkeypress_event()');
+ onload_functions.push(apply_onkeypress_event);
// ]]>
</script>
diff --git a/phpBB/styles/prosilver/template/search_body.html b/phpBB/styles/prosilver/template/search_body.html
index a8baafa5f1..0d8797b2ff 100644
--- a/phpBB/styles/prosilver/template/search_body.html
+++ b/phpBB/styles/prosilver/template/search_body.html
@@ -2,7 +2,9 @@
<script type="text/javascript">
// <![CDATA[
- onload_functions.push('document.getElementById("keywords").focus();');
+ onload_functions.push(function () {
+ document.getElementById("keywords").focus();
+ });
// ]]>
</script>
diff --git a/phpBB/styles/prosilver/template/simple_header.html b/phpBB/styles/prosilver/template/simple_header.html
index 5440d66520..6026dfd329 100644
--- a/phpBB/styles/prosilver/template/simple_header.html
+++ b/phpBB/styles/prosilver/template/simple_header.html
@@ -26,7 +26,7 @@
{
for (var i = 0; i < onload_functions.length; i++)
{
- eval(onload_functions[i]);
+ onload_functions[i]();
}
}
@@ -34,7 +34,7 @@
{
for (var i = 0; i < onunload_functions.length; i++)
{
- eval(onunload_functions[i]);
+ onunload_functions[i]();
}
}
diff --git a/phpBB/styles/prosilver/template/ucp_register.html b/phpBB/styles/prosilver/template/ucp_register.html
index 994356efe6..e14ca6493d 100644
--- a/phpBB/styles/prosilver/template/ucp_register.html
+++ b/phpBB/styles/prosilver/template/ucp_register.html
@@ -12,7 +12,7 @@
}
<!-- IF CAPTCHA_TEMPLATE and S_CONFIRM_REFRESH -->
- onload_functions.push('apply_onkeypress_event()');
+ onload_functions.push(apply_onkeypress_event);
<!-- ENDIF -->
// ]]>
diff --git a/phpBB/styles/subsilver2/template/memberlist_search.html b/phpBB/styles/subsilver2/template/memberlist_search.html
index 96ffad00d6..ab1ecca2ee 100644
--- a/phpBB/styles/subsilver2/template/memberlist_search.html
+++ b/phpBB/styles/subsilver2/template/memberlist_search.html
@@ -43,11 +43,7 @@
*/
function marklist(id, name, state)
{
- var parent = document.getElementById(id);
- if (!parent)
- {
- eval('parent = document.' + id);
- }
+ var parent = document.getElementById(id) || document[id];
if (!parent)
{
diff --git a/phpBB/styles/subsilver2/template/overall_header.html b/phpBB/styles/subsilver2/template/overall_header.html
index 5d5489338a..f08531c47f 100644
--- a/phpBB/styles/subsilver2/template/overall_header.html
+++ b/phpBB/styles/subsilver2/template/overall_header.html
@@ -71,11 +71,7 @@ function find_username(url)
*/
function marklist(id, name, state)
{
- var parent = document.getElementById(id);
- if (!parent)
- {
- eval('parent = document.' + id);
- }
+ var parent = document.getElementById(id) || document[id];
if (!parent)
{