From 006d1662b4320de8f233f49eace8f39d81fcf481 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Mon, 12 Oct 2026 07:44:06 -0700 Subject: [PATCH 1/2] Add privacy policy disclosure --- event/listener.php | 23 +++++++++ .../en/webpushnotifications_module_ucp.php | 1 + .../ru/webpushnotifications_module_ucp.php | 1 + tests/event/listener_test.php | 47 +++++++++++++++++++ 4 files changed, 72 insertions(+) diff --git a/event/listener.php b/event/listener.php index bad15d2..619fd9f 100644 --- a/event/listener.php +++ b/event/listener.php @@ -82,6 +82,7 @@ public static function getSubscribedEvents() 'core.ucp_display_module_before' => 'load_language', 'core.acp_main_notice' => 'compatibility_notice', 'core.help_manager_add_block_after' => 'wpn_faq', + 'core.page_footer' => 'append_agreement', ]; } @@ -198,6 +199,28 @@ public function wpn_faq($event) } } + /** + * Append language to privacy agreement. + * + * @return void + */ + public function append_agreement() + { + if (!$this->config['wpn_webpush_enable'] + || !$this->template->retrieve_var('S_AGREEMENT') + || $this->template->retrieve_var('AGREEMENT_TITLE') !== $this->language->lang('PRIVACY')) + { + return; + } + + if (!$this->language->is_set('NOTIFY_WEBPUSH_PRIVACY_POLICY')) + { + $this->language->add_lang('webpushnotifications_module_ucp', 'phpbb/webpushnotifications'); + } + + $this->template->append_var('AGREEMENT_TEXT', $this->language->lang('NOTIFY_WEBPUSH_PRIVACY_POLICY', $this->config['sitename'])); + } + /** * Can notifications be used by the user? * diff --git a/language/en/webpushnotifications_module_ucp.php b/language/en/webpushnotifications_module_ucp.php index 18e7ff9..3bc83c1 100644 --- a/language/en/webpushnotifications_module_ucp.php +++ b/language/en/webpushnotifications_module_ucp.php @@ -57,4 +57,5 @@ 'NOTIFY_WEBPUSH_POPUP_DISABLE_EXPLAIN' => 'We show a reminder asking you to allow browser notifications when they are not currently enabled or when we cannot detect them. Turn this off to permanently stop these reminder pop-ups on all your devices. If you turn this off, you will not be warned if your browser notifications stop working in the future.', 'NOTIFY_WEBPUSH_POPUP_ENABLER' => 'Enable reminders', 'NOTIFY_WEBPUSH_POPUP_DISABLER' => 'Disable reminders', + 'NOTIFY_WEBPUSH_PRIVACY_POLICY' => '

Push Notifications

If you enable push notifications, “%1$s” stores a browser subscription linked to your account. Notifications are routed through a third-party push service used by your browser or device (such as Google, Mozilla, Apple, or Microsoft), which processes the subscription identifier and delivery metadata. Push messages are encrypted, and notification details are retrieved directly from “%1$s”. You can disable push notifications at any time through your board or browser settings.', ]); diff --git a/language/ru/webpushnotifications_module_ucp.php b/language/ru/webpushnotifications_module_ucp.php index edfcfc9..ee8a4e0 100644 --- a/language/ru/webpushnotifications_module_ucp.php +++ b/language/ru/webpushnotifications_module_ucp.php @@ -57,4 +57,5 @@ 'NOTIFY_WEBPUSH_POPUP_DISABLE_EXPLAIN' => 'Мы показываем напоминание с просьбой разрешить уведомления браузера, если они сейчас не включены или если мы не можем их обнаружить. Отключите эту функцию, чтобы навсегда убрать эти напоминания на всех ваших устройствах. Если вы отключите эту функцию, вы больше не будете получать предупреждения, если уведомления браузера перестанут работать в будущем.', 'NOTIFY_WEBPUSH_POPUP_ENABLER' => 'Включить напоминания', 'NOTIFY_WEBPUSH_POPUP_DISABLER' => 'Отключить напоминания', + 'NOTIFY_WEBPUSH_PRIVACY_POLICY' => '

Push-уведомления

Если вы включите push-уведомления, «%1$s» сохранит подписку браузера, связанную с вашей учётной записью. Уведомления передаются через стороннюю службу push-уведомлений, используемую вашим браузером или устройством (например, Google, Mozilla, Apple или Microsoft), которая обрабатывает идентификатор подписки и метаданные доставки. Push-сообщения шифруются, а сведения об уведомлениях загружаются непосредственно с «%1$s». Вы можете в любое время отключить push-уведомления в настройках конференции или браузера.', ]); diff --git a/tests/event/listener_test.php b/tests/event/listener_test.php index 2ae9d29..6ba9747 100644 --- a/tests/event/listener_test.php +++ b/tests/event/listener_test.php @@ -158,6 +158,7 @@ public function test_getSubscribedEvents() 'core.ucp_display_module_before', 'core.acp_main_notice', 'core.help_manager_add_block_after', + 'core.page_footer', ], array_keys(\phpbb\webpushnotifications\event\listener::getSubscribedEvents())); } @@ -419,6 +420,52 @@ public function test_wpn_faq() $this->listener->wpn_faq($event); } + /** + * Data for test_append_agreement + * + * @return array + */ + public function append_agreement_data() + { + return [ + 'no agreement' => [true, false, 'PRIVACY', 0], + 'terms page' => [true, true, 'TERMS', 0], + 'privacy page but disabled' => [false, true, 'PRIVACY', 0], + 'privacy page, enabled' => [true, true, 'PRIVACY', 1], + ]; + } + + /** + * Test the append_agreement method + * + * @dataProvider append_agreement_data + * @param bool $show_agreement Whether to display agreement text + * @param mixed $s_agreement S_AGREEMENT template variable value + * @param mixed $agreement_title AGREEMENT_TITLE template variable value + * @param int $expected_append_calls Expected append_var calls + */ + public function test_append_agreement($show_agreement, $s_agreement, $agreement_title, $expected_append_calls) + { + $this->config['wpn_webpush_enable'] = $show_agreement; + $this->config['sitename'] = 'Test Board'; + + $this->template->expects(self::atMost(2)) + ->method('retrieve_var') + ->withConsecutive(['S_AGREEMENT'], ['AGREEMENT_TITLE']) + ->willReturnOnConsecutiveCalls($s_agreement, $this->language->lang($agreement_title)); + + $this->template->expects($expected_append_calls ? self::once() : self::never()) + ->method('append_var') + ->with('AGREEMENT_TEXT', self::callback(function ($agreement_text) { + self::assertTrue($this->language->is_set('NOTIFY_WEBPUSH_PRIVACY_POLICY')); + self::assertSame($this->language->lang('NOTIFY_WEBPUSH_PRIVACY_POLICY', 'Test Board'), $agreement_text); + return true; + })); + + $this->set_listener(); + $this->listener->append_agreement(); + } + private function lang($string) { return $this->language->lang($string); From 522f4a7c0a08c3700d3dc2c2ee8fe088cf4b957a Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Mon, 12 Oct 2026 08:57:16 -0700 Subject: [PATCH 2/2] Update language/ru/webpushnotifications_module_ucp.php Co-authored-by: rxu --- language/ru/webpushnotifications_module_ucp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/language/ru/webpushnotifications_module_ucp.php b/language/ru/webpushnotifications_module_ucp.php index ee8a4e0..575dbf8 100644 --- a/language/ru/webpushnotifications_module_ucp.php +++ b/language/ru/webpushnotifications_module_ucp.php @@ -57,5 +57,5 @@ 'NOTIFY_WEBPUSH_POPUP_DISABLE_EXPLAIN' => 'Мы показываем напоминание с просьбой разрешить уведомления браузера, если они сейчас не включены или если мы не можем их обнаружить. Отключите эту функцию, чтобы навсегда убрать эти напоминания на всех ваших устройствах. Если вы отключите эту функцию, вы больше не будете получать предупреждения, если уведомления браузера перестанут работать в будущем.', 'NOTIFY_WEBPUSH_POPUP_ENABLER' => 'Включить напоминания', 'NOTIFY_WEBPUSH_POPUP_DISABLER' => 'Отключить напоминания', - 'NOTIFY_WEBPUSH_PRIVACY_POLICY' => '

Push-уведомления

Если вы включите push-уведомления, «%1$s» сохранит подписку браузера, связанную с вашей учётной записью. Уведомления передаются через стороннюю службу push-уведомлений, используемую вашим браузером или устройством (например, Google, Mozilla, Apple или Microsoft), которая обрабатывает идентификатор подписки и метаданные доставки. Push-сообщения шифруются, а сведения об уведомлениях загружаются непосредственно с «%1$s». Вы можете в любое время отключить push-уведомления в настройках конференции или браузера.', + 'NOTIFY_WEBPUSH_PRIVACY_POLICY' => '

Браузерные push—уведомления

Браузерные push—уведомления на конференции «%1$s» используют сторонние службы push-уведомлений в зависимости от используемого браузера или устройства (например, соответствующие службы Google, Mozilla, Apple или Microsoft), которые обрабатывают идентификаторы и метаданные подписок. Текст сообщений зашифровывается, остальные данные о push—уведомлениях загружаются напрямую с конференции «%1$s». Вы можете отключить браузерные push—уведомления в настройках конференции или браузера.', ]);