aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
authorNathaniel Guse <nathaniel.guse@gmail.com>2013-05-01 12:28:31 -0500
committerNathaniel Guse <nathaniel.guse@gmail.com>2013-05-01 12:28:31 -0500
commitabaa53b0b295358efcf591587485c01a027cd5cb (patch)
tree7c1b18f425019544dc0ee535dd6d65680ef9306d /phpBB/includes
parentd68778e7ebd801d396a8ec8694499f2ebdbb809f (diff)
downloadforums-abaa53b0b295358efcf591587485c01a027cd5cb.tar
forums-abaa53b0b295358efcf591587485c01a027cd5cb.tar.gz
forums-abaa53b0b295358efcf591587485c01a027cd5cb.tar.bz2
forums-abaa53b0b295358efcf591587485c01a027cd5cb.tar.xz
forums-abaa53b0b295358efcf591587485c01a027cd5cb.zip
[ticket/8323] Combine into a single query
PHPBB3-8323
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/ucp/ucp_pm_compose.php58
1 files changed, 28 insertions, 30 deletions
diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php
index 3e7ed05fdc..75b17a4a01 100644
--- a/phpBB/includes/ucp/ucp_pm_compose.php
+++ b/phpBB/includes/ucp/ucp_pm_compose.php
@@ -1222,49 +1222,47 @@ function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove
// Check for disallowed recipients
if (!empty($address_list['u']))
{
- // We need to check their PM status (do they want to receive PM's?)
- // Only check if not a moderator or admin, since they are allowed to override this user setting
+ // Administrator deactivated users check and we need to check their
+ // PM status (do they want to receive PM's?)
+ // Only check PM status if not a moderator or admin, since they
+ // are allowed to override this user setting
+ $sql = 'SELECT user_id, user_allow_pm
+ FROM ' . USERS_TABLE . '
+ WHERE ' . $db->sql_in_set('user_id', array_keys($address_list['u'])) . '
+ AND (user_type = ' . USER_INACTIVE . '
+ AND user_inactive_reason = ' . INACTIVE_MANUAL . ')';
+
if (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_'))
{
- $sql = 'SELECT user_id
- FROM ' . USERS_TABLE . '
- WHERE ' . $db->sql_in_set('user_id', array_keys($address_list['u'])) . '
- AND user_allow_pm = 0';
- $result = $db->sql_query($sql);
-
- $removed = false;
- while ($row = $db->sql_fetchrow($result))
- {
- $removed = true;
- unset($address_list['u'][$row['user_id']]);
- }
- $db->sql_freeresult($result);
-
- // print a notice about users not being added who do not want to receive pms
- if ($removed)
- {
- $error[] = $user->lang['PM_USERS_REMOVED_NO_PM'];
- }
+ $sql .= ' OR user_allow_pm = 0';
}
- // Administrator deactivated users check
- $sql = 'SELECT user_id
- FROM ' . USERS_TABLE . '
- WHERE ' . $db->sql_in_set('user_id', array_keys($address_list['u'])) . '
- AND user_type = ' . USER_INACTIVE . '
- AND user_inactive_reason = ' . INACTIVE_MANUAL;
$result = $db->sql_query($sql);
- $removed = false;
+ $removed_no_pm = $removed_no_permission = false;
while ($row = $db->sql_fetchrow($result))
{
- $removed = true;
+ if (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_') && !$row['user_allow_pm'])
+ {
+ $removed_no_pm = true;
+ }
+ else
+ {
+ $removed_no_permission = true;
+ }
+
unset($address_list['u'][$row['user_id']]);
}
$db->sql_freeresult($result);
+ // print a notice about users not being added who do not want to receive pms
+ if ($removed_no_pm)
+ {
+ $error[] = $user->lang['PM_USERS_REMOVED_NO_PM'];
+ }
+
// print a notice about users not being added who do not have permission to receive PMs
- if ($removed)
+ if ($removed_no_permission)
{
$error[] = $user->lang['PM_USERS_REMOVED_NO_PERMISSION'];
}