[ticket/11103] Move banned user checking to email method

This will make sure banned users are never sent notification emails

PHPBB3-11103
This commit is contained in:
Nathaniel Guse 2012-09-08 21:05:49 -05:00
parent 6983f380c5
commit 98a03090a0
2 changed files with 14 additions and 14 deletions

View file

@ -52,6 +52,13 @@ class phpbb_notifications_method_email extends phpbb_notifications_method_base
$user_ids[] = $notification->user_id;
}
// We do not send emails to banned users
if (!function_exists('phpbb_get_banned_user_ids'))
{
include($phpbb_container->getParameter('core.root_path') . 'includes/functions_user.' . $phpbb_container->getParameter('core.php_ext'));
}
$banned_users = phpbb_get_banned_user_ids($user_ids);
$sql = 'SELECT * FROM ' . USERS_TABLE . '
WHERE ' . $this->db->sql_in_set('user_id', $user_ids);
$result = $this->db->sql_query($sql);
@ -72,6 +79,11 @@ class phpbb_notifications_method_email extends phpbb_notifications_method_base
// Time to go through the queue and send emails
foreach ($this->queue as $notification)
{
if (in_array($notification->user_id, $banned_users))
{
continue;
}
$notification->users($users);
$user = $notification->get_user($notification->user_id);

View file

@ -118,20 +118,8 @@ class phpbb_notifications_type_pm extends phpbb_notifications_type_base
$db = $phpbb_container->get('dbal.conn');
$user = $phpbb_container->get('user');
// Exclude guests, current user and banned users from notifications
unset($pm['recipients'][ANONYMOUS]);//, $pm['recipients'][$user->data['user_id']]);
if (!sizeof($pm['recipients']))
{
return;
}
if (!function_exists('phpbb_get_banned_user_ids'))
{
include($phpbb_container->getParameter('core.root_path') . 'includes/functions_user.' . $phpbb_container->getParameter('core.php_ext'));
}
$banned_users = phpbb_get_banned_user_ids(array_keys($pm['recipients']));
$pm['recipients'] = array_diff(array_keys($pm['recipients']), $banned_users);
// Exclude guests and current user from notifications
unset($pm['recipients'][ANONYMOUS], $pm['recipients'][$user->data['user_id']]);
if (!sizeof($pm['recipients']))
{