mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/9581] Slightly tweaked queries
Changed the queries based upon comments by Oleg and Nick, this should return the expected result in every case. PHPBB3-9581
This commit is contained in:
parent
1dd25ce62d
commit
df76799d4b
1 changed files with 35 additions and 14 deletions
|
@ -69,8 +69,6 @@ class acp_email
|
||||||
|
|
||||||
if (!sizeof($error))
|
if (!sizeof($error))
|
||||||
{
|
{
|
||||||
$sql_ban_where = (!isset($_REQUEST['mail_banned_flag'])) ? 'AND b.ban_userid != u.user_id' : '';
|
|
||||||
|
|
||||||
if ($usernames)
|
if ($usernames)
|
||||||
{
|
{
|
||||||
// If giving usernames the admin is able to email inactive users too...
|
// If giving usernames the admin is able to email inactive users too...
|
||||||
|
@ -84,25 +82,48 @@ class acp_email
|
||||||
{
|
{
|
||||||
if ($group_id)
|
if ($group_id)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT u.user_email, u.username, u.username_clean, u.user_lang, u.user_jabber, u.user_notify_type
|
$sql_ary = array(
|
||||||
FROM ' . ((!empty($sql_ban_where)) ? BANLIST_TABLE . ' b, ' : '') . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . ' ug
|
'SELECT' => 'u.user_email, u.username, u.username_clean, u.user_lang, u.user_jabber, u.user_notify_type',
|
||||||
WHERE ug.group_id = ' . $group_id . '
|
'FROM' => array(
|
||||||
|
USERS_TABLE => 'u',
|
||||||
|
USER_GROUP_TABLE => 'ug',
|
||||||
|
),
|
||||||
|
'WHERE' => 'ug.group_id = ' . $group_id . '
|
||||||
AND ug.user_pending = 0
|
AND ug.user_pending = 0
|
||||||
AND u.user_id = ug.user_id
|
AND u.user_id = ug.user_id
|
||||||
AND u.user_allow_massemail = 1
|
AND u.user_allow_massemail = 1
|
||||||
AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ")
|
AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')',
|
||||||
{$sql_ban_where}
|
'ORDER_BY' => 'u.user_lang, u.user_notify_type',
|
||||||
ORDER BY u.user_lang, u.user_notify_type";
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sql = 'SELECT u.username, u.username_clean, u.user_email, u.user_jabber, u.user_notify_type, u.user_lang
|
$sql_ary = array(
|
||||||
FROM (' . ((!empty($sql_ban_where)) ? BANLIST_TABLE . ' b, ' : '') . USERS_TABLE . ' u)
|
'SELECT' => 'u.username, u.username_clean, u.user_email, u.user_jabber, u.user_notify_type',
|
||||||
WHERE u.user_allow_massemail = 1
|
'FROM' => array(
|
||||||
AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ")
|
USERS_TABLE => 'u',
|
||||||
{$sql_ban_where}
|
),
|
||||||
ORDER BY u.user_lang, u.user_notify_type";
|
'WHERE' => 'u.user_allow_massemail = 1
|
||||||
|
AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')',
|
||||||
|
'ORDER_BY' => 'u.user_lang, u.user_notify_type',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mail banned or not
|
||||||
|
if (!isset($_REQUEST['mail_banned_flag']))
|
||||||
|
{
|
||||||
|
$sql_ary['WHERE'] .= ' AND (b.ban_id IS NULL
|
||||||
|
OR b.ban_exclude = 1)';
|
||||||
|
$sql_ary['LEFT_JOIN'] = array(
|
||||||
|
array(
|
||||||
|
'FROM' => array(
|
||||||
|
BANLIST_TABLE => 'b',
|
||||||
|
),
|
||||||
|
'ON' => 'u.user_id = b.ban_userid',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$sql = $db->sql_build_query('SELECT', $sql_ary);
|
||||||
}
|
}
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
$row = $db->sql_fetchrow($result);
|
$row = $db->sql_fetchrow($result);
|
||||||
|
|
Loading…
Add table
Reference in a new issue