From ef47c691554f0592dfb65dca2844ad251cb1fbc5 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 14 Apr 2025 20:27:03 +0200 Subject: [PATCH] [ticket/17493] Remove notification method jabber PHPBB-17493 --- .../container/services_notification.yml | 13 --- phpBB/includes/acp/acp_email.php | 58 ++++------ phpBB/memberlist.php | 5 +- .../db/migration/data/v400/remove_jabber.php | 9 ++ phpBB/phpbb/notification/method/jabber.php | 104 ------------------ 5 files changed, 30 insertions(+), 159 deletions(-) delete mode 100644 phpBB/phpbb/notification/method/jabber.php diff --git a/phpBB/config/default/container/services_notification.yml b/phpBB/config/default/container/services_notification.yml index 0ac9dc6a88..ccf16223cf 100644 --- a/phpBB/config/default/container/services_notification.yml +++ b/phpBB/config/default/container/services_notification.yml @@ -233,19 +233,6 @@ services: tags: - { 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: class: phpbb\notification\method\webpush shared: false diff --git a/phpBB/includes/acp/acp_email.php b/phpBB/includes/acp/acp_email.php index dc62e385cd..8dbdbf409d 100644 --- a/phpBB/includes/acp/acp_email.php +++ b/phpBB/includes/acp/acp_email.php @@ -76,13 +76,13 @@ class acp_email { // If giving usernames the admin is able to email inactive users too... $sql_ary = array( - 'SELECT' => 'user_id, username, user_email, user_notify_type, user_lang', + 'SELECT' => 'user_id, username, user_email, user_lang', 'FROM' => array( USERS_TABLE => '', ), 'WHERE' => $db->sql_in_set('username_clean', array_map('utf8_clean_string', $usernames)) . ' AND user_allow_massemail = 1', - 'ORDER_BY' => 'user_lang, user_notify_type', + 'ORDER_BY' => 'user_lang', ); } else @@ -90,7 +90,7 @@ class acp_email if ($group_id) { $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( USERS_TABLE => 'u', USER_GROUP_TABLE => 'ug', @@ -100,19 +100,19 @@ class acp_email AND u.user_id = ug.user_id AND u.user_allow_massemail = 1 AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')', - 'ORDER_BY' => 'u.user_lang, u.user_notify_type', + 'ORDER_BY' => 'u.user_lang', ); } else { $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( USERS_TABLE => 'u', ), 'WHERE' => 'u.user_allow_massemail = 1 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']; $email_list = array(); $old_lang = $rows[0]['user_lang']; - $old_notify_type = $rows[0]['user_notify_type']; foreach ($rows as $row) { - if (($row['user_notify_type'] == messenger_interface::NOTIFY_EMAIL && $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 ($row['user_email']) { - 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; @@ -172,14 +169,11 @@ class acp_email } $old_lang = $row['user_lang']; - $old_notify_type = $row['user_notify_type']; } $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]['name'] = $row['username']; - $email_list[$j][$i]['jabber'] = $row['user_jabber']; $i++; } } @@ -225,7 +219,6 @@ class acp_email for ($i = 0, $size = count($email_list); $i < $size; $i++) { $used_lang = $email_list[$i][0]['lang']; - $used_method = $email_list[$i][0]['method']; /** * @var \phpbb\messenger\method\messenger_interface $messenger_method @@ -234,39 +227,28 @@ class acp_email foreach ($messenger_collection_iterator as $messenger_method) { $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->template($email_template, $used_lang); $messenger_method->subject(html_entity_decode($subject, ENT_COMPAT)); $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]; - 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']); - } + $messenger_method->to($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->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']); - } - } + $messenger_method->anti_abuse_headers($config, $user); + $messenger_method->set_mail_priority($priority); $errored = !$messenger_method->send() || $errored; $messenger_method->save_queue(); diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 3164ad6a84..e392463b4f 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -963,7 +963,7 @@ switch ($mode) $select_single = $request->variable('select_single', false); // 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 $form = (!preg_match('/^[a-z0-9_-]+$/i', $form)) ? '' : $form; @@ -1316,7 +1316,6 @@ switch ($mode) 'select_single' => array('select_single', $select_single), 'username' => array('username', '', true), 'email' => array('email', ''), - 'jabber' => array('jabber', ''), 'search_group_id' => array('search_group_id', 0), 'joined_select' => array('joined_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_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_SEARCH_USER' => ($mode == 'searchuser' || ($mode == '' && $submit)), 'S_FORM_NAME' => $form, @@ -1706,7 +1704,6 @@ switch ($mode) 'PROFILE_IMG' => $user->img('icon_user_profile', $user->lang['PROFILE']), 'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']), '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']), '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) : '')) : '', diff --git a/phpBB/phpbb/db/migration/data/v400/remove_jabber.php b/phpBB/phpbb/db/migration/data/v400/remove_jabber.php index 48d933d626..994f8c0167 100644 --- a/phpBB/phpbb/db/migration/data/v400/remove_jabber.php +++ b/phpBB/phpbb/db/migration/data/v400/remove_jabber.php @@ -20,6 +20,7 @@ class remove_jabber extends migration public static function depends_on(): array { 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\v400\dev', '\phpbb\db\migration\data\v400\add_webpush', @@ -68,6 +69,7 @@ class remove_jabber extends migration ]], ['permission.remove', ['a_jabber']], ['permission.remove', ['u_sendim']], + ['custom', [[$this, 'remove_from_user_notifcations']]], ]; } @@ -98,4 +100,11 @@ class remove_jabber extends migration ['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); + } } diff --git a/phpBB/phpbb/notification/method/jabber.php b/phpBB/phpbb/notification/method/jabber.php deleted file mode 100644 index e3482f98be..0000000000 --- a/phpBB/phpbb/notification/method/jabber.php +++ /dev/null @@ -1,104 +0,0 @@ - -* @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/'); - } -}