From 3caab55e819772bfad43960901a3898f10405c4b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 21 Apr 2025 15:16:41 +0200 Subject: [PATCH] [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);