From 860c2fe6018b77c0f86e2928d959b172708eef0d Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 13 Apr 2025 10:26:30 +0200 Subject: [PATCH 01/23] [ticket/17493] Start adding migration for removing jabber PHPBB-17493 --- .../db/migration/data/v400/remove_jabber.php | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 phpBB/phpbb/db/migration/data/v400/remove_jabber.php diff --git a/phpBB/phpbb/db/migration/data/v400/remove_jabber.php b/phpBB/phpbb/db/migration/data/v400/remove_jabber.php new file mode 100644 index 0000000000..acf61b2632 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v400/remove_jabber.php @@ -0,0 +1,83 @@ + + * @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\db\migration\data\v400; + +use phpbb\db\migration\migration; + +class remove_jabber extends migration +{ + public static function depends_on(): array + { + return [ + '\phpbb\db\migration\data\v400\dev', + '\phpbb\db\migration\data\v400\add_webpush', + ]; + } + + public function update_schema(): array + { + return [ + 'drop_columns' => [ + $this->table_prefix . 'users' => [ + 'user_jabber', + ], + ] + ]; + } + + public function effectively_installed() + { + return true; + } + + public function revert_schema(): array + { + return [ + 'add_columns' => [ + $this->table_prefix . 'users' => [ + 'user_jabber' => ['VCHAR_UNI', ''], + ], + ] + ]; + } + + public function update_data(): array + { + return [ + ['config.remove', ['jab_verify_peer']], + ['config.remove', ['jab_verify_peer_name']], + ['config.remove', ['jab_allow_self_signed']], + ]; + } + + public function revert_data(): array + { + return [ + ['config.add', ['jab_verify_peer', 1]], + ['config.add', ['jab_verify_peer_name', 1]], + ['config.add', ['jab_allow_self_signed', 0]], + ['module.add', [ + 'acp', + 'ACP_CLIENT_COMMUNICATION', + [ + 'module_basename' => 'acp_board', + 'module_langname' => 'ACP_WEBPUSH_SETTINGS', + 'module_mode' => 'webpush', + 'module_auth' => 'acl_a_board', + 'after' => ['settings', 'ACP_JABBER_SETTINGS'], + ], + ]], + ]; + } +} From a5c34234da0004a9a0b059458d7e8b3f0cee6cf1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 13 Apr 2025 12:56:03 +0200 Subject: [PATCH 02/23] [ticket/17493] Update migration with module to remove PHPBB-17493 --- .../db/migration/data/v400/remove_jabber.php | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/phpBB/phpbb/db/migration/data/v400/remove_jabber.php b/phpBB/phpbb/db/migration/data/v400/remove_jabber.php index acf61b2632..4398b3bd3c 100644 --- a/phpBB/phpbb/db/migration/data/v400/remove_jabber.php +++ b/phpBB/phpbb/db/migration/data/v400/remove_jabber.php @@ -55,15 +55,34 @@ class remove_jabber extends migration public function update_data(): array { return [ + ['config.remove', ['jab_enable']], + ['config.remove', ['jab_host']], + ['config.remove', ['jab_package_size']], + ['config.remove', ['jab_password']], + ['config.remove', ['jab_port']], + ['config.remove', ['jab_use_ssl']], + ['config.remove', ['jab_username']], ['config.remove', ['jab_verify_peer']], ['config.remove', ['jab_verify_peer_name']], ['config.remove', ['jab_allow_self_signed']], + ['module.remove', [ + 'acp', + 'ACP_CLIENT_COMMUNICATION', + 'ACP_JABBER_SETTINGS', + ]], ]; } public function revert_data(): array { return [ + ['config.add', ['jab_enable', 0]], + ['config.add', ['jab_host', '']], + ['config.add', ['jab_package_size', 20]], + ['config.add', ['jab_password', '']], + ['config.add', ['jab_port', 5222]], + ['config.add', ['jab_use_ssl', 0]], + ['config.add', ['jab_username', '']], ['config.add', ['jab_verify_peer', 1]], ['config.add', ['jab_verify_peer_name', 1]], ['config.add', ['jab_allow_self_signed', 0]], @@ -71,11 +90,10 @@ class remove_jabber extends migration 'acp', 'ACP_CLIENT_COMMUNICATION', [ - 'module_basename' => 'acp_board', - 'module_langname' => 'ACP_WEBPUSH_SETTINGS', - 'module_mode' => 'webpush', - 'module_auth' => 'acl_a_board', - 'after' => ['settings', 'ACP_JABBER_SETTINGS'], + 'module_basename' => 'acp_jabber', + 'module_langname' => 'ACP_JABBER_SETTINGS', + 'module_mode' => 'settings', + 'module_auth' => 'acl_a_jabber', ], ]], ]; From afbc0794d2cee2dbfc24166d50e4320202d4ebe4 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 13 Apr 2025 13:02:51 +0200 Subject: [PATCH 03/23] [ticket/17493] Remove jabber settings from schema data PHPBB-17493 --- phpBB/install/schemas/schema_data.sql | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 43b8f95fc8..ad9d5e3e5a 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -168,16 +168,6 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('ip_check', '3'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('ip_login_limit_max', '50'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('ip_login_limit_time', '21600'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('ip_login_limit_use_forwarded', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('jab_allow_self_signed', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('jab_enable', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('jab_host', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('jab_package_size', '20'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('jab_password', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('jab_port', '5222'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('jab_use_ssl', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('jab_username', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('jab_verify_peer', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('jab_verify_peer_name', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_base_dn', ''); INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_email', ''); INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_password', ''); From 8c6731ffb9527797b0e35c685fc0106441078c19 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 13 Apr 2025 13:13:38 +0200 Subject: [PATCH 04/23] [ticket/17493] Remove jabber permission and effectively_installed PHPBB-17493 --- phpBB/phpbb/db/migration/data/v400/remove_jabber.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/phpBB/phpbb/db/migration/data/v400/remove_jabber.php b/phpBB/phpbb/db/migration/data/v400/remove_jabber.php index 4398b3bd3c..1669e7e0c1 100644 --- a/phpBB/phpbb/db/migration/data/v400/remove_jabber.php +++ b/phpBB/phpbb/db/migration/data/v400/remove_jabber.php @@ -36,11 +36,6 @@ class remove_jabber extends migration ]; } - public function effectively_installed() - { - return true; - } - public function revert_schema(): array { return [ @@ -70,6 +65,7 @@ class remove_jabber extends migration 'ACP_CLIENT_COMMUNICATION', 'ACP_JABBER_SETTINGS', ]], + ['permission.remove', ['a_jabber']], ]; } @@ -96,6 +92,7 @@ class remove_jabber extends migration 'module_auth' => 'acl_a_jabber', ], ]], + ['permission.add', ['a_jabber', true]], ]; } } From 30178ee443f46110c934b353e7e02d6678c2f851 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 13 Apr 2025 16:16:31 +0200 Subject: [PATCH 05/23] [ticket/17493] Start removing jabber from acp PHPBB-17493 --- phpBB/adm/style/acp_jabber.html | 83 ------------ phpBB/adm/style/acp_users_prefs.html | 6 - phpBB/adm/style/acp_users_profile.html | 4 - phpBB/includes/acp/acp_email.php | 6 +- phpBB/includes/acp/acp_inactive.php | 2 +- phpBB/includes/acp/acp_jabber.php | 139 -------------------- phpBB/includes/acp/acp_users.php | 7 - phpBB/includes/acp/info/acp_jabber.php | 34 ----- phpBB/language/en/acp/board.php | 28 ---- phpBB/language/en/acp/common.php | 8 -- phpBB/language/en/acp/permissions_phpbb.php | 1 - 11 files changed, 4 insertions(+), 314 deletions(-) delete mode 100644 phpBB/adm/style/acp_jabber.html delete mode 100644 phpBB/includes/acp/acp_jabber.php delete mode 100644 phpBB/includes/acp/info/acp_jabber.php diff --git a/phpBB/adm/style/acp_jabber.html b/phpBB/adm/style/acp_jabber.html deleted file mode 100644 index 5267062106..0000000000 --- a/phpBB/adm/style/acp_jabber.html +++ /dev/null @@ -1,83 +0,0 @@ - - - - -

{L_ACP_JABBER_SETTINGS}

- -

{L_ACP_JABBER_SETTINGS_EXPLAIN}

- - -
-

{L_WARNING}

-

{WARNING_MSG}

-
- - -
- -
- {L_ACP_JABBER_SETTINGS} - -

{L_JAB_GTALK_NOTE}

- -
-

{L_JAB_ENABLE_EXPLAIN}
-
-
-
-
-

{L_JAB_SERVER_EXPLAIN}
-
-
-
-

{L_JAB_PORT_EXPLAIN}
-
-
-
-

{L_JAB_USERNAME_EXPLAIN}
-
-
-
-

{L_JAB_PASSWORD_EXPLAIN}
-
-
- -
-

{L_JAB_USE_SSL_EXPLAIN}
-
-
-
-
-

{L_JAB_VERIFY_PEER_EXPLAIN}
-
-
-
-
-

{L_JAB_VERIFY_PEER_NAME_EXPLAIN}
-
-
-
-
-

{L_JAB_ALLOW_SELF_SIGNED_EXPLAIN}
-
-
-
- -
-

{L_JAB_PACKAGE_SIZE_EXPLAIN}
-
-
- -
- -
- {L_ACP_SUBMIT_CHANGES} -

-   - -

- {S_FORM_TOKEN} -
-
- - diff --git a/phpBB/adm/style/acp_users_prefs.html b/phpBB/adm/style/acp_users_prefs.html index d485d1e113..7dbef95974 100644 --- a/phpBB/adm/style/acp_users_prefs.html +++ b/phpBB/adm/style/acp_users_prefs.html @@ -29,12 +29,6 @@
-
-

{L_NOTIFY_METHOD_EXPLAIN}
-
- -
-
diff --git a/phpBB/adm/style/acp_users_profile.html b/phpBB/adm/style/acp_users_profile.html index 9296638ff6..54f7245f81 100644 --- a/phpBB/adm/style/acp_users_profile.html +++ b/phpBB/adm/style/acp_users_profile.html @@ -3,10 +3,6 @@
{L_USER_PROFILE} -
-
-
-

{L_BIRTHDAY_EXPLAIN}
{L_DAY}{L_COLON} {L_MONTH}{L_COLON} {L_YEAR}{L_COLON}
diff --git a/phpBB/includes/acp/acp_email.php b/phpBB/includes/acp/acp_email.php index dfe58eb318..dc62e385cd 100644 --- a/phpBB/includes/acp/acp_email.php +++ b/phpBB/includes/acp/acp_email.php @@ -76,7 +76,7 @@ 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_jabber, user_notify_type, user_lang', + 'SELECT' => 'user_id, username, user_email, user_notify_type, user_lang', 'FROM' => array( USERS_TABLE => '', ), @@ -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_jabber, u.user_notify_type', + 'SELECT' => 'u.user_id, u.user_email, u.username, u.username_clean, u.user_lang, u.user_notify_type', 'FROM' => array( USERS_TABLE => 'u', USER_GROUP_TABLE => 'ug', @@ -106,7 +106,7 @@ class acp_email else { $sql_ary = array( - 'SELECT' => 'u.user_id, u.username, u.username_clean, u.user_email, u.user_jabber, u.user_lang, u.user_notify_type', + 'SELECT' => 'u.user_id, u.username, u.username_clean, u.user_email, u.user_lang, u.user_notify_type', 'FROM' => array( USERS_TABLE => 'u', ), diff --git a/phpBB/includes/acp/acp_inactive.php b/phpBB/includes/acp/acp_inactive.php index e1a511852b..138e06e525 100644 --- a/phpBB/includes/acp/acp_inactive.php +++ b/phpBB/includes/acp/acp_inactive.php @@ -185,7 +185,7 @@ class acp_inactive trigger_error($user->lang['EMAIL_DISABLED'] . adm_back_link($this->u_action), E_USER_WARNING); } - $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type, user_regdate, user_actkey + $sql = 'SELECT user_id, username, user_email, user_lang, user_notify_type, user_regdate, user_actkey FROM ' . USERS_TABLE . ' WHERE ' . $db->sql_in_set('user_id', $mark) . ' AND user_inactive_reason'; diff --git a/phpBB/includes/acp/acp_jabber.php b/phpBB/includes/acp/acp_jabber.php deleted file mode 100644 index fce1dee1df..0000000000 --- a/phpBB/includes/acp/acp_jabber.php +++ /dev/null @@ -1,139 +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. -* -*/ - -/** -* @todo Check/enter/update transport info -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class acp_jabber -{ - var $u_action; - - function main($id, $mode) - { - global $db, $user, $template, $phpbb_log, $request; - global $config, $phpbb_container, $phpbb_root_path, $phpEx; - - $jabber = $phpbb_container->get('messenger.method.jabber'); - - $user->add_lang('acp/board'); - - $submit = (isset($_POST['submit'])) ? true : false; - - if ($mode != 'settings') - { - return; - } - - $this->tpl_name = 'acp_jabber'; - $this->page_title = 'ACP_JABBER_SETTINGS'; - - $jab_enable = $request->variable('jab_enable', (bool) $config['jab_enable']); - $jab_host = $request->variable('jab_host', (string) $config['jab_host']); - $jab_port = $request->variable('jab_port', (int) $config['jab_port']); - $jab_username = $request->variable('jab_username', (string) $config['jab_username']); - $jab_password = $request->variable('jab_password', (string) $config['jab_password']); - $jab_package_size = $request->variable('jab_package_size', (int) $config['jab_package_size']); - $jab_use_ssl = $request->variable('jab_use_ssl', (bool) $config['jab_use_ssl']); - $jab_verify_peer = $request->variable('jab_verify_peer', (bool) $config['jab_verify_peer']); - $jab_verify_peer_name = $request->variable('jab_verify_peer_name', (bool) $config['jab_verify_peer_name']); - $jab_allow_self_signed = $request->variable('jab_allow_self_signed', (bool) $config['jab_allow_self_signed']); - - $form_name = 'acp_jabber'; - add_form_key($form_name); - - if ($submit) - { - if (!check_form_key($form_name)) - { - trigger_error($user->lang['FORM_INVALID']. adm_back_link($this->u_action), E_USER_WARNING); - } - - $message = $user->lang['JAB_SETTINGS_CHANGED']; - $log = 'JAB_SETTINGS_CHANGED'; - - // Is this feature enabled? Then try to establish a connection - if ($jabber->is_enabled()) - { - if (!$jabber->connect()) - { - trigger_error($user->lang['ERR_JAB_CONNECT'] . '

' . $jabber->get_log() . adm_back_link($this->u_action), E_USER_WARNING); - } - - // We'll try to authorise using this account - if (!$jabber->login()) - { - trigger_error($user->lang['ERR_JAB_AUTH'] . '

' . $jabber->get_log() . adm_back_link($this->u_action), E_USER_WARNING); - } - - $jabber->disconnect(); - } - else - { - // This feature is disabled. - // We update the user table to be sure all users that have IM as notify type are set to both as notify type - // We set this to both because users still have their jabber address entered and may want to receive jabber notifications again once it is re-enabled. - $sql_ary = array( - 'user_notify_type' => $jabber::NOTIFY_BOTH, - ); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE user_notify_type = ' . $jabber::NOTIFY_IM; - $db->sql_query($sql); - } - - $config->set('jab_enable', $jab_enable); - $config->set('jab_host', $jab_host); - $config->set('jab_port', $jab_port); - $config->set('jab_username', $jab_username); - if ($jab_password !== '********') - { - $config->set('jab_password', $jab_password); - } - $config->set('jab_package_size', $jab_package_size); - $config->set('jab_use_ssl', $jab_use_ssl); - $config->set('jab_verify_peer', $jab_verify_peer); - $config->set('jab_verify_peer_name', $jab_verify_peer_name); - $config->set('jab_allow_self_signed', $jab_allow_self_signed); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_' . $log); - trigger_error($message . adm_back_link($this->u_action)); - } - - $template->assign_vars(array( - 'U_ACTION' => $this->u_action, - 'JAB_ENABLE' => $jab_enable, - 'L_JAB_SERVER_EXPLAIN' => sprintf($user->lang['JAB_SERVER_EXPLAIN'], '', ''), - 'JAB_HOST' => $jab_host, - 'JAB_PORT' => ($jab_port) ? $jab_port : '', - 'JAB_USERNAME' => $jab_username, - 'JAB_PASSWORD' => $jab_password !== '' ? '********' : '', - 'JAB_PACKAGE_SIZE' => $jab_package_size, - 'JAB_USE_SSL' => $jab_use_ssl, - 'JAB_VERIFY_PEER' => $jab_verify_peer, - 'JAB_VERIFY_PEER_NAME' => $jab_verify_peer_name, - 'JAB_ALLOW_SELF_SIGNED' => $jab_allow_self_signed, - 'S_CAN_USE_SSL' => $jabber::can_use_ssl(), - 'S_GTALK_NOTE' => (!@function_exists('dns_get_record')) ? true : false, - )); - } -} diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index a954ec09f0..e01eace64e 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1426,7 +1426,6 @@ class acp_users $user_row['iso_lang_id'] = $row['lang_id']; $data = array( - 'jabber' => $request->variable('jabber', $user_row['user_jabber'], true), 'bday_day' => 0, 'bday_month' => 0, 'bday_year' => 0, @@ -1458,9 +1457,6 @@ class acp_users if ($submit) { $error = validate_data($data, array( - 'jabber' => array( - array('string', true, 5, 255), - array('jabber')), 'bday_day' => array('num', true, 1, 31), 'bday_month' => array('num', true, 1, 12), 'bday_year' => array('num', true, 1901, gmdate('Y', time())), @@ -1496,7 +1492,6 @@ class acp_users if (!count($error)) { $sql_ary = array( - 'user_jabber' => $data['jabber'], 'user_birthday' => $data['user_birthday'], ); @@ -1553,7 +1548,6 @@ class acp_users unset($now); $template->assign_vars(array( - 'JABBER' => $data['jabber'], 'S_BIRTHDAY_DAY_OPTIONS' => $s_birthday_day_options, 'S_BIRTHDAY_MONTH_OPTIONS' => $s_birthday_month_options, 'S_BIRTHDAY_YEAR_OPTIONS' => $s_birthday_year_options, @@ -1787,7 +1781,6 @@ class acp_users $user_prefs_data = array( 'S_PREFS' => true, - 'S_JABBER_DISABLED' => ($config['jab_enable'] && $user_row['user_jabber'] && @extension_loaded('xml')) ? false : true, 'VIEW_EMAIL' => $data['viewemail'], 'MASS_EMAIL' => $data['massemail'], diff --git a/phpBB/includes/acp/info/acp_jabber.php b/phpBB/includes/acp/info/acp_jabber.php deleted file mode 100644 index 660299a12d..0000000000 --- a/phpBB/includes/acp/info/acp_jabber.php +++ /dev/null @@ -1,34 +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. -* -*/ - -class acp_jabber_info -{ - function module() - { - return array( - 'filename' => 'acp_jabber', - 'title' => 'ACP_JABBER_SETTINGS', - 'modes' => array( - 'settings' => array('title' => 'ACP_JABBER_SETTINGS', 'auth' => 'acl_a_jabber', 'cat' => array('ACP_CLIENT_COMMUNICATION')), - ), - ); - } - - function install() - { - } - - function uninstall() - { - } -} diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index e46091c954..4bdaa12796 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -586,31 +586,3 @@ $lang = array_merge($lang, [ 'WEBPUSH_DROPDOWN_SUBSCRIBE' => 'Show “Subscribe” button in notification dropdown', 'WEBPUSH_DROPDOWN_SUBSCRIBE_EXPLAIN' => 'Display a “Subscribe” button in the Notification dropdown, allowing users to easily subscribe to push notifications from anywhere in the forum.', ]); - -// Jabber settings -$lang = array_merge($lang, array( - 'ACP_JABBER_SETTINGS_EXPLAIN' => 'Here you can enable and control the use of Jabber for instant messaging and board notifications. Jabber is an open source protocol and therefore available for use by anyone. Some Jabber servers include gateways or transports which allow you to contact users on other networks. Not all servers offer all transports and changes in protocols can prevent transports from operating. Please be sure to enter already registered account details - phpBB will use the details you enter here as is.', - - 'JAB_ALLOW_SELF_SIGNED' => 'Allow self-signed SSL certificates', - 'JAB_ALLOW_SELF_SIGNED_EXPLAIN' => 'Allow connections to Jabber server with self-signed SSL certificate.
Warning: Allowing self-signed SSL certificates may cause security implications.', - 'JAB_ENABLE' => 'Enable Jabber', - 'JAB_ENABLE_EXPLAIN' => 'Enables use of Jabber messaging and notifications.', - 'JAB_GTALK_NOTE' => 'Please note that GTalk will not work because the dns_get_record function could not be found. This function is not available in PHP4, and is not implemented on Windows platforms. It currently does not work on BSD-based systems, including Mac OS.', - 'JAB_PACKAGE_SIZE' => 'Jabber package size', - 'JAB_PACKAGE_SIZE_EXPLAIN' => 'This is the number of messages sent in one package. If set to 0 the message is sent immediately and will not be queued for later sending.', - 'JAB_PASSWORD' => 'Jabber password', - 'JAB_PASSWORD_EXPLAIN' => 'Warning: This password will be stored as plain text in the database, visible to everybody who can access your database or who can view this configuration page.', - 'JAB_PORT' => 'Jabber port', - 'JAB_PORT_EXPLAIN' => 'Leave blank unless you know it is not port 5222.', - 'JAB_SERVER' => 'Jabber server', - 'JAB_SERVER_EXPLAIN' => 'See %sjabber.org%s for a list of servers.', - 'JAB_SETTINGS_CHANGED' => 'Jabber settings changed successfully.', - 'JAB_USE_SSL' => 'Use SSL to connect', - 'JAB_USE_SSL_EXPLAIN' => 'If enabled a secure connection is tried to be established. The Jabber port will be modified to 5223 if port 5222 is specified.', - 'JAB_USERNAME' => 'Jabber username or JID', - 'JAB_USERNAME_EXPLAIN' => 'Specify a registered username or a valid JID. The username will not be checked for validity. If you only specify a username, then your JID will be the username and the server you specified above. Else, specify a valid JID, for example user@jabber.org.', - 'JAB_VERIFY_PEER' => 'Verify SSL certificate', - 'JAB_VERIFY_PEER_EXPLAIN' => 'Require verification of SSL certificate used by Jabber server.
Warning: Connecting peers with unverified SSL certificates may cause security implications.', - 'JAB_VERIFY_PEER_NAME' => 'Verify Jabber peer name', - 'JAB_VERIFY_PEER_NAME_EXPLAIN' => 'Require verification of peer name for Jabber servers using SSL / TLS connections.
Warning: Connecting to unverified peers may cause security implications.', -)); diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 62c08f0226..e2bbef019e 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -120,8 +120,6 @@ $lang = array_merge($lang, array( 'ACP_INACTIVE_USERS' => 'Inactive users', 'ACP_INDEX' => 'ACP index', - 'ACP_JABBER_SETTINGS' => 'Jabber settings', - 'ACP_LANGUAGE' => 'Language management', 'ACP_LANGUAGE_PACKS' => 'Language packs', 'ACP_LOAD_SETTINGS' => 'Load settings', @@ -642,7 +640,6 @@ $lang = array_merge($lang, array( 'LOG_DOWNLOAD_IP' => 'Added IP/hostname to download list
» %s', 'LOG_DOWNLOAD_REMOVE_IP' => 'Removed IP/hostname from download list
» %s', - 'LOG_ERROR_JABBER' => 'Jabber error
» %s', 'LOG_ERROR_EMAIL' => 'Email error
» %s', 'LOG_ERROR_CAPTCHA' => 'CAPTCHA error
» %s', @@ -686,11 +683,6 @@ $lang = array_merge($lang, array( 'LOG_IP_BROWSER_FORWARDED_CHECK' => 'Session IP/browser/X_FORWARDED_FOR check failed
»User IP “%1$s” checked against session IP “%2$s”, user browser string “%3$s” checked against session browser string “%4$s” and user X_FORWARDED_FOR string “%5$s” checked against session X_FORWARDED_FOR string “%6$s”.', - 'LOG_JAB_CHANGED' => 'Jabber account changed', - 'LOG_JAB_PASSCHG' => 'Jabber password changed', - 'LOG_JAB_REGISTER' => 'Jabber account registered', - 'LOG_JAB_SETTINGS_CHANGED' => 'Jabber settings changed', - 'LOG_LANGUAGE_PACK_DELETED' => 'Deleted language pack
» %s', 'LOG_LANGUAGE_PACK_INSTALLED' => 'Installed language pack
» %s', 'LOG_LANGUAGE_PACK_UPDATED' => 'Updated language pack details
» %s', diff --git a/phpBB/language/en/acp/permissions_phpbb.php b/phpBB/language/en/acp/permissions_phpbb.php index 590ccaaf9f..516e811768 100644 --- a/phpBB/language/en/acp/permissions_phpbb.php +++ b/phpBB/language/en/acp/permissions_phpbb.php @@ -168,7 +168,6 @@ $lang = array_merge($lang, array( $lang = array_merge($lang, array( 'ACL_A_BOARD' => 'Can alter board settings/check for updates', 'ACL_A_SERVER' => 'Can alter server/communication settings', - 'ACL_A_JABBER' => 'Can alter Jabber settings', 'ACL_A_PHPINFO' => 'Can view php settings', 'ACL_A_FORUM' => 'Can manage forums', From e32ebda982756be1c228b363398e9cdba78df966 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 13 Apr 2025 16:17:25 +0200 Subject: [PATCH 06/23] [ticket/17493] Remove memberlist IM page PHPBB-17493 --- phpBB/memberlist.php | 118 +----------------- .../prosilver/template/memberlist_im.html | 46 ------- 2 files changed, 2 insertions(+), 162 deletions(-) delete mode 100644 phpBB/styles/prosilver/template/memberlist_im.html diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 7b502e91c8..c031b01788 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -373,120 +373,6 @@ switch ($mode) ); break; - case 'contact': - - $page_title = $user->lang['IM_USER']; - $template_html = 'memberlist_im.html'; - - if (!$auth->acl_get('u_sendim')) - { - send_status_line(403, 'Forbidden'); - trigger_error('NOT_AUTHORISED'); - } - - $presence_img = ''; - switch ($action) - { - case 'jabber': - $lang = 'JABBER'; - $sql_field = 'user_jabber'; - $s_select = (@extension_loaded('xml') && $config['jab_enable']) ? 'S_SEND_JABBER' : 'S_NO_SEND_JABBER'; - $s_action = append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=$action&u=$user_id"); - break; - - default: - trigger_error('NO_MODE', E_USER_ERROR); - break; - } - - // Grab relevant data - $sql = "SELECT user_id, username, user_email, user_lang, $sql_field - FROM " . USERS_TABLE . " - WHERE user_id = $user_id - AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')'; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error('NO_USER'); - } - else if (empty($row[$sql_field])) - { - trigger_error('IM_NO_DATA'); - } - - // Post data grab actions - switch ($action) - { - case 'jabber': - add_form_key('memberlist_messaging'); - - if ($submit && @extension_loaded('xml') && $config['jab_enable']) - { - if (check_form_key('memberlist_messaging')) - { - - $subject = sprintf($user->lang['IM_JABBER_SUBJECT'], $user->data['username'], $config['server_name']); - $message = $request->variable('message', '', true); - - if (empty($message)) - { - trigger_error('EMPTY_MESSAGE_IM'); - } - - $jabber = $phpbb_container->get('messenger.method.jabber'); - $jabber->set_use_queue(false); - - $jabber->template('profile_send_im', $row['user_lang']); - $jabber->subject(html_entity_decode($subject, ENT_COMPAT)); - $jabber->set_addresses($row); - - $jabber->assign_vars([ - 'BOARD_CONTACT' => phpbb_get_board_contact($config, $phpEx), - 'FROM_USERNAME' => html_entity_decode($user->data['username'], ENT_COMPAT), - 'TO_USERNAME' => html_entity_decode($row['username'], ENT_COMPAT), - 'MESSAGE' => html_entity_decode($message, ENT_COMPAT), - ]); - - $jabber->send(); - - $s_select = 'S_SENT_JABBER'; - } - else - { - trigger_error('FORM_INVALID'); - } - } - break; - } - - $template->assign_block_vars('navlinks', array( - 'BREADCRUMB_NAME' => $page_title, - 'U_BREADCRUMB' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=$action&u=$user_id"), - )); - - // Send vars to the template - $template->assign_vars(array( - 'IM_CONTACT' => $row[$sql_field], - 'A_IM_CONTACT' => addslashes($row[$sql_field]), - - 'USERNAME' => $row['username'], - 'CONTACT_NAME' => $row[$sql_field], - 'SITENAME' => $config['sitename'], - - 'PRESENCE_IMG' => $presence_img, - - 'L_SEND_IM_EXPLAIN' => $user->lang['IM_' . $lang], - 'L_IM_SENT_JABBER' => sprintf($user->lang['IM_SENT_JABBER'], $row['username']), - - $s_select => true, - 'S_IM_ACTION' => $s_action) - ); - - break; - case 'viewprofile': // Display a profile if ($user_id == ANONYMOUS && !$username) @@ -950,8 +836,8 @@ switch ($mode) { // Generate the navlinks based on the selected topic $navlinks_sql_array = [ - 'SELECT' => 'f.parent_id, f.forum_parents, f.left_id, f.right_id, f.forum_type, f.forum_name, - f.forum_id, f.forum_desc, f.forum_desc_uid, f.forum_desc_bitfield, f.forum_desc_options, + 'SELECT' => 'f.parent_id, f.forum_parents, f.left_id, f.right_id, f.forum_type, f.forum_name, + f.forum_id, f.forum_desc, f.forum_desc_uid, f.forum_desc_bitfield, f.forum_desc_options, f.forum_options, t.topic_title', 'FROM' => [ FORUMS_TABLE => 'f', diff --git a/phpBB/styles/prosilver/template/memberlist_im.html b/phpBB/styles/prosilver/template/memberlist_im.html deleted file mode 100644 index f91454aacb..0000000000 --- a/phpBB/styles/prosilver/template/memberlist_im.html +++ /dev/null @@ -1,46 +0,0 @@ - - -

{L_SEND_IM}

- -
- -
-
- -

{L_SEND_IM_EXPLAIN}

- - -

{L_IM_SENT_JABBER}

- - -
-
-
-
{USERNAME} [ {IM_CONTACT} ] {PRESENCE_IMG}
-
- - -
-
-
-
-
-
 
-
-
- -
-
 
-
{L_IM_NO_JABBER}
-
- - {S_FORM_TOKEN} -
- -
-
-
- -{L_CLOSE_WINDOW} - - From a7c7c38bfbfed5b069480c819218359eb1355d14 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 13 Apr 2025 20:48:15 +0200 Subject: [PATCH 07/23] [ticket/17493] Remove settings, values, and lang vars for jabber PHPBB-17493 --- phpBB/includes/functions_display.php | 5 ---- phpBB/includes/functions_user.php | 2 +- phpBB/includes/mcp/mcp_reports.php | 2 +- phpBB/includes/ucp/ucp_pm_viewmessage.php | 13 +--------- phpBB/includes/ucp/ucp_prefs.php | 7 ------ phpBB/includes/ucp/ucp_profile.php | 24 +++---------------- phpBB/includes/ucp/ucp_resend.php | 2 +- phpBB/install/convertors/convert_phpbb20.php | 1 - phpBB/install/schemas/schema_data.sql | 3 +-- phpBB/language/en/common.php | 6 ----- phpBB/language/en/memberlist.php | 5 ---- phpBB/language/en/ucp.php | 3 --- .../db/migration/data/v400/remove_jabber.php | 1 + phpBB/phpbb/permissions.php | 1 - phpBB/phpbb/ucp/controller/reset_password.php | 4 ++-- .../prosilver/template/memberlist_search.html | 6 ----- .../prosilver/template/memberlist_view.html | 1 - .../template/ucp_prefs_personal.html | 10 -------- .../template/ucp_profile_profile_info.html | 6 ----- phpBB/viewtopic.php | 9 ------- tests/auth/provider_apache_test.php | 1 - 21 files changed, 11 insertions(+), 101 deletions(-) diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index e8f49f0329..860bb8d89a 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1681,7 +1681,6 @@ function phpbb_show_profile($data, $user_notes_enabled = false, $warn_user_enabl 'S_ONLINE' => ($config['load_onlinetrack'] && $online) ? true : false, 'RANK_IMG' => $user_rank_data['img'], 'RANK_IMG_SRC' => $user_rank_data['img_src'], - 'S_JABBER_ENABLED' => ($config['jab_enable']) ? true : false, 'S_WARNINGS' => ($auth->acl_getf_global('m_') || $auth->acl_get('m_warn')) ? true : false, @@ -1690,10 +1689,6 @@ function phpbb_show_profile($data, $user_notes_enabled = false, $warn_user_enabl 'U_WARN' => ($warn_user_enabled && $auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $user_id) : '', 'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && $can_receive_pm) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $user_id) : '', 'U_EMAIL' => $email, - 'U_JABBER' => ($data['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=jabber&u=' . $user_id) : '', - - 'USER_JABBER' => ($config['jab_enable'] && $auth->acl_get('u_sendim')) ? $data['user_jabber'] : '', - 'USER_JABBER_IMG' => ($config['jab_enable'] && $auth->acl_get('u_sendim') && $data['user_jabber']) ? $user->img('icon_contact_jabber', $data['user_jabber']) : '', 'L_SEND_EMAIL_USER' => $user->lang('SEND_EMAIL_USER', $username), 'L_CONTACT_USER' => $user->lang('CONTACT_USER', $username), diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index e495198a68..563564cf67 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2730,7 +2730,7 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna case 'approve': // Make sure we only approve those which are pending ;) - $sql = 'SELECT u.user_id, u.user_email, u.username, u.username_clean, u.user_notify_type, u.user_jabber, u.user_lang + $sql = 'SELECT u.user_id, u.user_email, u.username, u.username_clean, u.user_notify_type, u.user_lang FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . ' ug WHERE ug.group_id = ' . $group_id . ' AND ug.user_pending = 1 diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index 7843bc1efe..3325fd6b8d 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -661,7 +661,7 @@ function close_report($report_id_list, $mode, $action, $pm = false) { $post_info = ($pm) ? phpbb_get_pm_data($post_id_list) : phpbb_get_post_data($post_id_list, 'm_report'); - $sql = "SELECT r.report_id, r.$id_column, r.report_closed, r.user_id, r.user_notify, u.username, u.username_clean, u.user_email, u.user_jabber, u.user_lang, u.user_notify_type + $sql = "SELECT r.report_id, r.$id_column, r.report_closed, r.user_id, r.user_notify, u.username, u.username_clean, u.user_email, u.user_lang, u.user_notify_type FROM " . REPORTS_TABLE . ' r, ' . USERS_TABLE . ' u WHERE ' . $db->sql_in_set('r.report_id', $report_id_list) . ' ' . (($action == 'close') ? 'AND r.report_closed = 0' : '') . ' diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index 060a9941b3..d418e49887 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -201,18 +201,13 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) } } - $u_pm = $u_jabber = ''; + $u_pm = ''; if ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($user_info['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) { $u_pm = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $author_id); } - if ($config['jab_enable'] && $user_info['user_jabber'] && $auth->acl_get('u_sendim')) - { - $u_jabber = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=jabber&u=' . $author_id); - } - $can_edit_pm = ($message_row['message_time'] > time() - ($config['pm_edit_time'] * 60) || !$config['pm_edit_time']) && $folder_id == PRIVMSGS_OUTBOX && $auth->acl_get('u_pm_edit'); $msg_data = array( @@ -248,7 +243,6 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) 'MESSAGE_ID' => $message_row['msg_id'], 'U_PM' => $u_pm, - 'U_JABBER' => $u_jabber, 'U_DELETE' => ($auth->acl_get('u_pm_delete')) ? "$url&mode=compose&action=delete&f=$folder_id&p=" . $message_row['msg_id'] : '', 'U_EMAIL' => $user_info['email'], @@ -358,11 +352,6 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) 'NAME' => $user->lang['SEND_EMAIL'], 'U_CONTACT' => $user_info['email'], ), - array( - 'ID' => 'jabber', - 'NAME' => $user->lang['JABBER'], - 'U_CONTACT' => $u_jabber, - ), ); foreach ($contact_fields as $field) diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php index d08a81b854..480b4a3d12 100644 --- a/phpBB/includes/ucp/ucp_prefs.php +++ b/phpBB/includes/ucp/ucp_prefs.php @@ -54,12 +54,6 @@ class ucp_prefs 'allowpm' => $request->variable('allowpm', (bool) $user->data['user_allow_pm']), ); - if ($data['notifymethod'] == messenger_interface::NOTIFY_IM && (!$config['jab_enable'] || !$user->data['user_jabber'] || !@extension_loaded('xml'))) - { - // Jabber isnt enabled, or no jabber field filled in. Update the users table to be sure its correct. - $data['notifymethod'] = messenger_interface::NOTIFY_BOTH; - } - /** * Add UCP edit global settings data before they are assigned to the template or submitted * @@ -218,7 +212,6 @@ class ucp_prefs 'options' => $timezone_select, ], 'S_CAN_HIDE_ONLINE' => (bool) $auth->acl_get('u_hideonline'), - 'S_SELECT_NOTIFY' => (bool) ($config['jab_enable'] && $user->data['user_jabber'] && @extension_loaded('xml')), ]); break; diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index 52b007a1fe..77c1a56e9d 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -284,9 +284,7 @@ class ucp_profile $cp_data = $cp_error = array(); - $data = array( - 'jabber' => $request->variable('jabber', $user->data['user_jabber'], true), - ); + $data = []; if ($config['allow_birthdays']) { @@ -318,11 +316,7 @@ class ucp_profile if ($submit) { - $validate_array = array( - 'jabber' => array( - array('string', true, 5, 255), - array('jabber')), - ); + $validate_array = []; if ($config['allow_birthdays']) { @@ -363,18 +357,8 @@ class ucp_profile if (!count($error)) { - $data['notify'] = $user->data['user_notify_type']; - - if ($data['notify'] == messenger_interface::NOTIFY_IM && (!$config['jab_enable'] || !$data['jabber'] || !@extension_loaded('xml'))) - { - // User has not filled in a jabber address (Or one of the modules is disabled or jabber is disabled) - // Disable notify by Jabber now for this user. - $data['notify'] = messenger_interface::NOTIFY_EMAIL; - } - $sql_ary = array( - 'user_jabber' => $data['jabber'], - 'user_notify_type' => $data['notify'], + 'user_notify_type' => messenger_interface::NOTIFY_EMAIL, ); if ($config['allow_birthdays']) @@ -446,8 +430,6 @@ class ucp_profile $template->assign_vars(array( 'ERROR' => (count($error)) ? implode('
', $error) : '', - 'S_JABBER_ENABLED' => $config['jab_enable'], - 'JABBER' => $data['jabber'], )); // Get additional profile fields and assign them to the template block var 'profile_fields' diff --git a/phpBB/includes/ucp/ucp_resend.php b/phpBB/includes/ucp/ucp_resend.php index 43e26567e5..d3512865db 100644 --- a/phpBB/includes/ucp/ucp_resend.php +++ b/phpBB/includes/ucp/ucp_resend.php @@ -128,7 +128,7 @@ class ucp_resend // Grab an array of user_id's with a_user permissions ... these users can activate a user $admin_ary = $auth->acl_get_list(false, 'a_user', false); - $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type + $sql = 'SELECT user_id, username, user_email, user_lang, user_notify_type FROM ' . USERS_TABLE . ' WHERE ' . $db->sql_in_set('user_id', $admin_ary[0]['a_user']); $result = $db->sql_query($sql); diff --git a/phpBB/install/convertors/convert_phpbb20.php b/phpBB/install/convertors/convert_phpbb20.php index 8750c24dcc..cff03b712e 100644 --- a/phpBB/install/convertors/convert_phpbb20.php +++ b/phpBB/install/convertors/convert_phpbb20.php @@ -923,7 +923,6 @@ if (!$get_info) array('user_inactive_reason', '', 'phpbb_inactive_reason'), array('user_inactive_time', '', 'phpbb_inactive_time'), - array('user_jabber', '', ''), array('user_rank', 'users.user_rank', 'intval'), array('user_permissions', '', ''), diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index ad9d5e3e5a..fdae577190 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -429,7 +429,6 @@ INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_group', 1); INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_groupadd', 1); INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_groupdel', 1); INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_icons', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_jabber', 1); INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_language', 1); INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_mauth', 1); INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_modules', 1); @@ -559,7 +558,7 @@ INSERT INTO phpbb_ranks (rank_title, rank_min, rank_special, rank_image) VALUES # -- Roles data # Standard Admin (a_) -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 1, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'a_%' AND auth_option NOT IN ('a_switchperm', 'a_jabber', 'a_phpinfo', 'a_server', 'a_backup', 'a_styles', 'a_clearlogs', 'a_modules', 'a_language', 'a_email', 'a_bots', 'a_search', 'a_aauth', 'a_roles'); +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 1, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'a_%' AND auth_option NOT IN ('a_switchperm', 'a_phpinfo', 'a_server', 'a_backup', 'a_styles', 'a_clearlogs', 'a_modules', 'a_language', 'a_email', 'a_bots', 'a_search', 'a_aauth', 'a_roles'); # Forum admin (a_) INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 2, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'a_%' AND auth_option IN ('a_', 'a_authgroups', 'a_authusers', 'a_fauth', 'a_forum', 'a_forumadd', 'a_forumdel', 'a_mauth', 'a_prune', 'a_uauth', 'a_viewauth', 'a_viewlogs'); diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 7b6623e19a..e9225c6274 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -232,8 +232,6 @@ $lang = array_merge($lang, array( 'ENTER_USERNAME' => 'Enter username', 'ERR_CHANGING_DIRECTORY' => 'Unable to change directory.', 'ERR_CONNECTING_SERVER' => 'Error connecting to the server.', - 'ERR_JAB_AUTH' => 'Could not authorise on Jabber server.', - 'ERR_JAB_CONNECT' => 'Could not connect to Jabber server.', 'ERR_UNABLE_TO_LOGIN' => 'The specified username or password is incorrect.', 'ERR_UNWATCHING' => 'An error occurred while trying to unsubscribe.', 'ERR_WATCHING' => 'An error occurred while trying to subscribe.', @@ -372,7 +370,6 @@ $lang = array_merge($lang, array( 'IP' => 'IP', 'IP_BLACKLISTED' => 'Your IP %1$s has been blocked because it is blacklisted. For details please see %2$s.', - 'JABBER' => 'Jabber', 'JOINED' => 'Joined', 'JUMP_PAGE' => 'Enter the page number you wish to go to', 'JUMP_TO' => 'Jump to', @@ -801,7 +798,6 @@ $lang = array_merge($lang, array( 'TOO_LONG_CONFIRM_CODE' => 'The confirm code you entered is too long.', 'TOO_LONG_DATEFORMAT' => 'The date format you entered is too long.', - 'TOO_LONG_JABBER' => 'The Jabber account name you entered is too long.', 'TOO_LONG_NEW_PASSWORD' => 'The password you entered is too long.', 'TOO_LONG_PASSWORD_CONFIRM' => 'The password confirmation you entered is too long.', 'TOO_LONG_USER_PASSWORD' => 'The password you entered is too long.', @@ -814,7 +810,6 @@ $lang = array_merge($lang, array( 'TOO_SHORT_CONFIRM_CODE' => 'The confirm code you entered is too short.', 'TOO_SHORT_DATEFORMAT' => 'The date format you entered is too short.', - 'TOO_SHORT_JABBER' => 'The Jabber account name you entered is too short.', 'TOO_SHORT_NEW_PASSWORD' => 'The password you entered is too short.', 'TOO_SHORT_PASSWORD_CONFIRM' => 'The password confirmation you entered is too short.', 'TOO_SHORT_USER_PASSWORD' => 'The password you entered is too short.', @@ -943,7 +938,6 @@ $lang = array_merge($lang, array( 'WRONG_PASSWORD' => 'You entered an incorrect password.', 'WRONG_DATA_COLOUR' => 'The colour value you entered is invalid.', - 'WRONG_DATA_JABBER' => 'The name you entered is not a valid Jabber account name.', 'WRONG_DATA_LANG' => 'The language you specified is not valid.', 'WRONG_DATA_POST_SD' => 'The post sort direction you specified is not valid.', 'WRONG_DATA_POST_SK' => 'The post sort option you specified is not valid.', diff --git a/phpBB/language/en/memberlist.php b/phpBB/language/en/memberlist.php index 2e757043bb..09675d8095 100644 --- a/phpBB/language/en/memberlist.php +++ b/phpBB/language/en/memberlist.php @@ -78,16 +78,12 @@ $lang = array_merge($lang, array( 'IM_ADD_CONTACT' => 'Add Contact', 'IM_DOWNLOAD_APP' => 'Download application', - 'IM_JABBER' => 'Please note that users may have selected to not receive unsolicited instant messages.', - 'IM_JABBER_SUBJECT' => 'This is an automated message please do not reply! Message from user %1$s at %2$s.', 'IM_MESSAGE' => 'Your message', 'IM_NAME' => 'Your Name', 'IM_NO_DATA' => 'There is no suitable contact information for this user.', - 'IM_NO_JABBER' => 'Sorry, direct messaging of Jabber users is not supported on this board. You will need a Jabber client installed on your system to contact the recipient above.', 'IM_RECIPIENT' => 'Recipient', 'IM_SEND' => 'Send message', 'IM_SEND_MESSAGE' => 'Send message', - 'IM_SENT_JABBER' => 'Your message to %1$s has been sent successfully.', 'IM_USER' => 'Send an instant message', 'LAST_ACTIVE' => 'Last active', @@ -125,7 +121,6 @@ $lang = array_merge($lang, array( 'SENDER_NAME' => 'Your name', 'SEND_ICQ_MESSAGE' => 'Send ICQ message', 'SEND_IM' => 'Instant messaging', - 'SEND_JABBER_MESSAGE' => 'Send Jabber message', 'SEND_MESSAGE' => 'Message', 'SEND_YIM_MESSAGE' => 'Send YIM message', 'SORT_EMAIL' => 'Email', diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index 3d90f15742..bf5299e7aa 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -331,7 +331,6 @@ $lang = array_merge($lang, array( 'NOTIFICATION_GROUP_POSTING' => 'Posting Notifications', 'NOTIFICATION_METHOD_BOARD' => 'Notifications', 'NOTIFICATION_METHOD_EMAIL' => 'Email', - 'NOTIFICATION_METHOD_JABBER' => 'Jabber', 'NOTIFICATION_METHOD_WEBPUSH' => 'Web Push', 'NOTIFICATION_TYPE' => 'Notification type', 'NOTIFICATION_TYPE_BOOKMARK' => 'Someone replies to a topic you have bookmarked', @@ -354,7 +353,6 @@ $lang = array_merge($lang, array( 'NOTIFY_METHOD_BOTH' => 'Both', 'NOTIFY_METHOD_EMAIL' => 'Email only', 'NOTIFY_METHOD_EXPLAIN' => 'Method for sending messages sent via this board.', - 'NOTIFY_METHOD_IM' => 'Jabber only', 'NOTIFY_ON_PM' => 'Notify me on new private messages', 'NOTIFY_WEBPUSH_ENABLE' => 'Enable receiving Web Push notifications', 'NOTIFY_WEBPUSH_ENABLE_EXPLAIN' => 'Enable receiving browser-based push notifications.
The notifications can be turned off at any time in your browser settings, by unsubscribing, or by disabling the push notifications below.', @@ -534,7 +532,6 @@ $lang = array_merge($lang, array( 'UCP_COPPA_BEFORE' => 'Before %s', 'UCP_COPPA_ON_AFTER' => 'On or after %s', 'UCP_EMAIL_ACTIVATE' => 'Please note that you will need to enter a valid email address before your account is activated. You will receive an email at the address you provide that contains an account activation link.', - 'UCP_JABBER' => 'Jabber address', 'UCP_LOGIN_LINK' => 'Set up an external account association', 'UCP_MAIN' => 'Overview', diff --git a/phpBB/phpbb/db/migration/data/v400/remove_jabber.php b/phpBB/phpbb/db/migration/data/v400/remove_jabber.php index 1669e7e0c1..2a6ed89c21 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\v31x\add_jabber_ssl_context_config_options', '\phpbb\db\migration\data\v400\dev', '\phpbb\db\migration\data\v400\add_webpush', ]; diff --git a/phpBB/phpbb/permissions.php b/phpBB/phpbb/permissions.php index 79102f96a8..afbd710971 100644 --- a/phpBB/phpbb/permissions.php +++ b/phpBB/phpbb/permissions.php @@ -317,7 +317,6 @@ class permissions // Admin Permissions 'a_board' => array('lang' => 'ACL_A_BOARD', 'cat' => 'settings'), 'a_server' => array('lang' => 'ACL_A_SERVER', 'cat' => 'settings'), - 'a_jabber' => array('lang' => 'ACL_A_JABBER', 'cat' => 'settings'), 'a_phpinfo' => array('lang' => 'ACL_A_PHPINFO', 'cat' => 'settings'), 'a_forum' => array('lang' => 'ACL_A_FORUM', 'cat' => 'forums'), diff --git a/phpBB/phpbb/ucp/controller/reset_password.php b/phpBB/phpbb/ucp/controller/reset_password.php index 95a2a82b12..d9ec05316c 100644 --- a/phpBB/phpbb/ucp/controller/reset_password.php +++ b/phpBB/phpbb/ucp/controller/reset_password.php @@ -176,7 +176,7 @@ class reset_password } $sql_array = [ - 'SELECT' => 'user_id, username, user_permissions, user_email, user_jabber, user_notify_type, user_type,' + 'SELECT' => 'user_id, username, user_permissions, user_email, user_notify_type, user_type,' . ' user_lang, user_inactive_reason, reset_token, reset_token_expiration', 'FROM' => [$this->users_table => 'u'], 'WHERE' => "user_email = '" . $this->db->sql_escape($email) . "'" . @@ -308,7 +308,7 @@ class reset_password add_form_key('ucp_reset_password'); $sql_array = [ - 'SELECT' => 'user_id, username, user_permissions, user_email, user_jabber, user_notify_type, user_type,' + 'SELECT' => 'user_id, username, user_permissions, user_email, user_notify_type, user_type,' . ' user_lang, user_inactive_reason, reset_token, reset_token_expiration', 'FROM' => [$this->users_table => 'u'], 'WHERE' => 'user_id = ' . $user_id, diff --git a/phpBB/styles/prosilver/template/memberlist_search.html b/phpBB/styles/prosilver/template/memberlist_search.html index 3d9e0dec2b..a5644cc0c0 100644 --- a/phpBB/styles/prosilver/template/memberlist_search.html +++ b/phpBB/styles/prosilver/template/memberlist_search.html @@ -29,12 +29,6 @@
- - -
-
-
-
diff --git a/phpBB/styles/prosilver/template/memberlist_view.html b/phpBB/styles/prosilver/template/memberlist_view.html index 2a69cb08be..2a6d13847a 100644 --- a/phpBB/styles/prosilver/template/memberlist_view.html +++ b/phpBB/styles/prosilver/template/memberlist_view.html @@ -75,7 +75,6 @@
{L_EMAIL_ADDRESS}{L_COLON}
{L_SEND_EMAIL_USER}
{L_PM}{L_COLON}
{L_SEND_PRIVATE_MESSAGE}
-
{L_JABBER}{L_COLON}
{L_SEND_JABBER_MESSAGE}
{L_JABBER}{L_COLON}
{USER_JABBER}
diff --git a/phpBB/styles/prosilver/template/ucp_prefs_personal.html b/phpBB/styles/prosilver/template/ucp_prefs_personal.html index fe1ea17c74..82d2274c2f 100644 --- a/phpBB/styles/prosilver/template/ucp_prefs_personal.html +++ b/phpBB/styles/prosilver/template/ucp_prefs_personal.html @@ -40,16 +40,6 @@
- -
-
-
- - - -
-
-
diff --git a/phpBB/styles/prosilver/template/ucp_profile_profile_info.html b/phpBB/styles/prosilver/template/ucp_profile_profile_info.html index 0f0acc6f99..0dd54ee85f 100644 --- a/phpBB/styles/prosilver/template/ucp_profile_profile_info.html +++ b/phpBB/styles/prosilver/template/ucp_profile_profile_info.html @@ -21,12 +21,6 @@
- -
-
-
-
-
for="{profile_fields.FIELD_ID}">{profile_fields.LANG_NAME}{L_COLON} * diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 152e7ee52f..3181204292 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -802,7 +802,6 @@ $template->assign_vars(array( 'SEARCH_IMG' => $user->img('icon_user_search', 'SEARCH_USER_POSTS'), 'PM_IMG' => $user->img('icon_contact_pm', 'SEND_PRIVATE_MESSAGE'), 'EMAIL_IMG' => $user->img('icon_contact_email', 'SEND_EMAIL'), - 'JABBER_IMG' => $user->img('icon_contact_jabber', 'JABBER') , 'REPORT_IMG' => $user->img('icon_post_report', 'REPORT_POST'), 'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'), @@ -1423,7 +1422,6 @@ while ($row = $db->sql_fetchrow($result)) 'rank_image_src' => '', 'pm' => '', 'email' => '', - 'jabber' => '', 'search' => '', 'age' => '', @@ -1493,7 +1491,6 @@ while ($row = $db->sql_fetchrow($result)) 'contact_user' => $user->lang('CONTACT_USER', get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['username'])), 'online' => false, - 'jabber' => ($config['jab_enable'] && $row['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=jabber&u=$poster_id") : '', 'search' => ($config['load_search'] && $auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$poster_id&sr=posts") : '', 'author_full' => get_username_string('full', $poster_id, $row['username'], $row['user_colour']), @@ -2068,7 +2065,6 @@ for ($i = 0, $end = count($post_list); $i < $end; ++$i) 'U_SEARCH' => $user_cache[$poster_id]['search'], 'U_PM' => $u_pm, 'U_EMAIL' => $user_cache[$poster_id]['email'], - 'U_JABBER' => $user_cache[$poster_id]['jabber'], 'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&p={$row['post_id']}&f={$row['forum_id']}&redirect=" . urlencode(str_replace('&', '&', $viewtopic_url . '&p=' . $row['post_id'] . '#p' . $row['post_id']))), 'U_REPORT' => ($auth->acl_get('f_report', $forum_id)) ? $phpbb_container->get('controller.helper')->route('phpbb_report_post_controller', array('id' => $row['post_id'])) : '', @@ -2179,11 +2175,6 @@ for ($i = 0, $end = count($post_list); $i < $end; ++$i) 'NAME' => $user->lang['SEND_EMAIL'], 'U_CONTACT' => $user_cache[$poster_id]['email'], ), - array( - 'ID' => 'jabber', - 'NAME' => $user->lang['JABBER'], - 'U_CONTACT' => $user_cache[$poster_id]['jabber'], - ), ); foreach ($contact_fields as $field) diff --git a/tests/auth/provider_apache_test.php b/tests/auth/provider_apache_test.php index bc211b4ed5..3604bbf9cd 100644 --- a/tests/auth/provider_apache_test.php +++ b/tests/auth/provider_apache_test.php @@ -165,7 +165,6 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case 'user_sig' => '', 'user_sig_bbcode_uid' => '', 'user_sig_bbcode_bitfield' => '', - 'user_jabber' => '', 'user_actkey' => '', 'user_actkey_expiration' => 0, 'user_newpasswd' => '', From 3128b3fa9b3ceb7d05855bc6624d31aff71b6169 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 13 Apr 2025 21:00:19 +0200 Subject: [PATCH 08/23] [ticket/17493] Remove more jabber permissions and elements PHPBB-17493 --- phpBB/develop/add_permissions.php | 13 +- phpBB/includes/functions_user.php | 202 ------------------ phpBB/install/schemas/schema_data.sql | 9 +- phpBB/language/en/acp/permissions_phpbb.php | 1 - phpBB/memberlist.php | 10 - phpBB/phpbb/cron/task/core/queue.php | 2 +- .../db/migration/data/v400/remove_jabber.php | 2 + phpBB/phpbb/message/message.php | 26 +-- phpBB/phpbb/permissions.php | 1 - tests/functions/validate_jabber_test.php | 83 ------- 10 files changed, 26 insertions(+), 323 deletions(-) delete mode 100644 tests/functions/validate_jabber_test.php diff --git a/phpBB/develop/add_permissions.php b/phpBB/develop/add_permissions.php index 6b8913de8c..1531e67de6 100644 --- a/phpBB/develop/add_permissions.php +++ b/phpBB/develop/add_permissions.php @@ -140,7 +140,6 @@ $u_permissions = array( 'u_sendemail' => array(0, 1), 'u_readpm' => array(0, 1), 'u_sendpm' => array(0, 1), - 'u_sendim' => array(0, 1), 'u_hideonline' => array(0, 1), 'u_viewonline' => array(0, 1), 'u_viewprofile' => array(0, 1), @@ -247,7 +246,7 @@ function mass_auth($ug_type, $forum_id, $ug_id, $acl_list, $setting) { if (!isset($group_ids[$ug_id])) { - $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . " + $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . " WHERE group_name = '" . strtoupper($ug_id) . "'"; $result = $db->sql_query_limit($sql, 1); $id = (int) $db->sql_fetchfield('group_id', 0, $result); @@ -340,7 +339,7 @@ function mass_auth($ug_type, $forum_id, $ug_id, $acl_list, $setting) case ACL_NO: if (isset($cur_auth[$forum][$auth_option_id])) { - $sql_ary['delete'][] = "DELETE FROM $table + $sql_ary['delete'][] = "DELETE FROM $table WHERE forum_id = $forum AND auth_option_id = $auth_option_id AND $id_field = $ug_id"; @@ -354,10 +353,10 @@ function mass_auth($ug_type, $forum_id, $ug_id, $acl_list, $setting) } else if ($cur_auth[$forum][$auth_option_id] != $setting) { - $sql_ary['update'][] = "UPDATE " . $table . " - SET auth_setting = $setting - WHERE $id_field = $ug_id - AND forum_id = $forum + $sql_ary['update'][] = "UPDATE " . $table . " + SET auth_setting = $setting + WHERE $id_field = $ug_id + AND forum_id = $forum AND auth_option_id = $auth_option_id"; } } diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 563564cf67..42c9e7fd5a 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1514,208 +1514,6 @@ function validate_user_email($email, $allowed_email = false) return false; } -/** -* Validate jabber address -* Taken from the jabber class within flyspray (see author notes) -* -* @author flyspray.org -*/ -function validate_jabber($jid) -{ - if (!$jid) - { - return false; - } - - $separator_pos = strpos($jid, '@'); - - if ($separator_pos === false) - { - return 'WRONG_DATA'; - } - - $username = substr($jid, 0, $separator_pos); - $realm = substr($jid, $separator_pos + 1); - - if (strlen($username) == 0 || strlen($realm) < 3) - { - return 'WRONG_DATA'; - } - - $arr = explode('.', $realm); - - if (count($arr) == 0) - { - return 'WRONG_DATA'; - } - - foreach ($arr as $part) - { - if (substr($part, 0, 1) == '-' || substr($part, -1, 1) == '-') - { - return 'WRONG_DATA'; - } - - if (!preg_match("@^[a-zA-Z0-9-.]+$@", $part)) - { - return 'WRONG_DATA'; - } - } - - $boundary = array(array(0, 127), array(192, 223), array(224, 239), array(240, 247), array(248, 251), array(252, 253)); - - // Prohibited Characters RFC3454 + RFC3920 - $prohibited = array( - // Table C.1.1 - array(0x0020, 0x0020), // SPACE - // Table C.1.2 - array(0x00A0, 0x00A0), // NO-BREAK SPACE - array(0x1680, 0x1680), // OGHAM SPACE MARK - array(0x2000, 0x2001), // EN QUAD - array(0x2001, 0x2001), // EM QUAD - array(0x2002, 0x2002), // EN SPACE - array(0x2003, 0x2003), // EM SPACE - array(0x2004, 0x2004), // THREE-PER-EM SPACE - array(0x2005, 0x2005), // FOUR-PER-EM SPACE - array(0x2006, 0x2006), // SIX-PER-EM SPACE - array(0x2007, 0x2007), // FIGURE SPACE - array(0x2008, 0x2008), // PUNCTUATION SPACE - array(0x2009, 0x2009), // THIN SPACE - array(0x200A, 0x200A), // HAIR SPACE - array(0x200B, 0x200B), // ZERO WIDTH SPACE - array(0x202F, 0x202F), // NARROW NO-BREAK SPACE - array(0x205F, 0x205F), // MEDIUM MATHEMATICAL SPACE - array(0x3000, 0x3000), // IDEOGRAPHIC SPACE - // Table C.2.1 - array(0x0000, 0x001F), // [CONTROL CHARACTERS] - array(0x007F, 0x007F), // DELETE - // Table C.2.2 - array(0x0080, 0x009F), // [CONTROL CHARACTERS] - array(0x06DD, 0x06DD), // ARABIC END OF AYAH - array(0x070F, 0x070F), // SYRIAC ABBREVIATION MARK - array(0x180E, 0x180E), // MONGOLIAN VOWEL SEPARATOR - array(0x200C, 0x200C), // ZERO WIDTH NON-JOINER - array(0x200D, 0x200D), // ZERO WIDTH JOINER - array(0x2028, 0x2028), // LINE SEPARATOR - array(0x2029, 0x2029), // PARAGRAPH SEPARATOR - array(0x2060, 0x2060), // WORD JOINER - array(0x2061, 0x2061), // FUNCTION APPLICATION - array(0x2062, 0x2062), // INVISIBLE TIMES - array(0x2063, 0x2063), // INVISIBLE SEPARATOR - array(0x206A, 0x206F), // [CONTROL CHARACTERS] - array(0xFEFF, 0xFEFF), // ZERO WIDTH NO-BREAK SPACE - array(0xFFF9, 0xFFFC), // [CONTROL CHARACTERS] - array(0x1D173, 0x1D17A), // [MUSICAL CONTROL CHARACTERS] - // Table C.3 - array(0xE000, 0xF8FF), // [PRIVATE USE, PLANE 0] - array(0xF0000, 0xFFFFD), // [PRIVATE USE, PLANE 15] - array(0x100000, 0x10FFFD), // [PRIVATE USE, PLANE 16] - // Table C.4 - array(0xFDD0, 0xFDEF), // [NONCHARACTER CODE POINTS] - array(0xFFFE, 0xFFFF), // [NONCHARACTER CODE POINTS] - array(0x1FFFE, 0x1FFFF), // [NONCHARACTER CODE POINTS] - array(0x2FFFE, 0x2FFFF), // [NONCHARACTER CODE POINTS] - array(0x3FFFE, 0x3FFFF), // [NONCHARACTER CODE POINTS] - array(0x4FFFE, 0x4FFFF), // [NONCHARACTER CODE POINTS] - array(0x5FFFE, 0x5FFFF), // [NONCHARACTER CODE POINTS] - array(0x6FFFE, 0x6FFFF), // [NONCHARACTER CODE POINTS] - array(0x7FFFE, 0x7FFFF), // [NONCHARACTER CODE POINTS] - array(0x8FFFE, 0x8FFFF), // [NONCHARACTER CODE POINTS] - array(0x9FFFE, 0x9FFFF), // [NONCHARACTER CODE POINTS] - array(0xAFFFE, 0xAFFFF), // [NONCHARACTER CODE POINTS] - array(0xBFFFE, 0xBFFFF), // [NONCHARACTER CODE POINTS] - array(0xCFFFE, 0xCFFFF), // [NONCHARACTER CODE POINTS] - array(0xDFFFE, 0xDFFFF), // [NONCHARACTER CODE POINTS] - array(0xEFFFE, 0xEFFFF), // [NONCHARACTER CODE POINTS] - array(0xFFFFE, 0xFFFFF), // [NONCHARACTER CODE POINTS] - array(0x10FFFE, 0x10FFFF), // [NONCHARACTER CODE POINTS] - // Table C.5 - array(0xD800, 0xDFFF), // [SURROGATE CODES] - // Table C.6 - array(0xFFF9, 0xFFF9), // INTERLINEAR ANNOTATION ANCHOR - array(0xFFFA, 0xFFFA), // INTERLINEAR ANNOTATION SEPARATOR - array(0xFFFB, 0xFFFB), // INTERLINEAR ANNOTATION TERMINATOR - array(0xFFFC, 0xFFFC), // OBJECT REPLACEMENT CHARACTER - array(0xFFFD, 0xFFFD), // REPLACEMENT CHARACTER - // Table C.7 - array(0x2FF0, 0x2FFB), // [IDEOGRAPHIC DESCRIPTION CHARACTERS] - // Table C.8 - array(0x0340, 0x0340), // COMBINING GRAVE TONE MARK - array(0x0341, 0x0341), // COMBINING ACUTE TONE MARK - array(0x200E, 0x200E), // LEFT-TO-RIGHT MARK - array(0x200F, 0x200F), // RIGHT-TO-LEFT MARK - array(0x202A, 0x202A), // LEFT-TO-RIGHT EMBEDDING - array(0x202B, 0x202B), // RIGHT-TO-LEFT EMBEDDING - array(0x202C, 0x202C), // POP DIRECTIONAL FORMATTING - array(0x202D, 0x202D), // LEFT-TO-RIGHT OVERRIDE - array(0x202E, 0x202E), // RIGHT-TO-LEFT OVERRIDE - array(0x206A, 0x206A), // INHIBIT SYMMETRIC SWAPPING - array(0x206B, 0x206B), // ACTIVATE SYMMETRIC SWAPPING - array(0x206C, 0x206C), // INHIBIT ARABIC FORM SHAPING - array(0x206D, 0x206D), // ACTIVATE ARABIC FORM SHAPING - array(0x206E, 0x206E), // NATIONAL DIGIT SHAPES - array(0x206F, 0x206F), // NOMINAL DIGIT SHAPES - // Table C.9 - array(0xE0001, 0xE0001), // LANGUAGE TAG - array(0xE0020, 0xE007F), // [TAGGING CHARACTERS] - // RFC3920 - array(0x22, 0x22), // " - array(0x26, 0x26), // & - array(0x27, 0x27), // ' - array(0x2F, 0x2F), // / - array(0x3A, 0x3A), // : - array(0x3C, 0x3C), // < - array(0x3E, 0x3E), // > - array(0x40, 0x40) // @ - ); - - $pos = 0; - $result = true; - - while ($pos < strlen($username)) - { - $len = $uni = 0; - for ($i = 0; $i <= 5; $i++) - { - if (ord($username[$pos]) >= $boundary[$i][0] && ord($username[$pos]) <= $boundary[$i][1]) - { - $len = $i + 1; - $uni = (ord($username[$pos]) - $boundary[$i][0]) * pow(2, $i * 6); - - for ($k = 1; $k < $len; $k++) - { - $uni += (ord($username[$pos + $k]) - 128) * pow(2, ($i - $k) * 6); - } - - break; - } - } - - if ($len == 0) - { - return 'WRONG_DATA'; - } - - foreach ($prohibited as $pval) - { - if ($uni >= $pval[0] && $uni <= $pval[1]) - { - $result = false; - break 2; - } - } - - $pos = $pos + $len; - } - - if (!$result) - { - return 'WRONG_DATA'; - } - - return false; -} - /** * Validate hex colour value * diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index fdae577190..7f53a3adc4 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -482,7 +482,6 @@ INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_readpm', 1); INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_savedrafts', 1); INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_search', 1); INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_sendemail', 1); -INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_sendim', 1); INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_sendpm', 1); INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_sig', 1); INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_viewonline', 1); @@ -528,10 +527,10 @@ INSERT INTO phpbb_forums (forum_name, forum_desc, left_id, right_id, parent_id, INSERT INTO phpbb_forums (forum_name, forum_desc, left_id, right_id, parent_id, forum_type, forum_posts_approved, forum_posts_unapproved, forum_posts_softdeleted, forum_topics_approved, forum_topics_unapproved, forum_topics_softdeleted, forum_last_post_id, forum_last_poster_id, forum_last_poster_name, forum_last_poster_colour, forum_last_post_subject, forum_last_post_time, forum_link, forum_password, forum_image, forum_rules, forum_rules_link, forum_rules_uid, forum_desc_uid, prune_freq, prune_days, prune_viewed, forum_parents, forum_flags) VALUES ('{L_FORUMS_TEST_FORUM_TITLE}', '{L_FORUMS_TEST_FORUM_DESC}', 2, 3, 1, 1, 1, 0, 0, 1, 0, 0, 1, 2, 'Admin', 'AA0000', '{L_TOPICS_TOPIC_TITLE}', 972086460, '', '', '', '', '', '', '', 1, 7, 7, '', 48); # -- Users / Anonymous user -INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_jabber, user_actkey, user_actkey_expiration, user_newpasswd, user_allow_massemail) VALUES (2, 1, 'Anonymous', 'anonymous', 0, '', '', 'en', 1, 0, '', 0, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', 0, '', 0); +INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_actkey, user_actkey_expiration, user_newpasswd, user_allow_massemail) VALUES (2, 1, 'Anonymous', 'anonymous', 0, '', '', 'en', 1, 0, '', 0, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', 0, '', 0); # -- username: Admin password: admin (change this or remove it once everything is working!) -INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_jabber, user_actkey, user_actkey_expiration, user_newpasswd) VALUES (3, 5, 'Admin', 'admin', 0, '21232f297a57a5a743894a0e4a801fc3', 'admin@yourdomain.com', 'en', 1, 1, 'AA0000', 1, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', 0, ''); +INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_actkey, user_actkey_expiration, user_newpasswd) VALUES (3, 5, 'Admin', 'admin', 0, '21232f297a57a5a743894a0e4a801fc3', 'admin@yourdomain.com', 'en', 1, 1, 'AA0000', 1, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', 0, ''); # -- Groups INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('GUESTS', 3, 0, '', 0, '', '', '', 5); @@ -576,14 +575,14 @@ INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 6, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option NOT IN ('u_viewonline', 'u_chggrp', 'u_chgname', 'u_ignoreflood', 'u_pm_forward'); # Limited Features (u_) -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 7, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option NOT IN ('u_attach', 'u_viewonline', 'u_chggrp', 'u_chgname', 'u_ignoreflood', 'u_pm_attach', 'u_pm_emailpm', 'u_savedrafts', 'u_search', 'u_sendemail', 'u_sendim', 'u_masspm', 'u_masspm_group'); +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 7, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option NOT IN ('u_attach', 'u_viewonline', 'u_chggrp', 'u_chgname', 'u_ignoreflood', 'u_pm_attach', 'u_pm_emailpm', 'u_savedrafts', 'u_search', 'u_sendemail', 'u_masspm', 'u_masspm_group'); # No Private Messages (u_) INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 8, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_', 'u_chgavatar', 'u_chgcensors', 'u_chgemail', 'u_chgpasswd', 'u_download', 'u_hideonline', 'u_mention', 'u_sig', 'u_viewprofile'); INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 8, auth_option_id, 0 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_readpm', 'u_sendpm', 'u_masspm', 'u_masspm_group'); # No Avatar (u_) -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 9, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option NOT IN ('u_attach', 'u_chgavatar', 'u_viewonline', 'u_chggrp', 'u_chgname', 'u_ignoreflood', 'u_pm_attach', 'u_pm_emailpm', 'u_savedrafts', 'u_search', 'u_sendemail', 'u_sendim', 'u_masspm', 'u_masspm_group'); +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 9, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option NOT IN ('u_attach', 'u_chgavatar', 'u_viewonline', 'u_chggrp', 'u_chgname', 'u_ignoreflood', 'u_pm_attach', 'u_pm_emailpm', 'u_savedrafts', 'u_search', 'u_sendemail', 'u_masspm', 'u_masspm_group'); INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 9, auth_option_id, 0 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_chgavatar'); # Full Moderator (m_) diff --git a/phpBB/language/en/acp/permissions_phpbb.php b/phpBB/language/en/acp/permissions_phpbb.php index 516e811768..17361e1a3b 100644 --- a/phpBB/language/en/acp/permissions_phpbb.php +++ b/phpBB/language/en/acp/permissions_phpbb.php @@ -98,7 +98,6 @@ $lang = array_merge($lang, array( 'ACL_U_PM_IMG' => 'Can use [img] BBCode tag in private messages', 'ACL_U_SENDEMAIL' => 'Can send emails', - 'ACL_U_SENDIM' => 'Can send instant messages', 'ACL_U_IGNOREFLOOD' => 'Can ignore flood limit', 'ACL_U_HIDEONLINE' => 'Can hide online status', 'ACL_U_VIEWONLINE' => 'Can view hidden online users', diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index c031b01788..3164ad6a84 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -669,7 +669,6 @@ switch ($mode) 'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']), 'L_SEND_EMAIL_USER' => $user->lang('SEND_EMAIL_USER', $member['username']), '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']), 'S_PROFILE_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group'), @@ -923,12 +922,6 @@ switch ($mode) $sort_key_text = array('a' => $user->lang['SORT_USERNAME'], 'c' => $user->lang['SORT_JOINED'], 'd' => $user->lang['SORT_POST_COUNT']); $sort_key_sql = array('a' => 'u.username_clean', 'c' => 'u.user_regdate', 'd' => 'u.user_posts'); - if ($config['jab_enable'] && $auth->acl_get('u_sendim')) - { - $sort_key_text['k'] = $user->lang['JABBER']; - $sort_key_sql['k'] = 'u.user_jabber'; - } - if ($auth->acl_get('a_user')) { $sort_key_text['e'] = $user->lang['SORT_EMAIL']; @@ -979,7 +972,6 @@ switch ($mode) { $username = $request->variable('username', '', true); $email = strtolower($request->variable('email', '')); - $jabber = $request->variable('jabber', ''); $search_group_id = $request->variable('search_group_id', 0); // when using these, make sure that we actually have values defined in $find_key_match @@ -1019,7 +1011,6 @@ switch ($mode) $sql_where .= ($username) ? ' AND u.username_clean ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), utf8_clean_string($username))) : ''; $sql_where .= ($auth->acl_get('a_user') && $email) ? ' AND u.user_email ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), $email)) . ' ' : ''; - $sql_where .= ($jabber) ? ' AND u.user_jabber ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), $jabber)) . ' ' : ''; $sql_where .= (is_numeric($count) && isset($find_key_match[$count_select])) ? ' AND u.user_posts ' . $find_key_match[$count_select] . ' ' . (int) $count . ' ' : ''; if (isset($find_key_match[$joined_select]) && count($joined) == 3) @@ -1480,7 +1471,6 @@ switch ($mode) $template->assign_vars(array( 'USERNAME' => $username, 'EMAIL' => $email, - 'JABBER' => $jabber, 'JOINED' => implode('-', $joined), 'ACTIVE' => implode('-', $active), 'COUNT' => $count, diff --git a/phpBB/phpbb/cron/task/core/queue.php b/phpBB/phpbb/cron/task/core/queue.php index 9395a538de..7e902f5304 100644 --- a/phpBB/phpbb/cron/task/core/queue.php +++ b/phpBB/phpbb/cron/task/core/queue.php @@ -16,7 +16,7 @@ namespace phpbb\cron\task\core; use phpbb\config\config; /** -* Queue cron task. Sends email and jabber messages queued by other scripts. +* Queue cron task. Sends email queued by other scripts. */ class queue extends \phpbb\cron\task\base { diff --git a/phpBB/phpbb/db/migration/data/v400/remove_jabber.php b/phpBB/phpbb/db/migration/data/v400/remove_jabber.php index 2a6ed89c21..48d933d626 100644 --- a/phpBB/phpbb/db/migration/data/v400/remove_jabber.php +++ b/phpBB/phpbb/db/migration/data/v400/remove_jabber.php @@ -67,6 +67,7 @@ class remove_jabber extends migration 'ACP_JABBER_SETTINGS', ]], ['permission.remove', ['a_jabber']], + ['permission.remove', ['u_sendim']], ]; } @@ -94,6 +95,7 @@ class remove_jabber extends migration ], ]], ['permission.add', ['a_jabber', true]], + ['permission.add', ['u_sendim', true]], ]; } } diff --git a/phpBB/phpbb/message/message.php b/phpBB/phpbb/message/message.php index 900ef103c5..344c2f1cf2 100644 --- a/phpBB/phpbb/message/message.php +++ b/phpBB/phpbb/message/message.php @@ -26,27 +26,34 @@ class message /** @var string */ protected $subject = ''; + /** @var string */ protected $body = ''; + /** @var string */ protected $template = ''; + /** @var array */ protected $template_vars = array(); /** @var string */ protected $sender_ip = ''; + /** @var string */ protected $sender_name = ''; + /** @var string */ protected $sender_address = ''; + /** @var string */ protected $sender_lang = ''; + /** @var string|int */ protected $sender_id = ''; + /** @var string */ protected $sender_username = ''; - /** @var string */ - protected $sender_jabber = ''; + /** @var int */ protected $sender_notify_type = messenger_interface::NOTIFY_EMAIL; @@ -120,8 +127,7 @@ class message $user['user_email'], $user['user_lang'], $user['user_notify_type'], - $user['username'], - $user['user_jabber'] + $user['username'] ); } @@ -133,17 +139,15 @@ class message * @param string $recipient_lang * @param int $recipient_notify_type Used notification methods (Jabber, Email, ...) * @param string $recipient_username User Name (used for AntiAbuse header) - * @param string $recipient_jabber * @return void */ - public function add_recipient($recipient_name, $recipient_address, $recipient_lang, $recipient_notify_type = messenger_interface::NOTIFY_EMAIL, $recipient_username = '', $recipient_jabber = '') + public function add_recipient($recipient_name, $recipient_address, $recipient_lang, $recipient_notify_type = messenger_interface::NOTIFY_EMAIL, $recipient_username = '') { $this->recipients[] = array( 'name' => $recipient_name, 'user_email' => $recipient_address, 'lang' => $recipient_lang, 'username' => $recipient_username, - 'user_jabber' => $recipient_jabber, 'notify_type' => $recipient_notify_type, 'to_name' => $recipient_name, ); @@ -163,8 +167,7 @@ class message $user->data['user_email'], $user->lang_name, $user->data['user_id'], - $user->data['username'], - $user->data['user_jabber'] + $user->data['username'] ); $this->set_sender_notify_type($user->data['user_notify_type']); @@ -179,10 +182,9 @@ class message * @param string $sender_lang * @param int $sender_id User ID * @param string $sender_username User Name (used for AntiAbuse header) - * @param string $sender_jabber * @return void */ - public function set_sender($sender_ip, $sender_name, $sender_address, $sender_lang = '', $sender_id = 0, $sender_username = '', $sender_jabber = '') + public function set_sender($sender_ip, $sender_name, $sender_address, $sender_lang = '', $sender_id = 0, $sender_username = '') { $this->sender_ip = $sender_ip; $this->sender_name = $sender_name; @@ -190,7 +192,6 @@ class message $this->sender_lang = $sender_lang; $this->sender_id = $sender_id; $this->sender_username = $sender_username; - $this->sender_jabber = $sender_jabber; } /** @@ -225,7 +226,6 @@ class message 'user_email' => $this->sender_address, 'name' => $this->sender_name, 'username' => $this->sender_username, - 'user_jabber' => $this->sender_jabber, 'notify_type' => $this->sender_notify_type, 'to_name' => $this->recipients[0]['to_name'], ); diff --git a/phpBB/phpbb/permissions.php b/phpBB/phpbb/permissions.php index afbd710971..87fa05c5ff 100644 --- a/phpBB/phpbb/permissions.php +++ b/phpBB/phpbb/permissions.php @@ -253,7 +253,6 @@ class permissions 'u_pm_img' => array('lang' => 'ACL_U_PM_IMG', 'cat' => 'pm'), 'u_sendemail' => array('lang' => 'ACL_U_SENDEMAIL', 'cat' => 'misc'), - 'u_sendim' => array('lang' => 'ACL_U_SENDIM', 'cat' => 'misc'), 'u_ignoreflood' => array('lang' => 'ACL_U_IGNOREFLOOD', 'cat' => 'misc'), 'u_hideonline' => array('lang' => 'ACL_U_HIDEONLINE', 'cat' => 'misc'), 'u_viewonline' => array('lang' => 'ACL_U_VIEWONLINE', 'cat' => 'misc'), diff --git a/tests/functions/validate_jabber_test.php b/tests/functions/validate_jabber_test.php deleted file mode 100644 index 92cf5062d5..0000000000 --- a/tests/functions/validate_jabber_test.php +++ /dev/null @@ -1,83 +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. -* -*/ - -require_once __DIR__ . '/../../phpBB/includes/functions_user.php'; -require_once __DIR__ . '/validate_data_helper.php'; - -class phpbb_functions_validate_jabber_test extends phpbb_test_case -{ - protected $helper; - - protected function setUp(): void - { - parent::setUp(); - - $this->helper = new phpbb_functions_validate_data_helper($this); - } - - public function test_validate_jabber() - { - $this->helper->assert_valid_data(array( - 'empty' => array( - array(), - '', - array('jabber'), - ), - 'no_seperator' => array( - array('WRONG_DATA'), - 'testjabber.ccc', - array('jabber'), - ), - 'no_user' => array( - array('WRONG_DATA'), - '@jabber.ccc', - array('jabber'), - ), - 'no_realm' => array( - array('WRONG_DATA'), - 'user@', - array('jabber'), - ), - 'dot_realm' => array( - array('WRONG_DATA'), - 'user@.....', - array('jabber'), - ), - '-realm' => array( - array('WRONG_DATA'), - 'user@-jabber.ccc', - array('jabber'), - ), - 'realm-' => array( - array('WRONG_DATA'), - 'user@jabber.ccc-', - array('jabber'), - ), - 'correct' => array( - array(), - 'user@jabber.09A-z.org', - array('jabber'), - ), - 'prohibited' => array( - array('WRONG_DATA'), - 'u@ser@jabber.ccc.org', - array('jabber'), - ), - 'prohibited_char' => array( - array('WRONG_DATA'), - 'uer@jabber.ccc.org', - array('jabber'), - ), - )); - } -} From ef47c691554f0592dfb65dca2844ad251cb1fbc5 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 14 Apr 2025 20:27:03 +0200 Subject: [PATCH 09/23] [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/'); - } -} From 610fa67928a0ada7afbff728bddd1fc5b3fb7cae Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 14 Apr 2025 20:33:13 +0200 Subject: [PATCH 10/23] [ticket/17493] Remove jabber as messenger method PHPBB-17493 --- .../default/container/services_messenger.yml | 9 - phpBB/phpbb/message/user_form.php | 2 +- phpBB/phpbb/messenger/method/jabber.php | 1236 ----------------- tests/messenger/method_jabber_test.php | 311 ----- tests/messenger/queue_test.php | 17 - tests/notification/base.php | 1 - .../notification_method_email_test.php | 1 - tests/notification/submit_post_base.php | 1 - 8 files changed, 1 insertion(+), 1577 deletions(-) delete mode 100644 phpBB/phpbb/messenger/method/jabber.php delete mode 100644 tests/messenger/method_jabber_test.php diff --git a/phpBB/config/default/container/services_messenger.yml b/phpBB/config/default/container/services_messenger.yml index 8645d2f17c..14bdf18df2 100644 --- a/phpBB/config/default/container/services_messenger.yml +++ b/phpBB/config/default/container/services_messenger.yml @@ -38,15 +38,6 @@ services: tags: - { name: messenger.method } - messenger.method.jabber: - class: phpbb\messenger\method\jabber - shared: false - parent: messenger.method.base - calls: - - [init, []] - tags: - - { name: messenger.method } - messenger.queue: class: phpbb\messenger\queue shared: false diff --git a/phpBB/phpbb/message/user_form.php b/phpBB/phpbb/message/user_form.php index 46a012297d..f52eabc7e9 100644 --- a/phpBB/phpbb/message/user_form.php +++ b/phpBB/phpbb/message/user_form.php @@ -34,7 +34,7 @@ class user_form extends form */ protected function get_user_row($user_id) { - $sql = 'SELECT user_id, username, user_colour, user_email, user_allow_viewemail, user_lang, user_jabber, user_notify_type + $sql = 'SELECT user_id, username, user_colour, user_email, user_allow_viewemail, user_lang, user_notify_type FROM ' . USERS_TABLE . ' WHERE user_id = ' . (int) $user_id . ' AND user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')'; diff --git a/phpBB/phpbb/messenger/method/jabber.php b/phpBB/phpbb/messenger/method/jabber.php deleted file mode 100644 index a4a2c07f61..0000000000 --- a/phpBB/phpbb/messenger/method/jabber.php +++ /dev/null @@ -1,1236 +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\messenger\method; - -/** - * - * Based on Jabber class from Flyspray project - * - * @version class.jabber2.php 1595 2008-09-19 (0.9.9) - * @copyright 2006 Flyspray.org - * @author Florian Schmitz (floele) - * - * Slightly modified by Acyd Burn (2006) - * Refactored to a service (2024) - */ -class jabber extends base -{ - /** @var string */ - protected $connect_server; - - /** @var resource|null */ - protected $connection = null; - - /** @var bool */ - protected $enable_logging = true; - - /** @var array */ - protected $features = []; - - /** @var array */ - protected $jid = []; - - /** @var array */ - protected $log_array = []; - - /** @var string */ - protected $password; - - /** @var int */ - protected $port; - - /** @var string */ - protected $resource = 'functions_jabber.phpbb.php'; - - /** @var string */ - protected $server; - - /** @var array */ - protected $session = []; - - /** @var array */ - protected $stream_options = []; - - /** @var int */ - protected $timeout = 10; - - /** @var array */ - protected $to = []; - - /** @var bool */ - protected $use_ssl = false; - - /** @var string */ - protected $username; - - /** @var string Stream close handshake */ - private const STREAM_CLOSE_HANDSHAKE = ''; - - /** - * Set initial parameter values - * To init correctly, username() call should go before server() - * and ssl() call should go before port() and stream_options() calls. - * - * Example: - * $this->username($username) - * ->password($password) - * ->ssl($use_ssl) - * ->server($server) - * ->port($port) - * ->stream_options( - * 'verify_peer' => true, - * 'verify_peer_name' => true, - * 'allow_self_signed' => false, - * ); - * - * @return void - */ - public function init(): void - { - $this->username($this->config['jab_username']) - ->password($this->config['jab_password']) - ->ssl((bool) $this->config['jab_use_ssl']) - ->server($this->config['jab_host']) - ->port($this->config['jab_port']) - ->stream_options['ssl'] = [ - 'verify_peer' => $this->config['jab_verify_peer'], - 'verify_peer_name' => $this->config['jab_verify_peer_name'], - 'allow_self_signed' => $this->config['jab_allow_self_signed'], - ]; - } - - /** - * {@inheritDoc} - */ - public function get_id(): int - { - return self::NOTIFY_IM; - } - - /** - * {@inheritDoc} - */ - public function get_queue_object_name(): string - { - return 'jabber'; - } - - /** - * {@inheritDoc} - */ - public function is_enabled(): bool - { - return - !empty($this->config['jab_enable']) && - !empty($this->config['jab_host']) && - !empty($this->config['jab_username']) && - !empty($this->config['jab_password']); - } - - /** - * Set ssl context options - * See http://php.net/manual/en/context.ssl.php - * - * @param array $options SSL context options array - * @return self - */ - public function stream_options(array $options = []): self - { - if ($this->use_ssl) - { - // Change default stream options if needed - $this->stream_options['ssl'] = array_merge($this->stream_options['ssl'], $options); - } - - return $this; - } - - /** - * Set password to connect to server - * - * @param string $password Password to connect to server - * @return self - */ - public function password(string $password = ''): self - { - $this->password = html_entity_decode($password, ENT_COMPAT); - - return $this; - } - - /** - * Set use of ssl to connect to server - * - * @param bool $use_ssl Flag indicating use of ssl to connect to server - * @return self - */ - public function ssl(bool $use_ssl = false): self - { - $this->use_ssl = $use_ssl && self::can_use_ssl(); - - return $this; - } - - /** - * Set port to connect to server - * use_ssl flag should be set first - * - * @param int $port Port to connect to server - * @return self - */ - public function port(int $port = 5222): self - { - $this->port = ($port > 0) ? $port : 5222; - - // Change port if we use SSL - if ($this->port == 5222 && $this->use_ssl) - { - $this->port = 5223; - } - - return $this; - } - - /** - * Set username to connect to server - * - * @param string $username Username to connect to server - * @return self - */ - public function username(string $username = ''): self - { - if (str_contains($username, '@')) - { - $this->jid = explode('@', $username, 2); - $this->username = $this->jid[0]; - } - else - { - $this->username = $username; - } - - return $this; - } - - /** - * Set server to connect - * Username should be set first - * - * @param string $server Server to connect - * @return self - */ - public function server(string $server = ''): self - { - $this->connect_server = $server ?: 'localhost'; - $this->server = $this->jid[1] ?? $this->connect_server; - - return $this; - } - - /** - * Check if it's possible to use the SSL functionality - * - * @return bool - */ - public static function can_use_ssl(): bool - { - return @extension_loaded('openssl'); - } - - /** - * Check if it's possible to use TLS functionality - * - * @return bool - */ - public static function can_use_tls(): bool - { - if (!@extension_loaded('openssl') || !function_exists('stream_socket_enable_crypto') || !function_exists('stream_get_meta_data') || !function_exists('stream_set_blocking') || !function_exists('stream_get_wrappers')) - { - return false; - } - - /** - * Make sure the encryption stream is supported - * Also seem to work without the crypto stream if correctly compiled - - $streams = stream_get_wrappers(); - - if (!in_array('streams.crypto', $streams)) - { - return false; - } - */ - - return true; - } - - /** - * Sets the resource which is used. No validation is done here, only escaping - * - * @param string $name - * @return void - */ - public function set_resource(string $name): void - { - $this->resource = $name; - } - - /** - * Connect to the server - * - * @return bool - */ - public function connect(): bool - { -/* if (!$this->check_jid($this->username . '@' . $this->server)) - { - $this->add_to_log('Error: Jabber ID is not valid: ' . $this->username . '@' . $this->server); - return false; - }*/ - - $this->session['ssl'] = $this->use_ssl; - - if ($this->open_socket($this->connect_server, $this->port)) - { - $this->send_xml("\n"); - $this->send_xml("\n"); - } - else - { - $this->add_to_log('Error: connect() #2'); - return false; - } - - // Now we listen what the server has to say...and give appropriate responses - $this->response($this->listen()); - return true; - } - - /** - * Disconnect from the server - * - * @return bool - */ - public function disconnect(): bool - { - if ($this->connected()) - { - // disconnect gracefully - if (isset($this->session['sent_presence'])) - { - $this->send_presence('offline', '', true); - } - - $this->send(self::STREAM_CLOSE_HANDSHAKE); - // Check stream close handshake reply - $stream_close_reply = $this->listen(); - - if ($stream_close_reply != self::STREAM_CLOSE_HANDSHAKE) - { - $this->add_to_log("Error: Unexpected stream close handshake reply ”{$stream_close_reply}”"); - } - - $this->session = []; - /** @psalm-suppress InvalidPropertyAssignmentValue */ - return fclose($this->connection); - } - - return false; - } - - /** - * Check if it's still connected to the server - * - * @return bool - */ - public function connected(): bool - { - return is_resource($this->connection) && !feof($this->connection); - } - - /** - * Initiates login (using data from contructor, after calling connect()) - * - * @return bool - */ - public function login(): bool - { - if (empty($this->features)) - { - $this->add_to_log('Error: No feature information from server available.'); - return false; - } - - return $this->response($this->features); - } - - /** - * {@inheritDoc} - */ - public function set_addresses(array $user_row): void - { - if (isset($user_row['user_jabber']) && $user_row['user_jabber']) - { - $this->to($user_row['user_jabber'], (isset($user_row['username']) ? $user_row['username'] : '')); - } - } - - /** - * Sets jabber contact to send message to - * - * @param string $address Jabber "To" recipient address - * @param string $realname Jabber "To" recipient name - * @return void - */ - public function to(string $address, string $realname = ''): void - { - // IM-Addresses could be empty - if (!trim($address)) - { - return; - } - - $pos = !empty($this->to) ? count($this->to) : 0; - $this->to[$pos]['uid'] = trim($address); - $this->to[$pos]['name'] = trim($realname); - } - - /** - * Resets all the data (address, template file, etc) to default - */ - public function reset(): void - { - $this->subject = $this->msg = ''; - $this->additional_headers = $this->to = []; - $this->use_queue = true; - unset($this->template); - } - - /** - * {@inheritDoc} - */ - public function set_use_queue(bool $use_queue = true): void - { - $this->use_queue = !$this->config['jab_package_size'] ? false : $use_queue; - } - - /** - * {@inheritDoc} - */ - public function process_queue(array &$queue_data): void - { - $queue_object_name = $this->get_queue_object_name(); - $messages_count = count($queue_data[$queue_object_name]['data']); - - if (!$this->is_enabled() || !$messages_count) - { - unset($queue_data[$queue_object_name]); - return; - } - - @set_time_limit(0); - - $package_size = $queue_data[$queue_object_name]['package_size'] ?? 0; - $num_items = (!$package_size || $messages_count < $package_size) ? $messages_count : $package_size; - - for ($i = 0; $i < $num_items; $i++) - { - // Make variables available... - extract(array_shift($queue_data[$queue_object_name]['data'])); - - if (!$this->connect()) - { - $this->error($this->user->lang['ERR_JAB_CONNECT'] . '
' . $this->get_log()); - return; - } - - if (!$this->login()) - { - $this->error($this->user->lang['ERR_JAB_AUTH'] . '
' . $this->get_log()); - return; - } - - foreach ($addresses as $address) - { - if ($this->send_message($address, $msg, $subject) === false) - { - $this->error($this->get_log()); - continue; - } - } - } - - // No more data for this object? Unset it - if (!count($queue_data[$queue_object_name]['data'])) - { - unset($queue_data[$queue_object_name]); - } - - $this->disconnect(); - } - - /** - * {@inheritDoc} - */ - public function send(): bool - { - $this->prepare_message(); - - if (empty($this->to)) - { - $this->add_to_log('Error: Could not send, recepient addresses undefined.'); - return false; - } - - $addresses = []; - foreach ($this->to as $uid_ary) - { - $addresses[] = $uid_ary['uid']; - } - $addresses = array_unique($addresses); - - if (!$this->use_queue) - { - if (!$this->connect()) - { - $this->error($this->user->lang['ERR_JAB_CONNECT'] . '
' . $this->get_log()); - return false; - } - - if (!$this->login()) - { - $this->error($this->user->lang['ERR_JAB_AUTH'] . '
' . $this->get_log()); - return false; - } - - foreach ($addresses as $address) - { - if ($this->send_message($address, $this->msg, $this->subject) === false) - { - $this->error($this->get_log()); - continue; - } - } - - $this->disconnect(); - } - else - { - $this->queue->init('jabber', $this->config['jab_package_size']); - $this->queue->put('jabber', [ - 'addresses' => $addresses, - 'subject' => $this->subject, - 'msg' => $this->msg, - ]); - } - unset($addresses); - - $this->reset(); - - return true; - } - - /** - * Send data to the Jabber server - * - * @param string $xml - * @return int|bool - */ - public function send_xml(string $xml): int|bool - { - if ($this->connected()) - { - $xml = trim($xml); - return fwrite($this->connection, $xml); - } - else - { - $this->add_to_log('Error: Could not send, connection lost (flood?).'); - return false; - } - } - - /** - * Open socket - * - * @param string $server Host to connect to - * @param int $port Port number - * - * @return bool - */ - public function open_socket(string $server, int $port): bool - { - if (@function_exists('dns_get_record')) - { - $record = @dns_get_record("_xmpp-client._tcp.$server", DNS_SRV); - if (!empty($record) && !empty($record[0]['target'])) - { - $server = $record[0]['target']; - } - } - - $remote_socket = $this->use_ssl ? 'ssl://' . $server . ':' . $port : $server . ':' . $port; - $socket_context = stream_context_create($this->stream_options); - - if ($this->connection = @stream_socket_client($remote_socket, $errorno, $errorstr, $this->timeout, STREAM_CLIENT_CONNECT, $socket_context)) - { - stream_set_blocking($this->connection, 0); - stream_set_timeout($this->connection, 60); - - return true; - } - - // Apparently an error occurred... - $this->add_to_log('Error: open_socket() - ' . $errorstr); - return false; - } - - /** - * Get connection log - * - * @return string - */ - public function get_log(): string - { - if ($this->enable_logging && count($this->log_array)) - { - return implode("

", $this->log_array); - } - - return ''; - } - - /** - * Add information to log - * - * @param string $string Log entry - * @return void - */ - protected function add_to_log(string $string): void - { - if ($this->enable_logging) - { - $this->log_array[] = utf8_htmlspecialchars($string); - } - } - - /** - * Listens to the connection until it gets data or the timeout is reached. - * Thus, it should only be called if data is expected to be received. - * - * @param int $timeout Connection timeout - * @param bool $wait Flag indicating if it should wait for the responce until timeout - * @return bool|array Either false for timeout or an array with the received data - */ - public function listen(int $timeout = 10, bool $wait = false): bool|array - { - if (!$this->connected()) - { - return false; - } - - // Wait for a response until timeout is reached - $start = time(); - $data = ''; - - do - { - $read = trim(fread($this->connection, 4096)); - $data .= $read; - } - while (time() <= $start + $timeout && !feof($this->connection) && ($wait || $data == '' || $read != '' || (substr(rtrim($data), -1) != '>'))); - - if ($data != '') - { - return $this->xmlize($data); - } - else - { - $this->add_to_log('Timeout, no response from server.'); - return false; - } - } - - /** - * Initiates account registration (based on data used for constructor) - * - * @return bool|null - */ - public function register(): bool|null - { - if (!isset($this->session['id']) || isset($this->session['jid'])) - { - $this->add_to_log('Error: Cannot initiate registration.'); - return false; - } - - $this->send_xml(""); - return $this->response($this->listen()); - } - - /** - * Sets account presence. No additional info required (default is "online" status) - * - * @param string $message Account status (online, offline) - * @param string $type Status type (dnd, away, chat, xa or nothing) - * @param bool $unavailable Set to true to make unavailable status - * @return int|bool - */ - function send_presence(string $message = '', string $type = '', bool $unavailable = false): int|bool - { - if (!isset($this->session['jid'])) - { - $this->add_to_log('ERROR: send_presence() - Cannot set presence at this point, no jid given.'); - return false; - } - - $type = strtolower($type); - $type = (in_array($type, array('dnd', 'away', 'chat', 'xa'))) ? ''. $type .'' : ''; - - $unavailable = ($unavailable) ? " type='unavailable'" : ''; - $message = ($message) ? '' . utf8_htmlspecialchars($message) .'' : ''; - - $this->session['sent_presence'] = !$unavailable; - - return $this->send_xml("" . $type . $message . ''); - } - - /** - * This handles all the different XML elements - * - * @param array $xml - * @return bool - */ - function response(array $xml): bool - { - if (!count($xml)) - { - return false; - } - - // did we get multiple elements? do one after another - // array('message' => ..., 'presence' => ...) - if (count($xml) > 1) - { - foreach ($xml as $key => $value) - { - $this->response(array($key => $value)); - } - return true; - } - else if (is_array(reset($xml)) && count(reset($xml)) > 1) - { - // or even multiple elements of the same type? - // array('message' => array(0 => ..., 1 => ...)) - foreach (reset($xml) as $value) - { - $this->response(array(key($xml) => array(0 => $value))); - } - return true; - } - - switch (key($xml)) - { - case 'stream:stream': - // Connection initialised (or after authentication). Not much to do here... - - if (isset($xml['stream:stream'][0]['#']['stream:features'])) - { - // we already got all info we need - $this->features = $xml['stream:stream'][0]['#']; - } - else - { - $this->features = $this->listen(); - } - - $second_time = isset($this->session['id']); - $this->session['id'] = isset($xml['stream:stream'][0]['@']['id']) ? $xml['stream:stream'][0]['@']['id'] : ''; - - if ($second_time) - { - // If we are here for the second time after TLS, we need to continue logging in - return $this->login(); - } - - // go on with authentication? - if (isset($this->features['stream:features'][0]['#']['bind']) || !empty($this->session['tls'])) - { - return $this->response($this->features); - } - return false; - break; - - case 'stream:features': - // Resource binding after successful authentication - if (isset($this->session['authenticated'])) - { - // session required? - $this->session['sess_required'] = isset($xml['stream:features'][0]['#']['session']); - - $this->send_xml(" - - " . utf8_htmlspecialchars($this->resource) . ' - - '); - return $this->response($this->listen()); - } - - // Let's use TLS if SSL is not enabled and we can actually use it - if (!$this->session['ssl'] && self::can_use_tls() && self::can_use_ssl() && isset($xml['stream:features'][0]['#']['starttls'])) - { - $this->add_to_log('Switching to TLS.'); - $this->send_xml("\n"); - return $this->response($this->listen()); - } - - // Does the server support SASL authentication? - - // I hope so, because we do (and no other method). - if (isset($xml['stream:features'][0]['#']['mechanisms'][0]['@']['xmlns']) && $xml['stream:features'][0]['#']['mechanisms'][0]['@']['xmlns'] == 'urn:ietf:params:xml:ns:xmpp-sasl') - { - // Now decide on method - $methods = array(); - - foreach ($xml['stream:features'][0]['#']['mechanisms'][0]['#']['mechanism'] as $value) - { - $methods[] = $value['#']; - } - - // we prefer DIGEST-MD5 - // we don't want to use plain authentication (neither does the server usually) if no encryption is in place - - // http://www.xmpp.org/extensions/attic/jep-0078-1.7.html - // The plaintext mechanism SHOULD NOT be used unless the underlying stream is encrypted (using SSL or TLS) - // and the client has verified that the server certificate is signed by a trusted certificate authority. - - if (in_array('DIGEST-MD5', $methods)) - { - $this->send_xml(""); - } - else if (in_array('PLAIN', $methods) && ($this->session['ssl'] || !empty($this->session['tls']))) - { - // http://www.ietf.org/rfc/rfc4616.txt (PLAIN SASL Mechanism) - $this->send_xml("" - . base64_encode($this->username . '@' . $this->server . chr(0) . $this->username . chr(0) . $this->password) . - ''); - } - else if (in_array('ANONYMOUS', $methods)) - { - $this->send_xml(""); - } - else - { - // not good... - $this->add_to_log('Error: No authentication method supported.'); - $this->disconnect(); - return false; - } - - return $this->response($this->listen()); - } - else - { - // ok, this is it. bye. - $this->add_to_log('Error: Server does not offer SASL authentication.'); - $this->disconnect(); - return false; - } - break; - - case 'challenge': - // continue with authentication...a challenge literally -_- - $decoded = base64_decode($xml['challenge'][0]['#']); - $decoded = $this->parse_data($decoded); - - if (!isset($decoded['digest-uri'])) - { - $decoded['digest-uri'] = 'xmpp/'. $this->server; - } - - // better generate a cnonce, maybe it's needed - $decoded['cnonce'] = base64_encode(md5(uniqid(mt_rand(), true))); - - // second challenge? - if (isset($decoded['rspauth'])) - { - $this->send_xml(""); - } - else - { - // Make sure we only use 'auth' for qop (relevant for $this->encrypt_password()) - // If the is choking up on the changed parameter we may need to adjust encrypt_password() directly - if (isset($decoded['qop']) && $decoded['qop'] != 'auth' && strpos($decoded['qop'], 'auth') !== false) - { - $decoded['qop'] = 'auth'; - } - - $response = array( - 'username' => $this->username, - 'response' => $this->encrypt_password(array_merge($decoded, array('nc' => '00000001'))), - 'charset' => 'utf-8', - 'nc' => '00000001', - 'qop' => 'auth', // only auth being supported - ); - - foreach (array('nonce', 'digest-uri', 'realm', 'cnonce') as $key) - { - if (isset($decoded[$key])) - { - $response[$key] = $decoded[$key]; - } - } - - $this->send_xml("" . base64_encode($this->implode_data($response)) . ''); - } - - return $this->response($this->listen()); - break; - - case 'failure': - $this->add_to_log('Error: Server sent "failure".'); - $this->disconnect(); - return false; - break; - - case 'proceed': - // continue switching to TLS - $meta = stream_get_meta_data($this->connection); - stream_set_blocking($this->connection, 1); - - if (!stream_socket_enable_crypto($this->connection, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) - { - $this->add_to_log('Error: TLS mode change failed.'); - return false; - } - - stream_set_blocking($this->connection, $meta['blocked']); - $this->session['tls'] = true; - - // new stream - $this->send_xml("\n"); - $this->send_xml("\n"); - - return $this->response($this->listen()); - break; - - case 'success': - // Yay, authentication successful. - $this->send_xml("\n"); - $this->session['authenticated'] = true; - - // we have to wait for another response - return $this->response($this->listen()); - break; - - case 'iq': - // we are not interested in IQs we did not expect - if (!isset($xml['iq'][0]['@']['id'])) - { - return false; - } - - // multiple possibilities here - switch ($xml['iq'][0]['@']['id']) - { - case 'bind_1': - $this->session['jid'] = $xml['iq'][0]['#']['bind'][0]['#']['jid'][0]['#']; - - // and (maybe) yet another request to be able to send messages *finally* - if ($this->session['sess_required']) - { - $this->send_xml(" - - "); - return $this->response($this->listen()); - } - - return true; - break; - - case 'sess_1': - return true; - break; - - case 'reg_1': - $this->send_xml(" - - " . utf8_htmlspecialchars($this->username) . " - " . utf8_htmlspecialchars($this->password) . " - - "); - return $this->response($this->listen()); - break; - - case 'reg_2': - // registration end - if (isset($xml['iq'][0]['#']['error'])) - { - $this->add_to_log('Warning: Registration failed.'); - return false; - } - return true; - break; - - case 'unreg_1': - return true; - break; - - default: - $this->add_to_log('Notice: Received unexpected IQ.'); - return false; - break; - } - break; - - case 'message': - // we are only interested in content... - if (!isset($xml['message'][0]['#']['body'])) - { - return false; - } - - $message['body'] = $xml['message'][0]['#']['body'][0]['#']; - $message['from'] = $xml['message'][0]['@']['from']; - - if (isset($xml['message'][0]['#']['subject'])) - { - $message['subject'] = $xml['message'][0]['#']['subject'][0]['#']; - } - $this->session['messages'][] = $message; - return true; - break; - - default: - // hm...don't know this response - $this->add_to_log('Notice: Unknown server response'); - return false; - break; - } - } - - /** - * Send Jabber message - * - * @param string $to Recepient usermane - * @param string $text Message text - * @param string $subject Message subject - * @param string $type Message type - * - * @return int|bool - */ - public function send_message(string $to, string $text, string $subject = '', string $type = 'normal'): int|bool - { - if (!isset($this->session['jid'])) - { - return false; - } - - if (!in_array($type, array('chat', 'normal', 'error', 'groupchat', 'headline'))) - { - $type = 'normal'; - } - - return $this->send_xml(" - " . utf8_htmlspecialchars($subject) . " - " . utf8_htmlspecialchars($text) . " - " - ); - } - - /** - * Encrypts a password as in RFC 2831 - * - * @param array $data Needs data from the client-server connection - * @return string - */ - public function encrypt_password(array $data): string - { - // let's me think about again... - foreach (array('realm', 'cnonce', 'digest-uri') as $key) - { - if (!isset($data[$key])) - { - $data[$key] = ''; - } - } - - $pack = md5($this->username . ':' . $data['realm'] . ':' . $this->password); - - if (isset($data['authzid'])) - { - $a1 = pack('H32', $pack) . sprintf(':%s:%s:%s', $data['nonce'], $data['cnonce'], $data['authzid']); - } - else - { - $a1 = pack('H32', $pack) . sprintf(':%s:%s', $data['nonce'], $data['cnonce']); - } - - // should be: qop = auth - $a2 = 'AUTHENTICATE:'. $data['digest-uri']; - - return md5(sprintf('%s:%s:%s:%s:%s:%s', md5($a1), $data['nonce'], $data['nc'], $data['cnonce'], $data['qop'], md5($a2))); - } - - /** - * Parse data string like a="b",c="d",... or like a="a, b", c, d="e", f=g,... - * - * @param string $data - * @return array a => b ... - */ - public function parse_data(string $data): array - { - $data = explode(',', $data); - $pairs = array(); - $key = false; - - foreach ($data as $pair) - { - $dd = strpos($pair, '='); - - if ($dd) - { - $key = trim(substr($pair, 0, $dd)); - $pairs[$key] = trim(trim(substr($pair, $dd + 1)), '"'); - } - else if (strpos(strrev(trim($pair)), '"') === 0 && $key) - { - // We are actually having something left from "a, b" values, add it to the last one we handled. - $pairs[$key] .= ',' . trim(trim($pair), '"'); - continue; - } - } - - return $pairs; - } - - /** - * The opposite of jabber::parse_data() - * - * @param array $data Data array - * @return string - */ - public function implode_data(array $data): string - { - $return = array(); - foreach ($data as $key => $value) - { - $return[] = $key . '="' . $value . '"'; - } - return implode(',', $return); - } - - /** - * xmlize() - * @author Hans Anderson - * @copyright Hans Anderson / http://www.hansanderson.com/php/xml/ - * - * @param string $data Data string - * @param string|int|bool $skip_white New XML parser option value - * @param string $encoding Encoding value - * @return array - */ - function xmlize(string $data, string|int|bool $skip_white = 1, string $encoding = 'UTF-8'): array - { - $data = trim($data); - - if (substr($data, 0, 5) != ''. $data . ''; - } - - $vals = $index = $array = array(); - $parser = xml_parser_create($encoding); - xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); - xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, $skip_white); - xml_parse_into_struct($parser, $data, $vals, $index); - xml_parser_free($parser); - - $i = 0; - $tagname = $vals[$i]['tag']; - - $array[$tagname][0]['@'] = (isset($vals[$i]['attributes'])) ? $vals[$i]['attributes'] : array(); - $array[$tagname][0]['#'] = $this->_xml_depth($vals, $i); - - if (substr($data, 0, 5) != '_xml_depth($vals, $i); - - break; - - case 'cdata': - array_push($children, $vals[$i]['value']); - break; - - case 'complete': - - $tagname = $vals[$i]['tag']; - $size = (isset($children[$tagname])) ? count($children[$tagname]) : 0; - $children[$tagname][$size]['#'] = (isset($vals[$i]['value'])) ? $vals[$i]['value'] : array(); - - if (isset($vals[$i]['attributes'])) - { - $children[$tagname][$size]['@'] = $vals[$i]['attributes']; - } - - break; - - case 'close': - return $children; - break; - } - } - - return $children; - } -} diff --git a/tests/messenger/method_jabber_test.php b/tests/messenger/method_jabber_test.php deleted file mode 100644 index d61cd9b1b1..0000000000 --- a/tests/messenger/method_jabber_test.php +++ /dev/null @@ -1,311 +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. - * - */ - -class phpbb_messenger_method_jabber_test extends \phpbb_test_case -{ - protected $assets_bag; - protected $cache_path; - protected config $config; - protected $dispatcher; - protected $extension_manager; - protected jabber $method_jabber; - protected $method_base; - protected $language; - protected $log; - protected $path_helper; - protected queue $queue; - protected $request; - protected $twig_extensions_collection; - protected $twig_lexer; - protected $user; - - public function setUp(): void - { - global $config, $request, $symfony_request, $user, $phpbb_root_path, $phpEx; - - $this->assets_bag = new assets_bag(); - $this->cache_path = $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/twig'; - $this->config = new config([ - 'force_server_vars' => false, - 'jab_username' => 'test', - 'jab_password' => 'password', - 'jab_use_ssl' => false, - 'jab_host' => 'localhost', - 'jab_port' => 5222, - 'jab_verify_peer' => true, - 'jab_verify_peer_name' => true, - 'jab_allow_self_signed' => false, - ]); - $config = $this->config; - $this->dispatcher = $this->getMockBuilder('\phpbb\event\dispatcher') - ->disableOriginalConstructor() - ->getMock(); - $this->filesystem = new \phpbb\filesystem\filesystem(); - $this->language = new language(new language_file_loader($phpbb_root_path, $phpEx)); - $this->queue = $this->createMock(queue::class); - $this->request = new phpbb_mock_request(); - $request = $this->request; - $this->symfony_request = new symfony_request(new phpbb_mock_request()); - $symfony_request = $this->symfony_request; - $this->user = $this->getMockBuilder('\phpbb\user') - ->setConstructorArgs([$this->language, '\phpbb\datetime']) - ->getMock(); - $user = $this->user; - $user->page['root_script_path'] = 'phpbb/'; - $this->user->host = 'yourdomain.com'; - $this->path_helper = new path_helper( - $this->symfony_request, - $this->request, - $phpbb_root_path, - $phpEx - ); - $phpbb_container = new phpbb_mock_container_builder; - $this->twig_extensions_collection = new \phpbb\di\service_collection($phpbb_container); - $twig = new \phpbb\template\twig\environment( - $this->assets_bag, - $this->config, - $this->filesystem, - $this->path_helper, - $this->cache_path, - null, - new \phpbb\template\twig\loader(''), - $this->dispatcher, - array( - 'cache' => false, - 'debug' => false, - 'auto_reload' => true, - 'autoescape' => false, - ) - ); - $this->twig_lexer = new \phpbb\template\twig\lexer($twig); - $this->extension_manager = new phpbb_mock_extension_manager( - __DIR__ . '/', - array( - 'vendor2/foo' => array( - 'ext_name' => 'vendor2/foo', - 'ext_active' => '1', - 'ext_path' => 'ext/vendor2/foo/', - ), - ) - ); - $this->log = $this->createMock(\phpbb\log\log_interface::class); - - $this->method_jabber = new jabber( - $this->assets_bag, - $this->config, - $this->dispatcher, - $this->language, - $this->queue, - $this->path_helper, - $this->request, - $this->twig_extensions_collection, - $this->twig_lexer, - $this->user, - $phpbb_root_path, - $this->cache_path, - $this->extension_manager, - $this->log - ); - } - - public function test_miscellaneous() - { - $this->method_jabber->init(); - $this->assertEquals(messenger_interface::NOTIFY_IM, $this->method_jabber->get_id()); - $this->assertEquals('jabber', $this->method_jabber->get_queue_object_name()); - $this->assertFalse($this->method_jabber->is_enabled()); - $this->config->set('jab_enable', true); - $this->assertTrue($this->method_jabber->is_enabled()); - $this->assertEquals(@extension_loaded('openssl'), $this->method_jabber->can_use_ssl()); - } - - public function test_stream_options() - { - $this->method_jabber->init(); - $this->assertEquals($this->method_jabber, $this->method_jabber->stream_options([ - 'allow_self_signed' => true, - ])); - - $stream_options_reflection = new \ReflectionProperty($this->method_jabber, 'stream_options'); - $stream_options = $stream_options_reflection->getValue($this->method_jabber); - $this->assertEquals([ - 'ssl' => [ - 'allow_self_signed' => false, - 'verify_peer' => true, - 'verify_peer_name' => true, - ], - ], $stream_options); - - $this->method_jabber->ssl(true); - - $this->assertEquals($this->method_jabber, $this->method_jabber->stream_options([ - 'allow_self_signed' => true, - ])); - $stream_options = $stream_options_reflection->getValue($this->method_jabber); - $this->assertEquals([ - 'ssl' => [ - 'allow_self_signed' => true, - 'verify_peer' => true, - 'verify_peer_name' => true, - ], - ], $stream_options); - } - - public function test_port_ssl_switch() - { - $port_reflection = new \ReflectionProperty($this->method_jabber, 'port'); - - $this->method_jabber->port(); - $this->assertEquals(5222, $port_reflection->getValue($this->method_jabber)); - - $this->method_jabber->ssl(true) - ->port(); - $this->assertEquals(5223, $port_reflection->getValue($this->method_jabber)); - } - - public function test_username() - { - $jabber_reflection = new \ReflectionClass($this->method_jabber); - $username_reflection = $jabber_reflection->getProperty('username'); - $jid_reflection = $jabber_reflection->getProperty('jid'); - - $this->method_jabber->username('foo@bar'); - $this->assertEquals(['foo', 'bar'], $jid_reflection->getValue($this->method_jabber)); - $this->assertEquals('foo', $username_reflection->getValue($this->method_jabber)); - - $this->method_jabber->username('bar@baz@qux'); - $this->assertEquals(['bar', 'baz@qux'], $jid_reflection->getValue($this->method_jabber)); - $this->assertEquals('bar', $username_reflection->getValue($this->method_jabber)); - } - - public function test_server() - { - $jabber_reflection = new \ReflectionClass($this->method_jabber); - $connect_server_reflection = $jabber_reflection->getProperty('connect_server'); - $server_reflection = $jabber_reflection->getProperty('server'); - - $this->method_jabber->server(); - $this->assertEquals('localhost', $connect_server_reflection->getValue($this->method_jabber)); - $this->assertEquals('localhost', $server_reflection->getValue($this->method_jabber)); - - $this->method_jabber->server('foobar.com'); - $this->assertEquals('foobar.com', $connect_server_reflection->getValue($this->method_jabber)); - $this->assertEquals('foobar.com', $server_reflection->getValue($this->method_jabber)); - - $this->method_jabber->username('foo@bar.com'); - $this->method_jabber->server('foobar.com'); - $this->assertEquals('foobar.com', $connect_server_reflection->getValue($this->method_jabber)); - $this->assertEquals('bar.com', $server_reflection->getValue($this->method_jabber)); - } - - public function test_encrypt_password() - { - $this->method_jabber->init(); - $this->method_jabber->password('password'); - $data = [ - 'realm' => 'example.com', - 'nonce' => '12345', - 'cnonce' => 'abcde', - 'digest-uri' => 'xmpp/example.com', - 'nc' => '00000001', - 'qop' => 'auth', - ]; - - $expected = md5(sprintf( - '%s:%s:%s:%s:%s:%s', - md5(pack('H32', md5('test:example.com:password')) . ':12345:abcde'), - $data['nonce'], - $data['nc'], - $data['cnonce'], - $data['qop'], - md5('AUTHENTICATE:xmpp/example.com') - )); - $this->assertEquals($expected, $this->method_jabber->encrypt_password($data)); - } - - public function test_parse_data() - { - $data = 'key1="value1",key2="value2",key3="value3"'; - $expected = [ - 'key1' => 'value1', - 'key2' => 'value2', - 'key3' => 'value3', - ]; - - $this->assertEquals($expected, $this->method_jabber->parse_data($data)); - } - - public function test_implode_data() - { - $data = [ - 'key1' => 'value1', - 'key2' => 'value2', - 'key3' => 'value3', - ]; - $expected = 'key1="value1",key2="value2",key3="value3"'; - - $this->assertEquals($expected, $this->method_jabber->implode_data($data)); - } - - public function test_xmlize() - { - $xml = 'content'; - $result = $this->method_jabber->xmlize($xml); - - $this->assertArrayHasKey('root', $result); - $this->assertArrayHasKey('child', $result['root'][0]['#']); - $this->assertEquals('content', $result['root'][0]['#']['child'][0]['#']); - $this->assertEquals(['key' => 'value'], $result['root'][0]['#']['child'][0]['@']); - } - - public function test_send_xml() - { - $jabber_mock = $this->getMockBuilder(jabber::class) - ->setConstructorArgs([ - $this->assets_bag, - $this->config, - $this->dispatcher, - $this->language, - $this->queue, - $this->path_helper, - $this->request, - $this->twig_extensions_collection, - $this->twig_lexer, - $this->user, - '', - '', - $this->extension_manager, - $this->log, - ]) - ->onlyMethods(['send_xml']) - ->getMock(); - - $jabber_mock->expects($this->once()) - ->method('send_xml') - ->with('Test') - ->willReturn(true); - - $this->assertTrue($jabber_mock->send_xml('Test')); - } -} diff --git a/tests/messenger/queue_test.php b/tests/messenger/queue_test.php index e99893d577..cb058cdc75 100644 --- a/tests/messenger/queue_test.php +++ b/tests/messenger/queue_test.php @@ -239,27 +239,10 @@ class phpbb_messenger_queue_test extends phpbb_test_case ], $queue_data['email']); unset($queue_data['email']); }); - $jabber_method = $this->getMockBuilder('phpbb\messenger\method\jabber') - ->disableOriginalConstructor() - ->onlyMethods(['get_queue_object_name', 'process_queue']) - ->getMock(); - $jabber_method->method('get_queue_object_name') - ->willReturn('jabber'); - $jabber_method->method('process_queue') - ->willReturnCallback(function(array &$queue_data) { - $this->assertEquals([ - 'package_size' => 10, - 'data' => [ - ['data2'], - ], - ], $queue_data['jabber']); - unset($queue_data['jabber']); - }); $this->service_collection->method('getIterator') ->willReturn(new \ArrayIterator([ 'email' => $email_method, - 'jabber' => $jabber_method, ])); // Process the queue diff --git a/tests/notification/base.php b/tests/notification/base.php index 07fef3a1c5..ec6319c420 100644 --- a/tests/notification/base.php +++ b/tests/notification/base.php @@ -148,7 +148,6 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case $messenger_method_collection = new \phpbb\di\service_collection($phpbb_container); $messenger_method_collection->add('messenger.method.email'); - $messenger_method_collection->add('messenger.method.jabber'); $phpbb_container->set('messenger.method_collection', $messenger_method_collection); $phpbb_container->compile(); diff --git a/tests/notification/notification_method_email_test.php b/tests/notification/notification_method_email_test.php index 15811cc968..6400c8bb1d 100644 --- a/tests/notification/notification_method_email_test.php +++ b/tests/notification/notification_method_email_test.php @@ -107,7 +107,6 @@ class notification_method_email_test extends phpbb_tests_notification_base $messenger_method_collection = new \phpbb\di\service_collection($phpbb_container); $messenger_method_collection->add('messenger.method.email'); - $messenger_method_collection->add('messenger.method.jabber'); $phpbb_container->set('messenger.method_collection', $messenger_method_collection); $this->notification_method_email = $this->getMockBuilder('\phpbb\notification\method\email') diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index 57b1242509..08505667d7 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -161,7 +161,6 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c $messenger_method_collection = new \phpbb\di\service_collection($phpbb_container); $messenger_method_collection->add('messenger.method.email'); - $messenger_method_collection->add('messenger.method.jabber'); $phpbb_container->set('messenger.method_collection', $messenger_method_collection); $phpbb_container->addCompilerPass(new phpbb\di\pass\markpublic_pass()); From bb26658a00c0de83f26a1a7e443f6919c862ac34 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 14 Apr 2025 21:39:06 +0200 Subject: [PATCH 11/23] [ticket/17493] Remove jabber data in queue test PHPBB-17493 --- tests/messenger/queue_test.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/messenger/queue_test.php b/tests/messenger/queue_test.php index cb058cdc75..3f87de91fc 100644 --- a/tests/messenger/queue_test.php +++ b/tests/messenger/queue_test.php @@ -202,20 +202,14 @@ class phpbb_messenger_queue_test extends phpbb_test_case // First save queue data $this->assertFileDoesNotExist($this->cache_file); $this->messenger_queue->init('email', 5); - $this->messenger_queue->init('jabber', 10); $this->assertEquals([ 'email' => [ 'package_size' => 5, 'data' => [], ], - 'jabber' => [ - 'package_size' => 10, - 'data' => [], - ] ], $this->messenger_queue->get_data()); $this->messenger_queue->put('email', ['data1']); - $this->messenger_queue->put('jabber', ['data2']); $this->messenger_queue->save(); $this->assertFileExists($this->cache_file); $this->assertEquals([], $this->messenger_queue->get_data()); From da32d51a8161245ce892ca3f45456b1449b246b4 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 18 Apr 2025 17:07:42 +0200 Subject: [PATCH 12/23] [ticket/17493] Remove remnants of user_notify_type PHPBB-17493 --- phpBB/includes/acp/acp_email.php | 42 +++++----- phpBB/includes/acp/acp_inactive.php | 25 +++--- phpBB/includes/acp/acp_users.php | 2 - phpBB/includes/functions_user.php | 3 +- phpBB/includes/mcp/mcp_reports.php | 2 +- phpBB/includes/ucp/ucp_activate.php | 21 ++--- phpBB/includes/ucp/ucp_prefs.php | 2 - phpBB/includes/ucp/ucp_profile.php | 20 +++-- phpBB/includes/ucp/ucp_resend.php | 23 +++-- .../db/migration/data/v400/remove_jabber.php | 15 ++-- .../data/v400/remove_notify_type.php | 64 ++++++++++++++ phpBB/phpbb/message/admin_form.php | 1 - phpBB/phpbb/message/message.php | 83 +++++++------------ phpBB/phpbb/message/topic_form.php | 1 - phpBB/phpbb/message/user_form.php | 2 +- phpBB/phpbb/ucp/controller/reset_password.php | 4 +- tests/auth/provider_apache_test.php | 1 - tests/functional/user_password_reset_test.php | 2 +- tests/notification/convert_test.php | 22 ++++- tests/notification/fixtures/convert.xml | 7 -- 20 files changed, 190 insertions(+), 152 deletions(-) create mode 100644 phpBB/phpbb/db/migration/data/v400/remove_notify_type.php diff --git a/phpBB/includes/acp/acp_email.php b/phpBB/includes/acp/acp_email.php index 8dbdbf409d..5156676881 100644 --- a/phpBB/includes/acp/acp_email.php +++ b/phpBB/includes/acp/acp_email.php @@ -226,33 +226,29 @@ class acp_email */ foreach ($messenger_collection_iterator as $messenger_method) { - $notify_method = $messenger_method->get_id(); - 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); + + for ($j = 0, $list_size = count($email_list[$i]); $j < $list_size; $j++) { - $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); - - 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); - - $errored = !$messenger_method->send() || $errored; - $messenger_method->save_queue(); } + + $messenger_method->anti_abuse_headers($config, $user); + $messenger_method->set_mail_priority($priority); + + $errored = !$messenger_method->send() || $errored; + $messenger_method->save_queue(); } } unset($email_list); diff --git a/phpBB/includes/acp/acp_inactive.php b/phpBB/includes/acp/acp_inactive.php index 138e06e525..b4b39cbdf9 100644 --- a/phpBB/includes/acp/acp_inactive.php +++ b/phpBB/includes/acp/acp_inactive.php @@ -185,7 +185,7 @@ class acp_inactive trigger_error($user->lang['EMAIL_DISABLED'] . adm_back_link($this->u_action), E_USER_WARNING); } - $sql = 'SELECT user_id, username, user_email, user_lang, user_notify_type, user_regdate, user_actkey + $sql = 'SELECT user_id, username, user_email, user_lang, user_regdate, user_actkey FROM ' . USERS_TABLE . ' WHERE ' . $db->sql_in_set('user_id', $mark) . ' AND user_inactive_reason'; @@ -211,20 +211,17 @@ class acp_inactive */ foreach ($messenger_collection_iterator as $messenger_method) { - if ($messenger_method->get_id() == $user_row['user_notify_type'] || $user_row['user_notify_type'] == $messenger_method::NOTIFY_BOTH) - { - $messenger_method->template('user_remind_inactive', $row['user_lang']); - $messenger_method->set_addresses($row); - $messenger_method->anti_abuse_headers($config, $user); - $messenger_method->assign_vars([ - 'USERNAME' => html_entity_decode($row['username'], ENT_COMPAT), - 'REGISTER_DATE' => $user->format_date($row['user_regdate'], false, true), - 'U_ACTIVATE' => generate_board_url() . "/ucp.$phpEx?mode=activate&u=" . $row['user_id'] . '&k=' . $row['user_actkey'], - ]); + $messenger_method->template('user_remind_inactive', $row['user_lang']); + $messenger_method->set_addresses($row); + $messenger_method->anti_abuse_headers($config, $user); + $messenger_method->assign_vars([ + 'USERNAME' => html_entity_decode($row['username'], ENT_COMPAT), + 'REGISTER_DATE' => $user->format_date($row['user_regdate'], false, true), + 'U_ACTIVATE' => generate_board_url() . "/ucp.$phpEx?mode=activate&u=" . $row['user_id'] . '&k=' . $row['user_actkey'], + ]); - $messenger_method->send(); - $messenger_method->save_queue(); - } + $messenger_method->send(); + $messenger_method->save_queue(); } $usernames[] = $row['username']; diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index e01eace64e..42d0338ba2 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1577,7 +1577,6 @@ class acp_users 'viewemail' => $request->variable('viewemail', $user_row['user_allow_viewemail']), 'massemail' => $request->variable('massemail', $user_row['user_allow_massemail']), 'hideonline' => $request->variable('hideonline', !$user_row['user_allow_viewonline']), - 'notifymethod' => $request->variable('notifymethod', $user_row['user_notify_type']), 'notifypm' => $request->variable('notifypm', $user_row['user_notify_pm']), 'allowpm' => $request->variable('allowpm', $user_row['user_allow_pm']), @@ -1648,7 +1647,6 @@ class acp_users 'user_allow_viewemail' => $data['viewemail'], 'user_allow_massemail' => $data['massemail'], 'user_allow_viewonline' => !$data['hideonline'], - 'user_notify_type' => $data['notifymethod'], 'user_notify_pm' => $data['notifypm'], 'user_dateformat' => $data['dateformat'], diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 42c9e7fd5a..a408f695aa 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -246,7 +246,6 @@ function user_add($user_row, $cp_data = false, $notifications_data = null) 'user_notify' => 0, 'user_notify_pm' => 1, - 'user_notify_type' => messenger_interface::NOTIFY_EMAIL, 'user_allow_pm' => 1, 'user_allow_viewonline' => 1, 'user_allow_viewemail' => 1, @@ -2528,7 +2527,7 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna case 'approve': // Make sure we only approve those which are pending ;) - $sql = 'SELECT u.user_id, u.user_email, u.username, u.username_clean, u.user_notify_type, u.user_lang + $sql = 'SELECT u.user_id FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . ' ug WHERE ug.group_id = ' . $group_id . ' AND ug.user_pending = 1 diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index 3325fd6b8d..ee9be079ae 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -661,7 +661,7 @@ function close_report($report_id_list, $mode, $action, $pm = false) { $post_info = ($pm) ? phpbb_get_pm_data($post_id_list) : phpbb_get_post_data($post_id_list, 'm_report'); - $sql = "SELECT r.report_id, r.$id_column, r.report_closed, r.user_id, r.user_notify, u.username, u.username_clean, u.user_email, u.user_lang, u.user_notify_type + $sql = "SELECT r.report_id, r.$id_column, r.report_closed, r.user_id, r.user_notify, u.username, u.username_clean, u.user_email, u.user_lang FROM " . REPORTS_TABLE . ' r, ' . USERS_TABLE . ' u WHERE ' . $db->sql_in_set('r.report_id', $report_id_list) . ' ' . (($action == 'close') ? 'AND r.report_closed = 0' : '') . ' diff --git a/phpBB/includes/ucp/ucp_activate.php b/phpBB/includes/ucp/ucp_activate.php index 81036c1956..50ccdfa7e6 100644 --- a/phpBB/includes/ucp/ucp_activate.php +++ b/phpBB/includes/ucp/ucp_activate.php @@ -35,7 +35,7 @@ class ucp_activate $user_id = $request->variable('u', 0); $key = $request->variable('k', ''); - $sql = 'SELECT user_id, username, user_type, user_email, user_newpasswd, user_lang, user_notify_type, user_actkey, user_inactive_reason + $sql = 'SELECT user_id, username, user_type, user_email, user_newpasswd, user_lang, user_actkey, user_inactive_reason FROM ' . USERS_TABLE . " WHERE user_id = $user_id"; $result = $db->sql_query($sql); @@ -140,18 +140,15 @@ class ucp_activate */ foreach ($messenger_collection_iterator as $messenger_method) { - if ($messenger_method->get_id() == $user_row['user_notify_type'] || $user_row['user_notify_type'] == $messenger_method::NOTIFY_BOTH) - { - $messenger_method->set_use_queue(false); - $messenger_method->template('admin_welcome_activated', $user_row['user_lang']); - $messenger_method->set_addresses($user_row); - $messenger_method->anti_abuse_headers($config, $user); - $messenger_method->assign_vars([ - 'USERNAME' => html_entity_decode($user_row['username'], ENT_COMPAT), - ]); + $messenger_method->set_use_queue(false); + $messenger_method->template('admin_welcome_activated', $user_row['user_lang']); + $messenger_method->set_addresses($user_row); + $messenger_method->anti_abuse_headers($config, $user); + $messenger_method->assign_vars([ + 'USERNAME' => html_entity_decode($user_row['username'], ENT_COMPAT), + ]); - $messenger_method->send(); - } + $messenger_method->send(); } $message = 'ACCOUNT_ACTIVE_ADMIN'; diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php index 480b4a3d12..86440cd714 100644 --- a/phpBB/includes/ucp/ucp_prefs.php +++ b/phpBB/includes/ucp/ucp_prefs.php @@ -42,7 +42,6 @@ class ucp_prefs case 'personal': add_form_key('ucp_prefs_personal'); $data = array( - 'notifymethod' => $request->variable('notifymethod', $user->data['user_notify_type']), 'dateformat' => $request->variable('dateformat', $user->data['user_dateformat'], true), 'lang' => basename($request->variable('lang', $user->data['user_lang'])), 'user_style' => $request->variable('user_style', (int) $user->data['user_style']), @@ -99,7 +98,6 @@ class ucp_prefs 'user_allow_viewemail' => $data['viewemail'], 'user_allow_massemail' => $data['massemail'], 'user_allow_viewonline' => ($auth->acl_get('u_hideonline')) ? !$data['hideonline'] : $user->data['user_allow_viewonline'], - 'user_notify_type' => $data['notifymethod'], 'user_options' => $user->data['user_options'], 'user_dateformat' => $data['dateformat'], diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index 77c1a56e9d..a5a1fe3d70 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -357,9 +357,7 @@ class ucp_profile if (!count($error)) { - $sql_ary = array( - 'user_notify_type' => messenger_interface::NOTIFY_EMAIL, - ); + $sql_ary = []; if ($config['allow_birthdays']) { @@ -378,13 +376,17 @@ class ucp_profile $vars = array('cp_data', 'data', 'sql_ary'); extract($phpbb_dispatcher->trigger_event('core.ucp_profile_info_modify_sql_ary', compact($vars))); - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE user_id = ' . $user->data['user_id']; - $db->sql_query($sql); + // Skip query if no data to update + if (count($sql_ary)) + { + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' + WHERE user_id = ' . $user->data['user_id']; + $db->sql_query($sql); - // Update Custom Fields - $cp->update_profile_field_data($user->data['user_id'], $cp_data); + // Update Custom Fields + $cp->update_profile_field_data($user->data['user_id'], $cp_data); + } meta_refresh(3, $this->u_action); $message = $user->lang['PROFILE_UPDATED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); diff --git a/phpBB/includes/ucp/ucp_resend.php b/phpBB/includes/ucp/ucp_resend.php index d3512865db..023ea80852 100644 --- a/phpBB/includes/ucp/ucp_resend.php +++ b/phpBB/includes/ucp/ucp_resend.php @@ -128,7 +128,7 @@ class ucp_resend // Grab an array of user_id's with a_user permissions ... these users can activate a user $admin_ary = $auth->acl_get_list(false, 'a_user', false); - $sql = 'SELECT user_id, username, user_email, user_lang, user_notify_type + $sql = 'SELECT user_id, username, user_email, user_lang FROM ' . USERS_TABLE . ' WHERE ' . $db->sql_in_set('user_id', $admin_ary[0]['a_user']); $result = $db->sql_query($sql); @@ -145,19 +145,16 @@ class ucp_resend foreach ($messenger_collection_iterator as $messenger_method) { $messenger_method->set_use_queue(false); - if ($messenger_method->get_id() == $row['user_notify_type'] || $row['user_notify_type'] == $messenger_method::NOTIFY_BOTH) - { - $messenger_method->template('admin_activate', $row['user_lang']); - $messenger_method->set_addresses($row); - $messenger_method->anti_abuse_headers($config, $user); - $messenger_method->assign_vars([ - 'USERNAME' => html_entity_decode($user_row['username'], ENT_COMPAT), - 'U_USER_DETAILS' => $board_url . "/memberlist.$phpEx?mode=viewprofile&u={$user_row['user_id']}", - 'U_ACTIVATE' => $board_url . "/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k={$user_row['user_actkey']}", - ]); + $messenger_method->template('admin_activate', $row['user_lang']); + $messenger_method->set_addresses($row); + $messenger_method->anti_abuse_headers($config, $user); + $messenger_method->assign_vars([ + 'USERNAME' => html_entity_decode($user_row['username'], ENT_COMPAT), + 'U_USER_DETAILS' => $board_url . "/memberlist.$phpEx?mode=viewprofile&u={$user_row['user_id']}", + 'U_ACTIVATE' => $board_url . "/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k={$user_row['user_actkey']}", + ]); - $messenger_method->send(); - } + $messenger_method->send(); } } $db->sql_freeresult($result); diff --git a/phpBB/phpbb/db/migration/data/v400/remove_jabber.php b/phpBB/phpbb/db/migration/data/v400/remove_jabber.php index 994f8c0167..c297ef0a8a 100644 --- a/phpBB/phpbb/db/migration/data/v400/remove_jabber.php +++ b/phpBB/phpbb/db/migration/data/v400/remove_jabber.php @@ -69,7 +69,7 @@ class remove_jabber extends migration ]], ['permission.remove', ['a_jabber']], ['permission.remove', ['u_sendim']], - ['custom', [[$this, 'remove_from_user_notifcations']]], + ['custom', [[$this, 'move_jabber_to_email_notifications']]], ]; } @@ -101,10 +101,15 @@ class remove_jabber extends migration ]; } - public function remove_from_user_notifcations() + public function move_jabber_to_email_notifications(int $start = 0) { - $sql = 'DELETE FROM ' . $this->table_prefix . 'user_notifications - WHERE notification_method = ' . $this->db->sql_escape('notification.method.jabber'); - $this->db->sql_query($sql); + $limit = 1000; + + $sql = 'UPDATE ' . $this->tables['user_notifications'] . ' + SET ' . $this->db->sql_build_array('UPDATE', ['method' => 'notification.method.email']) . " + WHERE method = 'notification.method.jabber'"; + $this->db->sql_query_limit($sql, $limit, $start); + + return $this->db->sql_affectedrows() < $limit ? true : $start + $limit; } } diff --git a/phpBB/phpbb/db/migration/data/v400/remove_notify_type.php b/phpBB/phpbb/db/migration/data/v400/remove_notify_type.php new file mode 100644 index 0000000000..a4b3cce8ed --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v400/remove_notify_type.php @@ -0,0 +1,64 @@ + + * @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\db\migration\data\v400; + +use phpbb\db\migration\migration; + +class remove_notify_type extends migration +{ + public static function depends_on(): array + { + return [ + '\phpbb\db\migration\data\v400\remove_jabber', + '\phpbb\db\migration\data\v400\dev', + '\phpbb\db\migration\data\v30x\release_3_0_0', + ]; + } + + public function update_schema(): array + { + return [ + 'drop_columns' => [ + $this->table_prefix . 'users' => [ + 'user_notify_type', + ], + ] + ]; + } + + public function revert_schema(): array + { + return [ + 'add_columns' => [ + $this->table_prefix . 'users' => [ + 'user_notify_type' => ['TINT:4', 0], + ], + ] + ]; + } + + public function update_data() + { + return [ + ['custom', [[$this, 'remove_jabber_user_notifications']]], + ]; + } + + protected function remove_jabber_user_notifications(): void + { + $sql = 'DELETE FROM ' . $this->tables['user_notifications'] . " + WHERE method = 'notification.method.jabber'"; + $this->db->sql_query($sql); + } +} diff --git a/phpBB/phpbb/message/admin_form.php b/phpBB/phpbb/message/admin_form.php index 72beaa38a6..e6e64210d8 100644 --- a/phpBB/phpbb/message/admin_form.php +++ b/phpBB/phpbb/message/admin_form.php @@ -157,7 +157,6 @@ class admin_form extends form } $this->message->set_sender($this->user->ip, $this->sender_name, $this->sender_address, $this->user->lang_name); - $this->message->set_sender_notify_type(messenger_interface::NOTIFY_EMAIL); } $this->message->set_template('contact_admin'); diff --git a/phpBB/phpbb/message/message.php b/phpBB/phpbb/message/message.php index 344c2f1cf2..9eae8719a4 100644 --- a/phpBB/phpbb/message/message.php +++ b/phpBB/phpbb/message/message.php @@ -54,9 +54,6 @@ class message /** @var string */ protected $sender_username = ''; - /** @var int */ - protected $sender_notify_type = messenger_interface::NOTIFY_EMAIL; - /** @var array */ protected $recipients; @@ -126,7 +123,6 @@ class message $user['username'], $user['user_email'], $user['user_lang'], - $user['user_notify_type'], $user['username'] ); } @@ -137,18 +133,16 @@ class message * @param string $recipient_name Displayed sender name * @param string $recipient_address Email address * @param string $recipient_lang - * @param int $recipient_notify_type Used notification methods (Jabber, Email, ...) * @param string $recipient_username User Name (used for AntiAbuse header) * @return void */ - public function add_recipient($recipient_name, $recipient_address, $recipient_lang, $recipient_notify_type = messenger_interface::NOTIFY_EMAIL, $recipient_username = '') + public function add_recipient($recipient_name, $recipient_address, $recipient_lang, $recipient_username = '') { $this->recipients[] = array( 'name' => $recipient_name, 'user_email' => $recipient_address, 'lang' => $recipient_lang, 'username' => $recipient_username, - 'notify_type' => $recipient_notify_type, 'to_name' => $recipient_name, ); } @@ -169,8 +163,6 @@ class message $user->data['user_id'], $user->data['username'] ); - - $this->set_sender_notify_type($user->data['user_notify_type']); } /** @@ -194,17 +186,6 @@ class message $this->sender_username = $sender_username; } - /** - * Which notification type should be used? Jabber, Email, ...? - * - * @param int $sender_notify_type - * @return void - */ - public function set_sender_notify_type($sender_notify_type) - { - $this->sender_notify_type = $sender_notify_type; - } - /** * Ok, now the same email if CC specified, but without exposing the user's email address * @@ -226,7 +207,6 @@ class message 'user_email' => $this->sender_address, 'name' => $this->sender_name, 'username' => $this->sender_username, - 'notify_type' => $this->sender_notify_type, 'to_name' => $this->recipients[0]['to_name'], ); } @@ -257,40 +237,37 @@ class message foreach ($messenger_collection_iterator as $messenger_method) { $messenger_method->set_use_queue(false); - if ($messenger_method->get_id() == $recipient['notify_type'] || $recipient['notify_type'] == $messenger_method::NOTIFY_BOTH) + $messenger_method->template($this->template, $recipient['lang']); + $messenger_method->set_addresses($recipient); + $messenger_method->reply_to($this->sender_address); + + $messenger_method->header('X-AntiAbuse', 'Board servername - ' . $this->server_name); + $messenger_method->header('X-AntiAbuse', 'User IP - ' . $this->sender_ip); + if ($this->sender_id) { - $messenger_method->template($this->template, $recipient['lang']); - $messenger_method->set_addresses($recipient); - $messenger_method->reply_to($this->sender_address); - - $messenger_method->header('X-AntiAbuse', 'Board servername - ' . $this->server_name); - $messenger_method->header('X-AntiAbuse', 'User IP - ' . $this->sender_ip); - if ($this->sender_id) - { - $messenger_method->header('X-AntiAbuse', 'User_id - ' . $this->sender_id); - } - - if ($this->sender_username) - { - $messenger_method->header('X-AntiAbuse', 'Username - ' . $this->sender_username); - } - - $messenger_method->subject(html_entity_decode($this->subject, ENT_COMPAT)); - - $messenger_method->assign_vars([ - 'BOARD_CONTACT' => $contact, - 'TO_USERNAME' => html_entity_decode($recipient['to_name'], ENT_COMPAT), - 'FROM_USERNAME' => html_entity_decode($this->sender_name, ENT_COMPAT), - 'MESSAGE' => html_entity_decode($this->body, ENT_COMPAT), - ]); - - if (count($this->template_vars)) - { - $messenger_method->assign_vars($this->template_vars); - } - - $messenger_method->send(); + $messenger_method->header('X-AntiAbuse', 'User_id - ' . $this->sender_id); } + + if ($this->sender_username) + { + $messenger_method->header('X-AntiAbuse', 'Username - ' . $this->sender_username); + } + + $messenger_method->subject(html_entity_decode($this->subject, ENT_COMPAT)); + + $messenger_method->assign_vars([ + 'BOARD_CONTACT' => $contact, + 'TO_USERNAME' => html_entity_decode($recipient['to_name'], ENT_COMPAT), + 'FROM_USERNAME' => html_entity_decode($this->sender_name, ENT_COMPAT), + 'MESSAGE' => html_entity_decode($this->body, ENT_COMPAT), + ]); + + if (count($this->template_vars)) + { + $messenger_method->assign_vars($this->template_vars); + } + + $messenger_method->send(); } } } diff --git a/phpBB/phpbb/message/topic_form.php b/phpBB/phpbb/message/topic_form.php index dd73a67ab2..8141a66b62 100644 --- a/phpBB/phpbb/message/topic_form.php +++ b/phpBB/phpbb/message/topic_form.php @@ -134,7 +134,6 @@ class topic_form extends form $this->recipient_lang, messenger_interface::NOTIFY_EMAIL ); - $this->message->set_sender_notify_type(messenger_interface::NOTIFY_EMAIL); parent::submit($messenger); } diff --git a/phpBB/phpbb/message/user_form.php b/phpBB/phpbb/message/user_form.php index f52eabc7e9..69189a81f1 100644 --- a/phpBB/phpbb/message/user_form.php +++ b/phpBB/phpbb/message/user_form.php @@ -34,7 +34,7 @@ class user_form extends form */ protected function get_user_row($user_id) { - $sql = 'SELECT user_id, username, user_colour, user_email, user_allow_viewemail, user_lang, user_notify_type + $sql = 'SELECT user_id, username, user_colour, user_email, user_allow_viewemail, user_lang FROM ' . USERS_TABLE . ' WHERE user_id = ' . (int) $user_id . ' AND user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')'; diff --git a/phpBB/phpbb/ucp/controller/reset_password.php b/phpBB/phpbb/ucp/controller/reset_password.php index d9ec05316c..790e00138c 100644 --- a/phpBB/phpbb/ucp/controller/reset_password.php +++ b/phpBB/phpbb/ucp/controller/reset_password.php @@ -176,7 +176,7 @@ class reset_password } $sql_array = [ - 'SELECT' => 'user_id, username, user_permissions, user_email, user_notify_type, user_type,' + 'SELECT' => 'user_id, username, user_permissions, user_email, user_type,' . ' user_lang, user_inactive_reason, reset_token, reset_token_expiration', 'FROM' => [$this->users_table => 'u'], 'WHERE' => "user_email = '" . $this->db->sql_escape($email) . "'" . @@ -308,7 +308,7 @@ class reset_password add_form_key('ucp_reset_password'); $sql_array = [ - 'SELECT' => 'user_id, username, user_permissions, user_email, user_notify_type, user_type,' + 'SELECT' => 'user_id, username, user_permissions, user_email, user_type,' . ' user_lang, user_inactive_reason, reset_token, reset_token_expiration', 'FROM' => [$this->users_table => 'u'], 'WHERE' => 'user_id = ' . $user_id, diff --git a/tests/auth/provider_apache_test.php b/tests/auth/provider_apache_test.php index 3604bbf9cd..2fcb5b8484 100644 --- a/tests/auth/provider_apache_test.php +++ b/tests/auth/provider_apache_test.php @@ -152,7 +152,6 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case 'user_post_sortby_dir' => 'a', 'user_notify' => 0, 'user_notify_pm' => 1, - 'user_notify_type' => 0, 'user_allow_pm' => 1, 'user_allow_viewonline' => 1, 'user_allow_viewemail' => 1, diff --git a/tests/functional/user_password_reset_test.php b/tests/functional/user_password_reset_test.php index 7e15aca56f..cf0f903817 100644 --- a/tests/functional/user_password_reset_test.php +++ b/tests/functional/user_password_reset_test.php @@ -263,7 +263,7 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca protected function get_user_data($username) { $db = $this->get_db(); - $sql = 'SELECT user_id, username, user_type, user_email, user_newpasswd, user_lang, user_notify_type, user_actkey, user_inactive_reason, reset_token, reset_token_expiration + $sql = 'SELECT user_id, username, user_type, user_email, user_newpasswd, user_lang, user_actkey, user_inactive_reason, reset_token, reset_token_expiration FROM ' . USERS_TABLE . " WHERE username = '" . $db->sql_escape($username) . "'"; $result = $db->sql_query($sql); diff --git a/tests/notification/convert_test.php b/tests/notification/convert_test.php index 0def0be5ed..6c1f7b496e 100644 --- a/tests/notification/convert_test.php +++ b/tests/notification/convert_test.php @@ -30,15 +30,33 @@ class phpbb_notification_convert_test extends phpbb_database_test_case $this->db = $this->new_dbal(); $this->doctrine_db = $this->new_doctrine_dbal(); $factory = new \phpbb\db\tools\factory(); + $db_tools = $factory->get($this->doctrine_db); + $core_tables = self::get_core_tables(); + + // Add user_notify_type column for testing this migration and set type + $db_tools->sql_column_add($core_tables['users'], 'user_notify_type', ['TINT:4', 0]); + $user_notify_type_map = [ + 1 => 0, + 2 => 0, + 3 => 1, + 4 => 1, + 5 => 2, + 6 => 2, + ]; + + foreach ($user_notify_type_map as $user_id => $notify_type) + { + $this->db->sql_query('UPDATE ' . $core_tables['users'] . ' SET user_notify_type = ' . (int) $notify_type . ' WHERE user_id = ' . (int) $user_id); + } $this->migration = new \phpbb\db\migration\data\v310\notification_options_reconvert( new \phpbb\config\config(array()), $this->db, - $factory->get($this->doctrine_db), + $db_tools, $phpbb_root_path, $phpEx, 'phpbb_', - self::get_core_tables() + $core_tables ); } diff --git a/tests/notification/fixtures/convert.xml b/tests/notification/fixtures/convert.xml index c9d8fafa97..9b357504d1 100644 --- a/tests/notification/fixtures/convert.xml +++ b/tests/notification/fixtures/convert.xml @@ -4,7 +4,6 @@ user_id username username_clean - user_notify_type user_notify_pm user_permissions user_sig @@ -13,7 +12,6 @@ 1 1 0 - 0 @@ -21,7 +19,6 @@ 2 2 2 - 0 1 @@ -30,7 +27,6 @@ 3 3 3 - 1 0 @@ -40,7 +36,6 @@ 4 4 1 - 1 @@ -48,7 +43,6 @@ 5 5 5 - 2 0 @@ -57,7 +51,6 @@ 6 6 6 - 2 1 From d985c8be60031435fb804157ff6a720d688e59b5 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 18 Apr 2025 17:20:25 +0200 Subject: [PATCH 13/23] [ticket/17493] Remove unused notify type in add_recipient PHPBB-17493 --- phpBB/phpbb/message/admin_form.php | 3 +-- phpBB/phpbb/message/topic_form.php | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/phpBB/phpbb/message/admin_form.php b/phpBB/phpbb/message/admin_form.php index e6e64210d8..ac03558f74 100644 --- a/phpBB/phpbb/message/admin_form.php +++ b/phpBB/phpbb/message/admin_form.php @@ -165,8 +165,7 @@ class admin_form extends form $this->message->add_recipient( $this->user->lang['ADMINISTRATOR'], $this->config['board_contact'], - $this->config['default_lang'], - messenger_interface::NOTIFY_EMAIL + $this->config['default_lang'] ); $this->message->set_template_vars(array( diff --git a/phpBB/phpbb/message/topic_form.php b/phpBB/phpbb/message/topic_form.php index 8141a66b62..8386eff89a 100644 --- a/phpBB/phpbb/message/topic_form.php +++ b/phpBB/phpbb/message/topic_form.php @@ -131,8 +131,7 @@ class topic_form extends form $this->message->add_recipient( $this->recipient_name, $this->recipient_address, - $this->recipient_lang, - messenger_interface::NOTIFY_EMAIL + $this->recipient_lang ); parent::submit($messenger); From 5ab0446eb188be36b9bc0796d8a3a7252d3b1565 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 18 Apr 2025 19:49:57 +0200 Subject: [PATCH 14/23] [ticket/17493] Remove unused use statements PHPBB-17493 --- phpBB/phpbb/message/admin_form.php | 2 -- phpBB/phpbb/message/topic_form.php | 2 -- 2 files changed, 4 deletions(-) diff --git a/phpBB/phpbb/message/admin_form.php b/phpBB/phpbb/message/admin_form.php index ac03558f74..30c863bb7f 100644 --- a/phpBB/phpbb/message/admin_form.php +++ b/phpBB/phpbb/message/admin_form.php @@ -13,8 +13,6 @@ namespace phpbb\message; -use phpbb\messenger\method\messenger_interface; - /** * Class admin_form * Displays a message to the user and allows him to send an email diff --git a/phpBB/phpbb/message/topic_form.php b/phpBB/phpbb/message/topic_form.php index 8386eff89a..15a4f30ac2 100644 --- a/phpBB/phpbb/message/topic_form.php +++ b/phpBB/phpbb/message/topic_form.php @@ -13,8 +13,6 @@ namespace phpbb\message; -use phpbb\messenger\method\messenger_interface; - /** * Class topic_form * Form used to send topics as notification emails From 27550ce59b8a66a6f1a988b8471711b630eaf745 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 20 Apr 2025 07:55:28 +0200 Subject: [PATCH 15/23] [ticket/17493] Remove not needed function in migration and fix type hinting PHPBB-17493 --- .../phpbb/db/migration/data/v400/remove_jabber.php | 2 +- .../db/migration/data/v400/remove_notify_type.php | 14 -------------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/phpBB/phpbb/db/migration/data/v400/remove_jabber.php b/phpBB/phpbb/db/migration/data/v400/remove_jabber.php index c297ef0a8a..5ff6b1e9b5 100644 --- a/phpBB/phpbb/db/migration/data/v400/remove_jabber.php +++ b/phpBB/phpbb/db/migration/data/v400/remove_jabber.php @@ -101,7 +101,7 @@ class remove_jabber extends migration ]; } - public function move_jabber_to_email_notifications(int $start = 0) + public function move_jabber_to_email_notifications(?int $start = 0) { $limit = 1000; diff --git a/phpBB/phpbb/db/migration/data/v400/remove_notify_type.php b/phpBB/phpbb/db/migration/data/v400/remove_notify_type.php index a4b3cce8ed..7ed606cd80 100644 --- a/phpBB/phpbb/db/migration/data/v400/remove_notify_type.php +++ b/phpBB/phpbb/db/migration/data/v400/remove_notify_type.php @@ -47,18 +47,4 @@ class remove_notify_type extends migration ] ]; } - - public function update_data() - { - return [ - ['custom', [[$this, 'remove_jabber_user_notifications']]], - ]; - } - - protected function remove_jabber_user_notifications(): void - { - $sql = 'DELETE FROM ' . $this->tables['user_notifications'] . " - WHERE method = 'notification.method.jabber'"; - $this->db->sql_query($sql); - } } From 54d8a49e7000dc57f28ee99cd37d35a0271b4a45 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 20 Apr 2025 07:58:53 +0200 Subject: [PATCH 16/23] [ticket/17493] Improve handling of nullable start parameter PHPBB-17493 --- phpBB/phpbb/db/migration/data/v400/remove_jabber.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/phpbb/db/migration/data/v400/remove_jabber.php b/phpBB/phpbb/db/migration/data/v400/remove_jabber.php index 5ff6b1e9b5..b82fdfc8db 100644 --- a/phpBB/phpbb/db/migration/data/v400/remove_jabber.php +++ b/phpBB/phpbb/db/migration/data/v400/remove_jabber.php @@ -101,14 +101,14 @@ class remove_jabber extends migration ]; } - public function move_jabber_to_email_notifications(?int $start = 0) + public function move_jabber_to_email_notifications(?int $start) { $limit = 1000; $sql = 'UPDATE ' . $this->tables['user_notifications'] . ' SET ' . $this->db->sql_build_array('UPDATE', ['method' => 'notification.method.email']) . " WHERE method = 'notification.method.jabber'"; - $this->db->sql_query_limit($sql, $limit, $start); + $this->db->sql_query_limit($sql, $limit, $start ?: 0); return $this->db->sql_affectedrows() < $limit ? true : $start + $limit; } From 52f04a3c2c4ae255633e23edb95f97b42d7eb5a8 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 20 Apr 2025 08:53:14 +0200 Subject: [PATCH 17/23] [ticket/17493] Remove "short" email templates as they were jabber only PHPBB-17493 --- phpBB/language/en/email/short/bookmark.txt | 13 ------------- phpBB/language/en/email/short/newtopic_notify.txt | 11 ----------- phpBB/language/en/email/short/post_approved.txt | 13 ------------- phpBB/language/en/email/short/post_disapproved.txt | 11 ----------- phpBB/language/en/email/short/post_in_queue.txt | 13 ------------- phpBB/language/en/email/short/privmsg_notify.txt | 13 ------------- phpBB/language/en/email/short/quote.txt | 13 ------------- phpBB/language/en/email/short/report_pm.txt | 10 ---------- phpBB/language/en/email/short/report_post.txt | 13 ------------- phpBB/language/en/email/short/topic_approved.txt | 10 ---------- phpBB/language/en/email/short/topic_disapproved.txt | 11 ----------- phpBB/language/en/email/short/topic_in_queue.txt | 13 ------------- phpBB/language/en/email/short/topic_notify.txt | 13 ------------- 13 files changed, 157 deletions(-) delete mode 100644 phpBB/language/en/email/short/bookmark.txt delete mode 100644 phpBB/language/en/email/short/newtopic_notify.txt delete mode 100644 phpBB/language/en/email/short/post_approved.txt delete mode 100644 phpBB/language/en/email/short/post_disapproved.txt delete mode 100644 phpBB/language/en/email/short/post_in_queue.txt delete mode 100644 phpBB/language/en/email/short/privmsg_notify.txt delete mode 100644 phpBB/language/en/email/short/quote.txt delete mode 100644 phpBB/language/en/email/short/report_pm.txt delete mode 100644 phpBB/language/en/email/short/report_post.txt delete mode 100644 phpBB/language/en/email/short/topic_approved.txt delete mode 100644 phpBB/language/en/email/short/topic_disapproved.txt delete mode 100644 phpBB/language/en/email/short/topic_in_queue.txt delete mode 100644 phpBB/language/en/email/short/topic_notify.txt diff --git a/phpBB/language/en/email/short/bookmark.txt b/phpBB/language/en/email/short/bookmark.txt deleted file mode 100644 index 963b644415..0000000000 --- a/phpBB/language/en/email/short/bookmark.txt +++ /dev/null @@ -1,13 +0,0 @@ -Subject: Reply in "{TOPIC_TITLE}" - -Hello {USERNAME}, - -Your bookmarked topic "{TOPIC_TITLE}" received a new reply since your last visit to "{SITENAME}". No more notifications will be sent until you visit the topic. - -If you want to view the newest post made since your last visit, click the following link: -{U_NEWEST_POST} - -If you no longer wish to receive updates about replies to bookmarks, please update your notification settings here: -{U_NOTIFICATION_SETTINGS} - -{EMAIL_SIG} diff --git a/phpBB/language/en/email/short/newtopic_notify.txt b/phpBB/language/en/email/short/newtopic_notify.txt deleted file mode 100644 index e8f8c25b9e..0000000000 --- a/phpBB/language/en/email/short/newtopic_notify.txt +++ /dev/null @@ -1,11 +0,0 @@ -Subject: New topic in "{FORUM_NAME}" - -Hello {USERNAME}, - -The forum "{FORUM_NAME}" received a new topic "{TOPIC_TITLE}" by {AUTHOR_NAME} since your last visit to "{SITENAME}". No more notifications will be sent until you visit the forum. -{U_FORUM} - -If you no longer wish to watch this forum click the following link: -{U_STOP_WATCHING_FORUM} - -{EMAIL_SIG} diff --git a/phpBB/language/en/email/short/post_approved.txt b/phpBB/language/en/email/short/post_approved.txt deleted file mode 100644 index 87e8acebb6..0000000000 --- a/phpBB/language/en/email/short/post_approved.txt +++ /dev/null @@ -1,13 +0,0 @@ -Subject: Post approved - "{POST_SUBJECT}" - -Hello {USERNAME}, - -Your post "{POST_SUBJECT}" at "{SITENAME}" was approved by a moderator or administrator. - -If you want to view the post, click the following link: -{U_VIEW_POST} - -If you want to view the topic, click the following link: -{U_VIEW_TOPIC} - -{EMAIL_SIG} diff --git a/phpBB/language/en/email/short/post_disapproved.txt b/phpBB/language/en/email/short/post_disapproved.txt deleted file mode 100644 index 11a0564cb8..0000000000 --- a/phpBB/language/en/email/short/post_disapproved.txt +++ /dev/null @@ -1,11 +0,0 @@ -Subject: Post disapproved - "{POST_SUBJECT}" - -Hello {USERNAME}, - -Your post "{POST_SUBJECT}" at "{SITENAME}" was disapproved by a moderator or administrator. - -The following reason was given for the disapproval: - -{REASON} - -{EMAIL_SIG} diff --git a/phpBB/language/en/email/short/post_in_queue.txt b/phpBB/language/en/email/short/post_in_queue.txt deleted file mode 100644 index 8ccbc8e9bb..0000000000 --- a/phpBB/language/en/email/short/post_in_queue.txt +++ /dev/null @@ -1,13 +0,0 @@ -Subject: Post needs approval - "{TOPIC_TITLE}" - -Hello {USERNAME}, - -The post "{POST_SUBJECT}" at "{SITENAME}" needs approval. - -If you want to view the post, click the following link: -{U_VIEW_POST} - -If you want to view the topic, click the following link: -{U_TOPIC} - -{EMAIL_SIG} diff --git a/phpBB/language/en/email/short/privmsg_notify.txt b/phpBB/language/en/email/short/privmsg_notify.txt deleted file mode 100644 index 0c579fa51c..0000000000 --- a/phpBB/language/en/email/short/privmsg_notify.txt +++ /dev/null @@ -1,13 +0,0 @@ -Subject: New private message - -Hello {USERNAME}, - -A new private message from "{AUTHOR_NAME}" to your account on "{SITENAME}" with the following subject has arrived: -{SUBJECT} - -You can view your new message by clicking on the following link: -{U_VIEW_MESSAGE} - -You have requested that you be notified on this event, remember that you can always choose not to be notified of new messages by changing the appropriate setting in your profile. - -{EMAIL_SIG} diff --git a/phpBB/language/en/email/short/quote.txt b/phpBB/language/en/email/short/quote.txt deleted file mode 100644 index 871f471037..0000000000 --- a/phpBB/language/en/email/short/quote.txt +++ /dev/null @@ -1,13 +0,0 @@ -Subject: Quoted in "{TOPIC_TITLE}" - -Hello {USERNAME}, - -"{AUTHOR_NAME}" quoted you in the topic "{TOPIC_TITLE}" at "{SITENAME}". - -If you want to view the quoted post, click the following link: -{U_VIEW_POST} - -If you no longer wish to receive updates about replies quoting you, please update your notification settings here: -{U_NOTIFICATION_SETTINGS} - -{EMAIL_SIG} diff --git a/phpBB/language/en/email/short/report_pm.txt b/phpBB/language/en/email/short/report_pm.txt deleted file mode 100644 index 771646046b..0000000000 --- a/phpBB/language/en/email/short/report_pm.txt +++ /dev/null @@ -1,10 +0,0 @@ -Subject: Private Message report - "{SUBJECT}" - -Hello {USERNAME}, - -A Private Message titled "{SUBJECT}" by "{AUTHOR_NAME}" at "{SITENAME}" was reported. - -If you want to view the report, click the following link: -{U_VIEW_REPORT} - -{EMAIL_SIG} diff --git a/phpBB/language/en/email/short/report_post.txt b/phpBB/language/en/email/short/report_post.txt deleted file mode 100644 index 1e50af1615..0000000000 --- a/phpBB/language/en/email/short/report_post.txt +++ /dev/null @@ -1,13 +0,0 @@ -Subject: Post report - "{TOPIC_TITLE}" - -Hello {USERNAME}, - -The post "{POST_SUBJECT}" at "{SITENAME}" was reported. - -If you want to view the report, click the following link: -{U_VIEW_REPORT} - -If you want to view the post, click the following link: -{U_VIEW_POST} - -{EMAIL_SIG} diff --git a/phpBB/language/en/email/short/topic_approved.txt b/phpBB/language/en/email/short/topic_approved.txt deleted file mode 100644 index 132a15ea24..0000000000 --- a/phpBB/language/en/email/short/topic_approved.txt +++ /dev/null @@ -1,10 +0,0 @@ -Subject: Topic approved - "{TOPIC_TITLE}" - -Hello {USERNAME}, - -Your topic "{TOPIC_TITLE}" at "{SITENAME}" was approved by a moderator or administrator. - -If you want to view the topic, click the following link: -{U_VIEW_TOPIC} - -{EMAIL_SIG} diff --git a/phpBB/language/en/email/short/topic_disapproved.txt b/phpBB/language/en/email/short/topic_disapproved.txt deleted file mode 100644 index dfb0f29228..0000000000 --- a/phpBB/language/en/email/short/topic_disapproved.txt +++ /dev/null @@ -1,11 +0,0 @@ -Subject: Topic disapproved - "{TOPIC_TITLE}" - -Hello {USERNAME}, - -Your topic "{TOPIC_TITLE}" at "{SITENAME}" was disapproved by a moderator or administrator. - -The following reason was given for the disapproval: - -{REASON} - -{EMAIL_SIG} diff --git a/phpBB/language/en/email/short/topic_in_queue.txt b/phpBB/language/en/email/short/topic_in_queue.txt deleted file mode 100644 index f4ed7b2ace..0000000000 --- a/phpBB/language/en/email/short/topic_in_queue.txt +++ /dev/null @@ -1,13 +0,0 @@ -Subject: Topic needs approval - "{TOPIC_TITLE}" - -Hello {USERNAME}, - -The topic "{TOPIC_TITLE}" at "{SITENAME}" needs approval. - -If you want to view the topic, click the following link: -{U_VIEW_TOPIC} - -If you want to view the forum, click the following link: -{U_FORUM} - -{EMAIL_SIG} diff --git a/phpBB/language/en/email/short/topic_notify.txt b/phpBB/language/en/email/short/topic_notify.txt deleted file mode 100644 index d92b342f33..0000000000 --- a/phpBB/language/en/email/short/topic_notify.txt +++ /dev/null @@ -1,13 +0,0 @@ -Subject: Reply in "{TOPIC_TITLE}" - -Hello {USERNAME}, - -The topic "{TOPIC_TITLE}" received a new reply by {AUTHOR_NAME} since your last visit to "{SITENAME}". No more emails will be sent until you visit the topic. - -If you want to view the newest post made since your last visit, click the following link: -{U_NEWEST_POST} - -If you no longer wish to watch this topic click the following link: -{U_STOP_WATCHING_TOPIC} - -{EMAIL_SIG} From bde52e28f8765a73265b1ff76bce1c117a73c442 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 21 Apr 2025 11:44:49 +0200 Subject: [PATCH 18/23] [ticket/17493] Move cpf update outside if PHPBB-17493 --- phpBB/includes/ucp/ucp_profile.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index a5a1fe3d70..93f98d613f 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -383,11 +383,11 @@ class ucp_profile SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $user->data['user_id']; $db->sql_query($sql); - - // Update Custom Fields - $cp->update_profile_field_data($user->data['user_id'], $cp_data); } + // Always update custom fields + $cp->update_profile_field_data($user->data['user_id'], $cp_data); + meta_refresh(3, $this->u_action); $message = $user->lang['PROFILE_UPDATED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); trigger_error($message); From 3caab55e819772bfad43960901a3898f10405c4b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 21 Apr 2025 15:16:41 +0200 Subject: [PATCH 19/23] [ticket/17493] Remove remnants of notify type PHPBB-17493 --- phpBB/includes/acp/acp_users.php | 3 --- phpBB/includes/constants.php | 8 -------- phpBB/includes/ucp/ucp_prefs.php | 3 --- phpBB/install/convertors/convert_phpbb20.php | 1 - .../data/v310/notification_options_reconvert.php | 8 ++++++-- phpBB/phpbb/messenger/method/email.php | 8 -------- .../messenger/method/messenger_interface.php | 16 ---------------- phpBB/phpbb/notification/method/email.php | 2 +- .../phpbb/notification/method/messenger_base.php | 6 +++--- tests/messenger/method_email_test.php | 1 - 10 files changed, 10 insertions(+), 46 deletions(-) diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 42d0338ba2..6abf55ebc8 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1784,9 +1784,6 @@ class acp_users 'MASS_EMAIL' => $data['massemail'], 'ALLOW_PM' => $data['allowpm'], 'HIDE_ONLINE' => $data['hideonline'], - 'NOTIFY_EMAIL' => ($data['notifymethod'] == messenger_interface::NOTIFY_EMAIL) ? true : false, - 'NOTIFY_IM' => ($data['notifymethod'] == messenger_interface::NOTIFY_IM) ? true : false, - 'NOTIFY_BOTH' => ($data['notifymethod'] == messenger_interface::NOTIFY_BOTH) ? true : false, 'NOTIFY_PM' => $data['notifypm'], 'BBCODE' => $data['bbcode'], 'SMILIES' => $data['smilies'], diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index e9890d27e1..e8b77ab2ce 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -119,14 +119,6 @@ define('POST_STICKY', 1); define('POST_ANNOUNCE', 2); define('POST_GLOBAL', 3); -// Notify methods -/** @deprecated 4.0.0-a1 Replaced by \phpbb\messenger\method\messenger_interface::NOTIFY_EMAIL, to be removed in 5.0.0-a1 */ -define('NOTIFY_EMAIL', 0); -/** @deprecated 4.0.0-a1 Replaced by \phpbb\messenger\method\messenger_interface::NOTIFY_IM, to be removed in 5.0.0-a1 */ -define('NOTIFY_IM', 1); -/** @deprecated 4.0.0-a1 Replaced by \phpbb\messenger\method\messenger_interface::NOTIFY_BOTH, to be removed in 5.0.0-a1 */ -define('NOTIFY_BOTH', 2); - // Notify status define('NOTIFY_YES', 0); define('NOTIFY_NO', 1); diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php index 86440cd714..a5794870b7 100644 --- a/phpBB/includes/ucp/ucp_prefs.php +++ b/phpBB/includes/ucp/ucp_prefs.php @@ -176,9 +176,6 @@ class ucp_prefs $template->assign_vars([ 'ERROR' => (count($error)) ? implode('
', $error) : '', - 'S_NOTIFY_EMAIL' => ($data['notifymethod'] == messenger_interface::NOTIFY_EMAIL) ? true : false, - 'S_NOTIFY_IM' => ($data['notifymethod'] == messenger_interface::NOTIFY_IM) ? true : false, - 'S_NOTIFY_BOTH' => ($data['notifymethod'] == messenger_interface::NOTIFY_BOTH) ? true : false, 'S_VIEW_EMAIL' => $data['viewemail'], 'S_MASS_EMAIL' => $data['massemail'], 'S_ALLOW_PM' => $data['allowpm'], diff --git a/phpBB/install/convertors/convert_phpbb20.php b/phpBB/install/convertors/convert_phpbb20.php index cff03b712e..db5a38db1f 100644 --- a/phpBB/install/convertors/convert_phpbb20.php +++ b/phpBB/install/convertors/convert_phpbb20.php @@ -937,7 +937,6 @@ if (!$get_info) array('user_emailtime', 'users.user_emailtime', 'null_to_zero'), array('user_notify', 'users.user_notify', 'intval'), array('user_notify_pm', 'users.user_notify_pm', 'intval'), - array('user_notify_type', $messenger_method::NOTIFY_EMAIL, ''), array('user_allow_pm', 'users.user_allow_pm', 'intval'), array('user_allow_viewonline', 'users.user_allow_viewonline', 'intval'), array('user_allow_viewemail', 'users.user_viewemail', 'intval'), diff --git a/phpBB/phpbb/db/migration/data/v310/notification_options_reconvert.php b/phpBB/phpbb/db/migration/data/v310/notification_options_reconvert.php index 7f58076a8d..f2879f4d71 100644 --- a/phpBB/phpbb/db/migration/data/v310/notification_options_reconvert.php +++ b/phpBB/phpbb/db/migration/data/v310/notification_options_reconvert.php @@ -17,6 +17,10 @@ use phpbb\messenger\method\messenger_interface; class notification_options_reconvert extends \phpbb\db\migration\migration { + protected const NOTIFY_EMAIL = 0; + protected const NOTIFY_IM = 1; + protected const NOTIFY_BOTH = 2; + public static function depends_on() { return array('\phpbb\db\migration\data\v310\notifications_schema_fix'); @@ -69,12 +73,12 @@ class notification_options_reconvert extends \phpbb\db\migration\migration // In-board notification $notification_methods[] = ''; - if ($row['user_notify_type'] == messenger_interface::NOTIFY_EMAIL || $row['user_notify_type'] == messenger_interface::NOTIFY_BOTH) + if ($row['user_notify_type'] == self::NOTIFY_EMAIL || $row['user_notify_type'] == self::NOTIFY_BOTH) { $notification_methods[] = 'email'; } - if ($row['user_notify_type'] == messenger_interface::NOTIFY_IM || $row['user_notify_type'] == messenger_interface::NOTIFY_BOTH) + if ($row['user_notify_type'] == self::NOTIFY_IM || $row['user_notify_type'] == self::NOTIFY_BOTH) { $notification_methods[] = 'jabber'; } diff --git a/phpBB/phpbb/messenger/method/email.php b/phpBB/phpbb/messenger/method/email.php index 7bd92538c2..b601fca232 100644 --- a/phpBB/phpbb/messenger/method/email.php +++ b/phpBB/phpbb/messenger/method/email.php @@ -74,14 +74,6 @@ class email extends base /** @var AbstractTransport */ protected AbstractTransport $transport; - /** - * {@inheritDoc} - */ - public function get_id(): int - { - return self::NOTIFY_EMAIL; - } - /** * {@inheritDoc} */ diff --git a/phpBB/phpbb/messenger/method/messenger_interface.php b/phpBB/phpbb/messenger/method/messenger_interface.php index 6d82f89b6f..d9eb247f77 100644 --- a/phpBB/phpbb/messenger/method/messenger_interface.php +++ b/phpBB/phpbb/messenger/method/messenger_interface.php @@ -18,22 +18,6 @@ namespace phpbb\messenger\method; */ interface messenger_interface { - /** @var int Email notify method used */ - public const NOTIFY_EMAIL = 0; - - /** @var int Instant messaging (Jabber) notify method used */ - public const NOTIFY_IM = 1; - - /** @var int Both notify methods used */ - public const NOTIFY_BOTH = 2; - - /** - * Get messenger method id - * - * @return int - */ - public function get_id(): int; - /** * Check if the messenger method is enabled * diff --git a/phpBB/phpbb/notification/method/email.php b/phpBB/phpbb/notification/method/email.php index 8a2fff1bb9..8ef86f4599 100644 --- a/phpBB/phpbb/notification/method/email.php +++ b/phpBB/phpbb/notification/method/email.php @@ -136,7 +136,7 @@ class email extends \phpbb\notification\method\messenger_base $insert_buffer->flush(); - $this->notify_using_messenger(messenger_interface::NOTIFY_EMAIL); + $this->notify_using_messenger('messenger.method.email'); } /** diff --git a/phpBB/phpbb/notification/method/messenger_base.php b/phpBB/phpbb/notification/method/messenger_base.php index 165735e56c..616199519c 100644 --- a/phpBB/phpbb/notification/method/messenger_base.php +++ b/phpBB/phpbb/notification/method/messenger_base.php @@ -67,12 +67,12 @@ abstract class messenger_base extends \phpbb\notification\method\base /** * Notify using phpBB messenger * - * @param int $notify_method Notify method for messenger (e.g. \phpbb\messenger\method\messenger_interface::NOTIFY_IM) + * @param string $notify_method Notify method service for messenger (e.g. 'messenger.method.email'), empty string for all available methods * @param string $template_dir_prefix Base directory to prepend to the email template name * * @return void */ - protected function notify_using_messenger($notify_method, $template_dir_prefix = '') + protected function notify_using_messenger(string $notify_method, string $template_dir_prefix = ''): void { if (empty($this->queue)) { @@ -120,7 +120,7 @@ abstract class messenger_base extends \phpbb\notification\method\base */ foreach ($messenger_collection_iterator as $messenger_method) { - if ($messenger_method->get_id() == $notify_method || $notify_method == $messenger_method::NOTIFY_BOTH) + if (empty($notify_method) || $messenger_collection_iterator->key() == $notify_method) { $messenger_method->template($notification->get_email_template(), $user['user_lang'], '', $template_dir_prefix); $messenger_method->set_addresses($user); diff --git a/tests/messenger/method_email_test.php b/tests/messenger/method_email_test.php index c21a883f74..fe5c24808c 100644 --- a/tests/messenger/method_email_test.php +++ b/tests/messenger/method_email_test.php @@ -119,7 +119,6 @@ class phpbb_messenger_method_email_test extends \phpbb_test_case public function test_miscellaneous(): void { - $this->assertEquals(email::NOTIFY_EMAIL, $this->method_email->get_id()); $this->assertEquals('email', $this->method_email->get_queue_object_name()); $this->assertFalse($this->method_email->is_enabled()); $this->config->offsetSet('email_enable', true); From 3125f3e1d368a424ea6931aea352364d8e819a5c Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 21 Apr 2025 15:24:07 +0200 Subject: [PATCH 20/23] [ticket/17493] Remove unused methods and use statements PHPBB-17493 --- .../migration/data/v310/notification_options_reconvert.php | 2 -- phpBB/phpbb/messenger/method/base.php | 5 ----- phpBB/phpbb/notification/method/email.php | 3 +-- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/phpBB/phpbb/db/migration/data/v310/notification_options_reconvert.php b/phpBB/phpbb/db/migration/data/v310/notification_options_reconvert.php index f2879f4d71..c0b02bc496 100644 --- a/phpBB/phpbb/db/migration/data/v310/notification_options_reconvert.php +++ b/phpBB/phpbb/db/migration/data/v310/notification_options_reconvert.php @@ -13,8 +13,6 @@ namespace phpbb\db\migration\data\v310; -use phpbb\messenger\method\messenger_interface; - class notification_options_reconvert extends \phpbb\db\migration\migration { protected const NOTIFY_EMAIL = 0; diff --git a/phpBB/phpbb/messenger/method/base.php b/phpBB/phpbb/messenger/method/base.php index f3db4155ca..17213c6b3d 100644 --- a/phpBB/phpbb/messenger/method/base.php +++ b/phpBB/phpbb/messenger/method/base.php @@ -141,11 +141,6 @@ abstract class base implements messenger_interface $this->set_use_queue(); } - /** - * {@inheritdoc} - */ - abstract public function get_id(): int; - /** * {@inheritdoc} */ diff --git a/phpBB/phpbb/notification/method/email.php b/phpBB/phpbb/notification/method/email.php index 8ef86f4599..07ce0b4f06 100644 --- a/phpBB/phpbb/notification/method/email.php +++ b/phpBB/phpbb/notification/method/email.php @@ -19,14 +19,13 @@ use phpbb\user_loader; use phpbb\config\config; use phpbb\db\driver\driver_interface; use phpbb\di\service_collection; -use phpbb\messenger\method\messenger_interface; /** * Email notification method class * This class handles sending emails for notifications */ -class email extends \phpbb\notification\method\messenger_base +class email extends messenger_base { /** @var user */ protected $user; From 75a24ae4845ce3d60460afc7082dd1bbb12626f0 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 21 Apr 2025 15:42:59 +0200 Subject: [PATCH 21/23] [ticket/17493] Explicitly use email in acp/ucp modules PHPBB-17493 --- phpBB/includes/acp/acp_email.php | 53 +++++++++++++---------------- phpBB/includes/acp/acp_inactive.php | 34 ++++++++---------- phpBB/includes/ucp/ucp_activate.php | 29 +++++++--------- phpBB/includes/ucp/ucp_resend.php | 35 ++++++++----------- 4 files changed, 65 insertions(+), 86 deletions(-) diff --git a/phpBB/includes/acp/acp_email.php b/phpBB/includes/acp/acp_email.php index 5156676881..2d1b4b72dd 100644 --- a/phpBB/includes/acp/acp_email.php +++ b/phpBB/includes/acp/acp_email.php @@ -213,43 +213,38 @@ class acp_email ); extract($phpbb_dispatcher->trigger_event('core.acp_email_send_before', compact($vars))); - /** @var \phpbb\di\service_collection */ - $messenger = $phpbb_container->get('messenger.method_collection'); - $messenger_collection_iterator = $messenger->getIterator(); + /** @var \phpbb\di\service_collection $messenger_collection */ + $messenger_collection = $phpbb_container->get('messenger.method_collection'); + /** @var \phpbb\messenger\method\messenger_interface $messenger_method */ + $messenger_method = $messenger_collection->offsetGet('messenger.method.email'); + for ($i = 0, $size = count($email_list); $i < $size; $i++) { $used_lang = $email_list[$i][0]['lang']; - /** - * @var \phpbb\messenger\method\messenger_interface $messenger_method - * @psalm-suppress UndefinedMethod - */ - foreach ($messenger_collection_iterator as $messenger_method) + $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); + + for ($j = 0, $list_size = count($email_list[$i]); $j < $list_size; $j++) { - $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); - - 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); - - $errored = !$messenger_method->send() || $errored; - $messenger_method->save_queue(); } + + $messenger_method->anti_abuse_headers($config, $user); + $messenger_method->set_mail_priority($priority); + + $errored = !$messenger_method->send() || $errored; + $messenger_method->save_queue(); } unset($email_list); diff --git a/phpBB/includes/acp/acp_inactive.php b/phpBB/includes/acp/acp_inactive.php index b4b39cbdf9..35bbdf4e85 100644 --- a/phpBB/includes/acp/acp_inactive.php +++ b/phpBB/includes/acp/acp_inactive.php @@ -194,9 +194,10 @@ class acp_inactive $result = $db->sql_query($sql); - /** @var \phpbb\di\service_collection */ - $messenger = $phpbb_container->get('messenger.method_collection'); - $messenger_collection_iterator = $messenger->getIterator(); + /** @var \phpbb\di\service_collection $messenger_collection */ + $messenger_collection = $phpbb_container->get('messenger.method_collection'); + /** @var \phpbb\messenger\method\messenger_interface $messenger_method */ + $messenger_method = $messenger_collection->offsetGet('messenger.method.email'); if ($row = $db->sql_fetchrow($result)) { @@ -205,24 +206,17 @@ class acp_inactive do { - /** - * @var \phpbb\messenger\method\messenger_interface $messenger_method - * @psalm-suppress UndefinedMethod - */ - foreach ($messenger_collection_iterator as $messenger_method) - { - $messenger_method->template('user_remind_inactive', $row['user_lang']); - $messenger_method->set_addresses($row); - $messenger_method->anti_abuse_headers($config, $user); - $messenger_method->assign_vars([ - 'USERNAME' => html_entity_decode($row['username'], ENT_COMPAT), - 'REGISTER_DATE' => $user->format_date($row['user_regdate'], false, true), - 'U_ACTIVATE' => generate_board_url() . "/ucp.$phpEx?mode=activate&u=" . $row['user_id'] . '&k=' . $row['user_actkey'], - ]); + $messenger_method->template('user_remind_inactive', $row['user_lang']); + $messenger_method->set_addresses($row); + $messenger_method->anti_abuse_headers($config, $user); + $messenger_method->assign_vars([ + 'USERNAME' => html_entity_decode($row['username'], ENT_COMPAT), + 'REGISTER_DATE' => $user->format_date($row['user_regdate'], false, true), + 'U_ACTIVATE' => generate_board_url() . "/ucp.$phpEx?mode=activate&u=" . $row['user_id'] . '&k=' . $row['user_actkey'], + ]); - $messenger_method->send(); - $messenger_method->save_queue(); - } + $messenger_method->send(); + $messenger_method->save_queue(); $usernames[] = $row['username']; $user_ids[] = (int) $row['user_id']; diff --git a/phpBB/includes/ucp/ucp_activate.php b/phpBB/includes/ucp/ucp_activate.php index 50ccdfa7e6..5351e7c518 100644 --- a/phpBB/includes/ucp/ucp_activate.php +++ b/phpBB/includes/ucp/ucp_activate.php @@ -131,25 +131,20 @@ class ucp_activate $phpbb_notifications = $phpbb_container->get('notification_manager'); $phpbb_notifications->delete_notifications('notification.type.admin_activate_user', $user_row['user_id']); - $messenger = $phpbb_container->get('messenger.method_collection'); - $messenger_collection_iterator = $messenger->getIterator(); + /** @var \phpbb\di\service_collection $messenger_collection */ + $messenger_collection = $phpbb_container->get('messenger.method_collection'); + /** @var \phpbb\messenger\method\messenger_interface $messenger_method */ + $messenger_method = $messenger_collection->offsetGet('messenger.method.email'); - /** - * @var \phpbb\messenger\method\messenger_interface $messenger_method - * @psalm-suppress UndefinedMethod - */ - foreach ($messenger_collection_iterator as $messenger_method) - { - $messenger_method->set_use_queue(false); - $messenger_method->template('admin_welcome_activated', $user_row['user_lang']); - $messenger_method->set_addresses($user_row); - $messenger_method->anti_abuse_headers($config, $user); - $messenger_method->assign_vars([ - 'USERNAME' => html_entity_decode($user_row['username'], ENT_COMPAT), - ]); + $messenger_method->set_use_queue(false); + $messenger_method->template('admin_welcome_activated', $user_row['user_lang']); + $messenger_method->set_addresses($user_row); + $messenger_method->anti_abuse_headers($config, $user); + $messenger_method->assign_vars([ + 'USERNAME' => html_entity_decode($user_row['username'], ENT_COMPAT), + ]); - $messenger_method->send(); - } + $messenger_method->send(); $message = 'ACCOUNT_ACTIVE_ADMIN'; } diff --git a/phpBB/includes/ucp/ucp_resend.php b/phpBB/includes/ucp/ucp_resend.php index 023ea80852..c2debbbe27 100644 --- a/phpBB/includes/ucp/ucp_resend.php +++ b/phpBB/includes/ucp/ucp_resend.php @@ -133,29 +133,24 @@ class ucp_resend WHERE ' . $db->sql_in_set('user_id', $admin_ary[0]['a_user']); $result = $db->sql_query($sql); - /** @var \phpbb\di\service_collection */ - $messenger = $phpbb_container->get('messenger.method_collection'); - $messenger_collection_iterator = $messenger->getIterator(); + /** @var \phpbb\di\service_collection $messenger_collection */ + $messenger_collection = $phpbb_container->get('messenger.method_collection'); + /** @var \phpbb\messenger\method\messenger_interface $messenger_method */ + $messenger_method = $messenger_collection->offsetGet('messenger.method.email'); + while ($row = $db->sql_fetchrow($result)) { - /** - * @var \phpbb\messenger\method\messenger_interface $messenger_method - * @psalm-suppress UndefinedMethod - */ - foreach ($messenger_collection_iterator as $messenger_method) - { - $messenger_method->set_use_queue(false); - $messenger_method->template('admin_activate', $row['user_lang']); - $messenger_method->set_addresses($row); - $messenger_method->anti_abuse_headers($config, $user); - $messenger_method->assign_vars([ - 'USERNAME' => html_entity_decode($user_row['username'], ENT_COMPAT), - 'U_USER_DETAILS' => $board_url . "/memberlist.$phpEx?mode=viewprofile&u={$user_row['user_id']}", - 'U_ACTIVATE' => $board_url . "/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k={$user_row['user_actkey']}", - ]); + $messenger_method->set_use_queue(false); + $messenger_method->template('admin_activate', $row['user_lang']); + $messenger_method->set_addresses($row); + $messenger_method->anti_abuse_headers($config, $user); + $messenger_method->assign_vars([ + 'USERNAME' => html_entity_decode($user_row['username'], ENT_COMPAT), + 'U_USER_DETAILS' => $board_url . "/memberlist.$phpEx?mode=viewprofile&u={$user_row['user_id']}", + 'U_ACTIVATE' => $board_url . "/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k={$user_row['user_actkey']}", + ]); - $messenger_method->send(); - } + $messenger_method->send(); } $db->sql_freeresult($result); } From 83508b415b6ccb053dd6370dc6475cfb0adecf2f Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 24 Apr 2025 17:32:04 +0200 Subject: [PATCH 22/23] [ticket/17493] Remove more jabber remainders PHPBB-17493 --- phpBB/includes/functions_posting.php | 2 +- phpBB/includes/questionnaire/questionnaire.php | 3 --- phpBB/phpbb/messenger/queue.php | 4 ++-- phpBB/phpbb/notification/manager.php | 4 ++-- phpBB/phpbb/notification/method/messenger_base.php | 2 +- phpBB/phpbb/notification/type/base.php | 5 +---- phpBB/phpbb/notification/type/type_interface.php | 2 +- phpBB/styles/prosilver/template/ucp_pm_viewmessage.html | 2 +- phpBB/styles/prosilver/template/viewtopic_body.html | 2 +- 9 files changed, 10 insertions(+), 16 deletions(-) diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index f6428b974f..f4637c5057 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -2381,7 +2381,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data VALUES (' . $user->data['user_id'] . ', ' . $data_ary['topic_id'] . ')'; $db->sql_query($sql); } - else if (($config['email_enable'] || $config['jab_enable']) && $data_ary['notify_set'] && !$data_ary['notify']) + else if ($config['email_enable'] && $data_ary['notify_set'] && !$data_ary['notify']) { $sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . ' WHERE user_id = ' . $user->data['user_id'] . ' diff --git a/phpBB/includes/questionnaire/questionnaire.php b/phpBB/includes/questionnaire/questionnaire.php index 319537f3e3..82f435ba35 100644 --- a/phpBB/includes/questionnaire/questionnaire.php +++ b/phpBB/includes/questionnaire/questionnaire.php @@ -366,9 +366,6 @@ class phpbb_questionnaire_phpbb_data_provider 'img_max_width' => true, 'img_min_thumb_filesize' => true, 'ip_check' => true, - 'jab_enable' => true, - 'jab_package_size' => true, - 'jab_use_ssl' => true, 'limit_load' => true, 'limit_search_load' => true, 'load_anon_lastread' => true, diff --git a/phpBB/phpbb/messenger/queue.php b/phpBB/phpbb/messenger/queue.php index 648dd75182..4e572a6b07 100644 --- a/phpBB/phpbb/messenger/queue.php +++ b/phpBB/phpbb/messenger/queue.php @@ -64,7 +64,7 @@ class queue /** * Init a queue object * - * @param string $object Queue object type: email/jabber/etc + * @param string $object Queue object type: email/etc * @param int $package_size Size of the messenger package to send * @return void */ @@ -78,7 +78,7 @@ class queue /** * Put message into the messenger file queue * - * @param string $object Queue object type: email/jabber/etc + * @param string $object Queue object type: email/etc * @param array $message_data Message data to send * @return void */ diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php index 721b37acac..aeb821cecc 100644 --- a/phpBB/phpbb/notification/manager.php +++ b/phpBB/phpbb/notification/manager.php @@ -708,7 +708,7 @@ class manager * * @param string $item_type Type identifier of the subscription * @param int $item_id The id of the item - * @param string $method The method of the notification e.g. 'board', 'email', or 'jabber' + * @param string $method The method of the notification e.g. 'board', 'email' * (if null a subscription will be added for all the defaults methods) * @param bool|int $user_id The user_id to add the subscription for (bool false for current user) */ @@ -765,7 +765,7 @@ class manager * * @param string $item_type Type identifier of the subscription * @param int $item_id The id of the item - * @param string $method The method of the notification e.g. 'board', 'email', or 'jabber' + * @param string $method The method of the notification e.g. 'board', 'email' * @param bool|int $user_id The user_id to add the subscription for (bool false for current user) */ public function delete_subscription($item_type, $item_id = 0, $method = null, $user_id = false) diff --git a/phpBB/phpbb/notification/method/messenger_base.php b/phpBB/phpbb/notification/method/messenger_base.php index 616199519c..090cf9c8d9 100644 --- a/phpBB/phpbb/notification/method/messenger_base.php +++ b/phpBB/phpbb/notification/method/messenger_base.php @@ -18,7 +18,7 @@ use phpbb\di\service_collection; use phpbb\user_loader; /** -* Abstract notification method handling email and jabber notifications +* Abstract notification method handling messenger notifications * using the phpBB messenger. */ abstract class messenger_base extends \phpbb\notification\method\base diff --git a/phpBB/phpbb/notification/type/base.php b/phpBB/phpbb/notification/type/base.php index cf0ce88a62..70fa979a57 100644 --- a/phpBB/phpbb/notification/type/base.php +++ b/phpBB/phpbb/notification/type/base.php @@ -327,10 +327,7 @@ abstract class base implements \phpbb\notification\type\type_interface */ /** - * URL to unsubscribe to this notification (fall back) - * - * @param string|bool $method Method name to unsubscribe from (email|jabber|etc), False to unsubscribe from all notifications for this item - * @return false + * {@inheritDoc} */ public function get_unsubscribe_url($method = false) { diff --git a/phpBB/phpbb/notification/type/type_interface.php b/phpBB/phpbb/notification/type/type_interface.php index 4c45b634ba..3ac8ea0a68 100644 --- a/phpBB/phpbb/notification/type/type_interface.php +++ b/phpBB/phpbb/notification/type/type_interface.php @@ -132,7 +132,7 @@ interface type_interface /** * URL to unsubscribe to this notification * - * @param string|bool $method Method name to unsubscribe from (email|jabber|etc), False to unsubscribe from all notifications for this item + * @param string|bool $method Method name to unsubscribe from (email|etc), False to unsubscribe from all notifications for this item */ public function get_unsubscribe_url($method); diff --git a/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html b/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html index f5c7d26518..6572d965b8 100644 --- a/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html +++ b/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html @@ -70,7 +70,7 @@
- class="last-cell" onclick="popup(this.href, 750, 320); return false;"> + class="last-cell"> {% if contact.ID == 'pm' %} {{ Icon('font', 'message', '', true, 'far contact-icon') }} {% elseif contact.ID == 'email' %} diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index 2031fa64dd..ac5cbc0240 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -191,7 +191,7 @@
- class="last-cell" onclick="popup(this.href, 750, 320); return false;"> + class="last-cell"> {% EVENT viewtopic_body_contact_icon_prepend %} {% if postrow.contact.ID == 'pm' %} {{ Icon('font', 'message', '', true, 'far contact-icon') }} From 3d9ecba1b11180ffcb6cec859984e558736437ce Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 24 Apr 2025 17:32:29 +0200 Subject: [PATCH 23/23] [ticket/17493] Remove Jabber library from CREDITS PHPBB-17493 --- phpBB/docs/CREDITS.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/phpBB/docs/CREDITS.txt b/phpBB/docs/CREDITS.txt index 9155fc9a2b..0c471e5454 100644 --- a/phpBB/docs/CREDITS.txt +++ b/phpBB/docs/CREDITS.txt @@ -90,7 +90,6 @@ Smarty (c) 2001, 2002 by ispi of Lincoln, Inc, http://smarty.php.net/ GPL licensed: phpMyAdmin (c) 2001, 2003 phpMyAdmin Devel team, http://www.phpmyadmin.net/ -Jabber Class (c) 2006 Flyspray.org, http://www.flyspray.org/ Chora (c) 2000-2006, The Horde Project. http://horde.org/chora/ Horde Project (c) 2000-2006, The Horde Project. http://horde.org/ jQuery (c) 2011, John Resig. http://jquery.com/