mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-24 12:03:21 +01:00
Merge branch 'ticket/11103' of github.com:EXreaction/phpbb3 into ticket/11103
This commit is contained in:
commit
2fb9f2ce6a
@ -23,6 +23,10 @@ if (!defined('IN_PHPBB'))
|
||||
*/
|
||||
class phpbb_notifications_method_email extends phpbb_notifications_method_base
|
||||
{
|
||||
/**
|
||||
* Is this method available for the user?
|
||||
* This is checked on the notifications options
|
||||
*/
|
||||
public static function is_available()
|
||||
{
|
||||
// Email is always available
|
||||
@ -48,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);
|
||||
@ -68,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);
|
||||
@ -77,12 +93,9 @@ class phpbb_notifications_method_email extends phpbb_notifications_method_base
|
||||
$messenger->to($user['user_email'], $user['username']);
|
||||
|
||||
$messenger->assign_vars(array(
|
||||
'SUBJECT' => htmlspecialchars_decode($notification->get_title()),
|
||||
'AUTHOR_NAME' => '',
|
||||
'USERNAME' => htmlspecialchars_decode($user['username']),
|
||||
'SUBJECT' => htmlspecialchars_decode($notification->get_title()),
|
||||
|
||||
'U_INBOX' => $board_url . "/ucp.{$this->php_ext}?i=pm&folder=inbox",
|
||||
'U_VIEW_MESSAGE' => $board_url . "/ucp.{$this->php_ext}?i=pm&mode=view&p={$notification->item_id}",
|
||||
'U_VIEW_MESSAGE' => $notification->get_full_url(),
|
||||
));
|
||||
|
||||
$messenger->send('email');
|
||||
|
@ -46,6 +46,8 @@ class phpbb_notifications_service
|
||||
*
|
||||
* @param array $options Optional options to control what notifications are loaded
|
||||
* user_id User id to load notifications for (Default: $user->data['user_id'])
|
||||
* order_by Order by (Default: time)
|
||||
* order_dir Order direction (Default: DESC)
|
||||
* limit Number of notifications to load (Default: 5)
|
||||
* start Notifications offset (Default: 0)
|
||||
*/
|
||||
@ -58,12 +60,15 @@ class phpbb_notifications_service
|
||||
'user_id' => $user->data['user_id'],
|
||||
'limit' => 5,
|
||||
'start' => 0,
|
||||
'order_by' => 'time',
|
||||
'order_dir' => 'DESC',
|
||||
), $options);
|
||||
|
||||
$notifications = $user_ids = array();
|
||||
|
||||
$sql = 'SELECT * FROM ' . NOTIFICATIONS_TABLE . '
|
||||
WHERE user_id = ' . (int) $options['user_id'];
|
||||
WHERE user_id = ' . (int) $options['user_id'] . '
|
||||
ORDER BY ' . $this->db->sql_escape($options['order_by']) . ' ' . $this->db->sql_escape($options['order_dir']);
|
||||
$result = $this->db->sql_query_limit($sql, $options['limit'], $options['start']);
|
||||
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
|
@ -29,6 +29,8 @@ interface phpbb_notifications_type_interface
|
||||
|
||||
public function get_url();
|
||||
|
||||
public function get_full_url();
|
||||
|
||||
public function create_insert_array($type_data);
|
||||
|
||||
public static function find_users_for_notification(ContainerBuilder $phpbb_container, $type_data);
|
||||
|
@ -65,7 +65,17 @@ class phpbb_notifications_type_pm extends phpbb_notifications_type_base
|
||||
*/
|
||||
public function get_url()
|
||||
{
|
||||
return append_sid($this->phpbb_root_path . 'ucp.' . $this->php_ext, "i=pm&mode=view&p={$this->item_id}");
|
||||
return append_sid($this->phpbb_root_path . 'ucp.' . $this->php_ext, "i=pm&mode=view&p={$this->item_id}");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the full url to this item
|
||||
*
|
||||
* @return string URL
|
||||
*/
|
||||
public function get_full_url()
|
||||
{
|
||||
return generate_board_url() . "/ucp.{$this->php_ext}?i=pm&mode=view&p={$this->item_id}";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -108,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']))
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user