diff --git a/event/listener.php b/event/listener.php index a90220b..6be2e18 100644 --- a/event/listener.php +++ b/event/listener.php @@ -217,7 +217,7 @@ public function wpn_faq($event) } /** - * Append language to privacy agreement. + * Append Web Push disclosure to privacy agreement. * * @return void */ @@ -230,12 +230,15 @@ public function append_agreement() return; } - if (!$this->language->is_set('NOTIFY_WEBPUSH_PRIVACY_POLICY')) + if (!$this->language->is_set('NOTIFY_WEBPUSH_PRIVACY_POLICY_TEXT')) { $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'])); + $this->template->set_filenames([ + 'wpn_privacy_policy' => '@phpbb_webpushnotifications/privacy_policy.html', + ]); + $this->template->append_var('AGREEMENT_TEXT', $this->template->assign_display('wpn_privacy_policy')); } /** diff --git a/language/en/webpushnotifications_module_ucp.php b/language/en/webpushnotifications_module_ucp.php index 99bceba..20e66bd 100644 --- a/language/en/webpushnotifications_module_ucp.php +++ b/language/en/webpushnotifications_module_ucp.php @@ -58,5 +58,6 @@ '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.', + 'NOTIFY_WEBPUSH_PRIVACY_POLICY_TITLE' => 'Push Notifications', + 'NOTIFY_WEBPUSH_PRIVACY_POLICY_TEXT' => '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 d807a06..e4cebc9 100644 --- a/language/ru/webpushnotifications_module_ucp.php +++ b/language/ru/webpushnotifications_module_ucp.php @@ -58,5 +58,6 @@ '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_TITLE' => 'Браузерные push—уведомления', + 'NOTIFY_WEBPUSH_PRIVACY_POLICY_TEXT' => 'Браузерные push—уведомления на конференции «%1$s» используют сторонние службы push-уведомлений в зависимости от используемого браузера или устройства (например, соответствующие службы Google, Mozilla, Apple или Microsoft), которые обрабатывают идентификаторы и метаданные подписок. Текст сообщений зашифровывается, остальные данные о push—уведомлениях загружаются напрямую с конференции «%1$s». Вы можете отключить браузерные push—уведомления в настройках конференции или браузера.', ]); diff --git a/styles/all/template/privacy_policy.html b/styles/all/template/privacy_policy.html new file mode 100644 index 0000000..3125ef8 --- /dev/null +++ b/styles/all/template/privacy_policy.html @@ -0,0 +1,3 @@ +

+

{{ lang('NOTIFY_WEBPUSH_PRIVACY_POLICY_TITLE') }}

+{{ lang('NOTIFY_WEBPUSH_PRIVACY_POLICY_TEXT', SITENAME) }} diff --git a/tests/event/listener_test.php b/tests/event/listener_test.php index 6cc9563..438f3ae 100644 --- a/tests/event/listener_test.php +++ b/tests/event/listener_test.php @@ -489,25 +489,40 @@ public function append_agreement_data() 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'; + $privacy_policy = '

Push Notifications

Privacy policy text'; $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('set_filenames') + ->with([ + 'wpn_privacy_policy' => '@phpbb_webpushnotifications/privacy_policy.html', + ]); + + $this->template->expects($expected_append_calls ? self::once() : self::never()) + ->method('assign_display') + ->with('wpn_privacy_policy') + ->willReturn($privacy_policy); + $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; - })); + ->with('AGREEMENT_TEXT', $privacy_policy); $this->set_listener(); $this->listener->append_agreement(); } + public function test_privacy_policy_language_has_no_markup() + { + $this->language->add_lang('webpushnotifications_module_ucp', 'phpbb/webpushnotifications'); + + self::assertStringNotContainsString('<', $this->language->lang('NOTIFY_WEBPUSH_PRIVACY_POLICY_TITLE')); + self::assertStringNotContainsString('<', $this->language->lang('NOTIFY_WEBPUSH_PRIVACY_POLICY_TEXT', 'Test Board')); + } + private function lang($string) { return $this->language->lang($string); diff --git a/tests/functional/functional_test.php b/tests/functional/functional_test.php index 6e22324..ebebc27 100644 --- a/tests/functional/functional_test.php +++ b/tests/functional/functional_test.php @@ -96,6 +96,24 @@ public function test_ucp_module() $this->assert_checkbox_is_checked($wp_list, 'notification.type.pm_notification.method.phpbb.wpn.webpush'); } + public function test_privacy_policy() + { + $this->login(); + $this->admin_login(); + $this->add_lang_ext('phpbb/webpushnotifications', 'webpushnotifications_module_ucp'); + $this->set_acp_option('wpn_webpush_enable', 1); + + $crawler = self::request('GET', 'ucp.php?mode=privacy'); + $agreement = $crawler->filter('.agreement'); + + $this->assertCount(1, $agreement->filter('h3')); + $this->assertContainsLang('NOTIFY_WEBPUSH_PRIVACY_POLICY_TITLE', $agreement->filter('h3')->text()); + $this->assertStringContainsString( + $this->lang('NOTIFY_WEBPUSH_PRIVACY_POLICY_TEXT', 'yourdomain.com'), + $agreement->text() + ); + } + public function test_dropdown_subscribe_button() { $this->login();