diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html
index 091fcc0d09..2c75581b7f 100644
--- a/phpBB/docs/CHANGELOG.html
+++ b/phpBB/docs/CHANGELOG.html
@@ -98,6 +98,7 @@
[Fix] Also add PHPBB_INSTALLED check to download/file.php for inline avatar delivery
[Fix] Unable to login to some jabber server, reverted previous change (Bug #25095)
[Fix] Do not return BMP as valid image type for GD image manipulation (Bug #25925)
+ [Change] For determining the maximum number of private messages in one box, use the biggest value from all groups the user is a member of (Bug #24665)
1.ii. Changes since 3.0.0
diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php
index bffa64158a..834bcfea51 100644
--- a/phpBB/includes/functions_privmsgs.php
+++ b/phpBB/includes/functions_privmsgs.php
@@ -1803,4 +1803,25 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode
return true;
}
+/**
+* Set correct users max messages in PM folder.
+* If several group memberships define different amount of messages, the highest will be chosen.
+*/
+function set_user_message_limit()
+{
+ global $user, $db, $config;
+
+ // Get maximum about from user memberships - if it is 0, there is no limit set and we use the maximum value within the config.
+ $sql = 'SELECT MAX(g.group_message_limit) as max_message_limit
+ FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . ' ug
+ WHERE ug.user_id = ' . $user->data['user_id'] . '
+ AND ug.user_pending = 0
+ AND ug.group_id = g.group_id';
+ $result = $db->sql_query($sql);
+ $message_limit = (int) $db->sql_fetchfield('max_message_limit');
+ $db->sql_freeresult($result);
+
+ $user->data['message_limit'] = (!$message_limit) ? $config['pm_max_msgs'] : $message_limit;
+}
+
?>
\ No newline at end of file
diff --git a/phpBB/includes/ucp/ucp_pm.php b/phpBB/includes/ucp/ucp_pm.php
index 46b23efb54..b4ac0c11da 100644
--- a/phpBB/includes/ucp/ucp_pm.php
+++ b/phpBB/includes/ucp/ucp_pm.php
@@ -129,15 +129,7 @@ class ucp_pm
break;
case 'options':
- $sql = 'SELECT group_message_limit
- FROM ' . GROUPS_TABLE . '
- WHERE group_id = ' . $user->data['group_id'];
- $result = $db->sql_query($sql, 3600);
- $message_limit = (int) $db->sql_fetchfield('group_message_limit');
- $db->sql_freeresult($result);
-
- $user->data['message_limit'] = (!$message_limit) ? $config['pm_max_msgs'] : $message_limit;
-
+ set_user_message_limit();
get_folder($user->data['user_id']);
include($phpbb_root_path . 'includes/ucp/ucp_pm_options.' . $phpEx);
@@ -168,14 +160,7 @@ class ucp_pm
case 'view':
- $sql = 'SELECT group_message_limit
- FROM ' . GROUPS_TABLE . '
- WHERE group_id = ' . $user->data['group_id'];
- $result = $db->sql_query($sql, 3600);
- $message_limit = (int) $db->sql_fetchfield('group_message_limit');
- $db->sql_freeresult($result);
-
- $user->data['message_limit'] = (!$message_limit) ? $config['pm_max_msgs'] : $message_limit;
+ set_user_message_limit();
if ($folder_specified)
{