mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/17493] Remove notification method jabber
PHPBB-17493
This commit is contained in:
parent
3128b3fa9b
commit
ef47c69155
5 changed files with 30 additions and 159 deletions
|
@ -233,19 +233,6 @@ services:
|
||||||
tags:
|
tags:
|
||||||
- { name: notification.method }
|
- { name: notification.method }
|
||||||
|
|
||||||
notification.method.jabber:
|
|
||||||
class: phpbb\notification\method\jabber
|
|
||||||
shared: false
|
|
||||||
arguments:
|
|
||||||
- '@user_loader'
|
|
||||||
- '@user'
|
|
||||||
- '@config'
|
|
||||||
- '%core.root_path%'
|
|
||||||
- '%core.php_ext%'
|
|
||||||
- '@messenger.method_collection'
|
|
||||||
tags:
|
|
||||||
- { name: notification.method }
|
|
||||||
|
|
||||||
notification.method.webpush:
|
notification.method.webpush:
|
||||||
class: phpbb\notification\method\webpush
|
class: phpbb\notification\method\webpush
|
||||||
shared: false
|
shared: false
|
||||||
|
|
|
@ -76,13 +76,13 @@ class acp_email
|
||||||
{
|
{
|
||||||
// If giving usernames the admin is able to email inactive users too...
|
// If giving usernames the admin is able to email inactive users too...
|
||||||
$sql_ary = array(
|
$sql_ary = array(
|
||||||
'SELECT' => 'user_id, username, user_email, user_notify_type, user_lang',
|
'SELECT' => 'user_id, username, user_email, user_lang',
|
||||||
'FROM' => array(
|
'FROM' => array(
|
||||||
USERS_TABLE => '',
|
USERS_TABLE => '',
|
||||||
),
|
),
|
||||||
'WHERE' => $db->sql_in_set('username_clean', array_map('utf8_clean_string', $usernames)) . '
|
'WHERE' => $db->sql_in_set('username_clean', array_map('utf8_clean_string', $usernames)) . '
|
||||||
AND user_allow_massemail = 1',
|
AND user_allow_massemail = 1',
|
||||||
'ORDER_BY' => 'user_lang, user_notify_type',
|
'ORDER_BY' => 'user_lang',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -90,7 +90,7 @@ class acp_email
|
||||||
if ($group_id)
|
if ($group_id)
|
||||||
{
|
{
|
||||||
$sql_ary = array(
|
$sql_ary = array(
|
||||||
'SELECT' => 'u.user_id, u.user_email, u.username, u.username_clean, u.user_lang, u.user_notify_type',
|
'SELECT' => 'u.user_id, u.user_email, u.username, u.username_clean, u.user_lang',
|
||||||
'FROM' => array(
|
'FROM' => array(
|
||||||
USERS_TABLE => 'u',
|
USERS_TABLE => 'u',
|
||||||
USER_GROUP_TABLE => 'ug',
|
USER_GROUP_TABLE => 'ug',
|
||||||
|
@ -100,19 +100,19 @@ class acp_email
|
||||||
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 . ')',
|
||||||
'ORDER_BY' => 'u.user_lang, u.user_notify_type',
|
'ORDER_BY' => 'u.user_lang',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sql_ary = array(
|
$sql_ary = array(
|
||||||
'SELECT' => 'u.user_id, u.username, u.username_clean, u.user_email, u.user_lang, u.user_notify_type',
|
'SELECT' => 'u.user_id, u.username, u.username_clean, u.user_email, u.user_lang',
|
||||||
'FROM' => array(
|
'FROM' => array(
|
||||||
USERS_TABLE => 'u',
|
USERS_TABLE => 'u',
|
||||||
),
|
),
|
||||||
'WHERE' => 'u.user_allow_massemail = 1
|
'WHERE' => 'u.user_allow_massemail = 1
|
||||||
AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')',
|
AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')',
|
||||||
'ORDER_BY' => 'u.user_lang, u.user_notify_type',
|
'ORDER_BY' => 'u.user_lang',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,15 +154,12 @@ class acp_email
|
||||||
$max_chunk_size = (int) $config['email_max_chunk_size'];
|
$max_chunk_size = (int) $config['email_max_chunk_size'];
|
||||||
$email_list = array();
|
$email_list = array();
|
||||||
$old_lang = $rows[0]['user_lang'];
|
$old_lang = $rows[0]['user_lang'];
|
||||||
$old_notify_type = $rows[0]['user_notify_type'];
|
|
||||||
|
|
||||||
foreach ($rows as $row)
|
foreach ($rows as $row)
|
||||||
{
|
{
|
||||||
if (($row['user_notify_type'] == messenger_interface::NOTIFY_EMAIL && $row['user_email']) ||
|
if ($row['user_email'])
|
||||||
($row['user_notify_type'] == messenger_interface::NOTIFY_IM && $row['user_jabber']) ||
|
|
||||||
($row['user_notify_type'] == messenger_interface::NOTIFY_BOTH && ($row['user_email'] || $row['user_jabber'])))
|
|
||||||
{
|
{
|
||||||
if ($i == $max_chunk_size || $row['user_lang'] != $old_lang || $row['user_notify_type'] != $old_notify_type)
|
if ($i == $max_chunk_size || $row['user_lang'] != $old_lang)
|
||||||
{
|
{
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
|
@ -172,14 +169,11 @@ class acp_email
|
||||||
}
|
}
|
||||||
|
|
||||||
$old_lang = $row['user_lang'];
|
$old_lang = $row['user_lang'];
|
||||||
$old_notify_type = $row['user_notify_type'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$email_list[$j][$i]['lang'] = $row['user_lang'];
|
$email_list[$j][$i]['lang'] = $row['user_lang'];
|
||||||
$email_list[$j][$i]['method'] = $row['user_notify_type'];
|
|
||||||
$email_list[$j][$i]['email'] = $row['user_email'];
|
$email_list[$j][$i]['email'] = $row['user_email'];
|
||||||
$email_list[$j][$i]['name'] = $row['username'];
|
$email_list[$j][$i]['name'] = $row['username'];
|
||||||
$email_list[$j][$i]['jabber'] = $row['user_jabber'];
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -225,7 +219,6 @@ class acp_email
|
||||||
for ($i = 0, $size = count($email_list); $i < $size; $i++)
|
for ($i = 0, $size = count($email_list); $i < $size; $i++)
|
||||||
{
|
{
|
||||||
$used_lang = $email_list[$i][0]['lang'];
|
$used_lang = $email_list[$i][0]['lang'];
|
||||||
$used_method = $email_list[$i][0]['method'];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \phpbb\messenger\method\messenger_interface $messenger_method
|
* @var \phpbb\messenger\method\messenger_interface $messenger_method
|
||||||
|
@ -234,39 +227,28 @@ class acp_email
|
||||||
foreach ($messenger_collection_iterator as $messenger_method)
|
foreach ($messenger_collection_iterator as $messenger_method)
|
||||||
{
|
{
|
||||||
$notify_method = $messenger_method->get_id();
|
$notify_method = $messenger_method->get_id();
|
||||||
if ($notify_method == $used_method || $used_method == messenger_interface::NOTIFY_BOTH)
|
if ($notify_method == messenger_interface::NOTIFY_EMAIL)
|
||||||
{
|
{
|
||||||
$messenger_method->set_use_queue($use_queue);
|
$messenger_method->set_use_queue($use_queue);
|
||||||
$messenger_method->template($email_template, $used_lang);
|
$messenger_method->template($email_template, $used_lang);
|
||||||
$messenger_method->subject(html_entity_decode($subject, ENT_COMPAT));
|
$messenger_method->subject(html_entity_decode($subject, ENT_COMPAT));
|
||||||
$messenger_method->assign_vars($template_data);
|
$messenger_method->assign_vars($template_data);
|
||||||
|
|
||||||
if ($notify_method == messenger_interface::NOTIFY_EMAIL)
|
for ($j = 0, $list_size = count($email_list[$i]); $j < $list_size; $j++)
|
||||||
{
|
{
|
||||||
for ($j = 0, $list_size = count($email_list[$i]); $j < $list_size; $j++)
|
$email_row = $email_list[$i][$j];
|
||||||
|
if (count($email_list[$i]) == 1)
|
||||||
{
|
{
|
||||||
$email_row = $email_list[$i][$j];
|
$messenger_method->to($email_row['email'], $email_row['name']);
|
||||||
if (count($email_list[$i]) == 1)
|
|
||||||
{
|
|
||||||
$messenger_method->to($email_row['email'], $email_row['name']);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$messenger_method->bcc($email_row['email'], $email_row['name']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$messenger_method->bcc($email_row['email'], $email_row['name']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$messenger_method->anti_abuse_headers($config, $user);
|
$messenger_method->anti_abuse_headers($config, $user);
|
||||||
$messenger_method->set_mail_priority($priority);
|
$messenger_method->set_mail_priority($priority);
|
||||||
}
|
|
||||||
else if ($notify_method == messenger_interface::NOTIFY_IM)
|
|
||||||
{
|
|
||||||
for ($j = 0, $list_size = count($email_list[$i]); $j < $list_size; $j++)
|
|
||||||
{
|
|
||||||
$email_row = $email_list[$i][$j];
|
|
||||||
$messenger_method->to($email_row['jabber'], $email_row['name']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$errored = !$messenger_method->send() || $errored;
|
$errored = !$messenger_method->send() || $errored;
|
||||||
$messenger_method->save_queue();
|
$messenger_method->save_queue();
|
||||||
|
|
|
@ -963,7 +963,7 @@ switch ($mode)
|
||||||
$select_single = $request->variable('select_single', false);
|
$select_single = $request->variable('select_single', false);
|
||||||
|
|
||||||
// Search URL parameters, if any of these are in the URL we do a search
|
// Search URL parameters, if any of these are in the URL we do a search
|
||||||
$search_params = array('username', 'email', 'jabber', 'search_group_id', 'joined_select', 'active_select', 'count_select', 'joined', 'active', 'count', 'ip');
|
$search_params = array('username', 'email', 'search_group_id', 'joined_select', 'active_select', 'count_select', 'joined', 'active', 'count', 'ip');
|
||||||
|
|
||||||
// We validate form and field here, only id/class allowed
|
// We validate form and field here, only id/class allowed
|
||||||
$form = (!preg_match('/^[a-z0-9_-]+$/i', $form)) ? '' : $form;
|
$form = (!preg_match('/^[a-z0-9_-]+$/i', $form)) ? '' : $form;
|
||||||
|
@ -1316,7 +1316,6 @@ switch ($mode)
|
||||||
'select_single' => array('select_single', $select_single),
|
'select_single' => array('select_single', $select_single),
|
||||||
'username' => array('username', '', true),
|
'username' => array('username', '', true),
|
||||||
'email' => array('email', ''),
|
'email' => array('email', ''),
|
||||||
'jabber' => array('jabber', ''),
|
|
||||||
'search_group_id' => array('search_group_id', 0),
|
'search_group_id' => array('search_group_id', 0),
|
||||||
'joined_select' => array('joined_select', 'lt'),
|
'joined_select' => array('joined_select', 'lt'),
|
||||||
'active_select' => array('active_select', 'lt'),
|
'active_select' => array('active_select', 'lt'),
|
||||||
|
@ -1478,7 +1477,6 @@ switch ($mode)
|
||||||
|
|
||||||
'S_IP_SEARCH_ALLOWED' => ($auth->acl_getf_global('m_info')) ? true : false,
|
'S_IP_SEARCH_ALLOWED' => ($auth->acl_getf_global('m_info')) ? true : false,
|
||||||
'S_EMAIL_SEARCH_ALLOWED'=> ($auth->acl_get('a_user')) ? true : false,
|
'S_EMAIL_SEARCH_ALLOWED'=> ($auth->acl_get('a_user')) ? true : false,
|
||||||
'S_JABBER_ENABLED' => $config['jab_enable'],
|
|
||||||
'S_IN_SEARCH_POPUP' => ($form && $field) ? true : false,
|
'S_IN_SEARCH_POPUP' => ($form && $field) ? true : false,
|
||||||
'S_SEARCH_USER' => ($mode == 'searchuser' || ($mode == '' && $submit)),
|
'S_SEARCH_USER' => ($mode == 'searchuser' || ($mode == '' && $submit)),
|
||||||
'S_FORM_NAME' => $form,
|
'S_FORM_NAME' => $form,
|
||||||
|
@ -1706,7 +1704,6 @@ switch ($mode)
|
||||||
'PROFILE_IMG' => $user->img('icon_user_profile', $user->lang['PROFILE']),
|
'PROFILE_IMG' => $user->img('icon_user_profile', $user->lang['PROFILE']),
|
||||||
'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']),
|
'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']),
|
||||||
'EMAIL_IMG' => $user->img('icon_contact_email', $user->lang['EMAIL']),
|
'EMAIL_IMG' => $user->img('icon_contact_email', $user->lang['EMAIL']),
|
||||||
'JABBER_IMG' => $user->img('icon_contact_jabber', $user->lang['JABBER']),
|
|
||||||
'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']),
|
'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']),
|
||||||
|
|
||||||
'U_FIND_MEMBER' => ($config['load_search'] || $auth->acl_get('a_')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser' . (($start) ? "&start=$start" : '') . (!empty($params) ? '&' . implode('&', $params) : '')) : '',
|
'U_FIND_MEMBER' => ($config['load_search'] || $auth->acl_get('a_')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser' . (($start) ? "&start=$start" : '') . (!empty($params) ? '&' . implode('&', $params) : '')) : '',
|
||||||
|
|
|
@ -20,6 +20,7 @@ class remove_jabber extends migration
|
||||||
public static function depends_on(): array
|
public static function depends_on(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
'\phpbb\db\migration\data\v310\notifications_use_full_name',
|
||||||
'\phpbb\db\migration\data\v31x\add_jabber_ssl_context_config_options',
|
'\phpbb\db\migration\data\v31x\add_jabber_ssl_context_config_options',
|
||||||
'\phpbb\db\migration\data\v400\dev',
|
'\phpbb\db\migration\data\v400\dev',
|
||||||
'\phpbb\db\migration\data\v400\add_webpush',
|
'\phpbb\db\migration\data\v400\add_webpush',
|
||||||
|
@ -68,6 +69,7 @@ class remove_jabber extends migration
|
||||||
]],
|
]],
|
||||||
['permission.remove', ['a_jabber']],
|
['permission.remove', ['a_jabber']],
|
||||||
['permission.remove', ['u_sendim']],
|
['permission.remove', ['u_sendim']],
|
||||||
|
['custom', [[$this, 'remove_from_user_notifcations']]],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,4 +100,11 @@ class remove_jabber extends migration
|
||||||
['permission.add', ['u_sendim', true]],
|
['permission.add', ['u_sendim', true]],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function remove_from_user_notifcations()
|
||||||
|
{
|
||||||
|
$sql = 'DELETE FROM ' . $this->table_prefix . 'user_notifications
|
||||||
|
WHERE notification_method = ' . $this->db->sql_escape('notification.method.jabber');
|
||||||
|
$this->db->sql_query($sql);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,104 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* This file is part of the phpBB Forum Software package.
|
|
||||||
*
|
|
||||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
|
||||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
|
||||||
*
|
|
||||||
* For full copyright and license information, please see
|
|
||||||
* the docs/CREDITS.txt file.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace phpbb\notification\method;
|
|
||||||
|
|
||||||
use phpbb\notification\type\type_interface;
|
|
||||||
use phpbb\user;
|
|
||||||
use phpbb\user_loader;
|
|
||||||
use phpbb\config\config;
|
|
||||||
use phpbb\di\service_collection;
|
|
||||||
use phpbb\messenger\method\messenger_interface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Jabber notification method class
|
|
||||||
* This class handles sending Jabber messages for notifications
|
|
||||||
*/
|
|
||||||
|
|
||||||
class jabber extends \phpbb\notification\method\messenger_base
|
|
||||||
{
|
|
||||||
/** @var user */
|
|
||||||
protected $user;
|
|
||||||
|
|
||||||
/** @var config */
|
|
||||||
protected $config;
|
|
||||||
|
|
||||||
/** @var service_collection */
|
|
||||||
protected $messenger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Notification Method jabber Constructor
|
|
||||||
*
|
|
||||||
* @param user_loader $user_loader
|
|
||||||
* @param user $user
|
|
||||||
* @param config $config
|
|
||||||
* @param string $phpbb_root_path
|
|
||||||
* @param string $php_ext
|
|
||||||
* @param service_collection $messenger
|
|
||||||
*/
|
|
||||||
public function __construct(user_loader $user_loader, user $user, config $config, $phpbb_root_path, $php_ext, service_collection $messenger)
|
|
||||||
{
|
|
||||||
parent::__construct($messenger, $user_loader, $phpbb_root_path, $php_ext);
|
|
||||||
|
|
||||||
$this->user = $user;
|
|
||||||
$this->config = $config;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get notification method name
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function get_type()
|
|
||||||
{
|
|
||||||
return 'notification.method.jabber';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Is this method available for the user?
|
|
||||||
* This is checked on the notifications options
|
|
||||||
*
|
|
||||||
* @param type_interface|null $notification_type An optional instance of a notification type. If provided, this
|
|
||||||
* method additionally checks if the type provides an email template.
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function is_available(type_interface $notification_type = null)
|
|
||||||
{
|
|
||||||
return parent::is_available($notification_type) && $this->global_available() && !empty($this->user->data['user_jabber']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Is this method available at all?
|
|
||||||
* This is checked before notifications are sent
|
|
||||||
*/
|
|
||||||
public function global_available()
|
|
||||||
{
|
|
||||||
return !(
|
|
||||||
empty($this->config['jab_enable']) ||
|
|
||||||
empty($this->config['jab_host']) ||
|
|
||||||
empty($this->config['jab_username']) ||
|
|
||||||
empty($this->config['jab_password']) ||
|
|
||||||
!@extension_loaded('xml')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function notify()
|
|
||||||
{
|
|
||||||
if (!$this->global_available())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->notify_using_messenger(messenger_interface::NOTIFY_IM, 'short/');
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue