Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions event/listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public function wpn_faq($event)
}

/**
* Append language to privacy agreement.
* Append Web Push disclosure to privacy agreement.
*
* @return void
*/
Expand All @@ -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'));
}

/**
Expand Down
3 changes: 2 additions & 1 deletion language/en/webpushnotifications_module_ucp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '<br><br><h3>Push Notifications</h3>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.',
]);
3 changes: 2 additions & 1 deletion language/ru/webpushnotifications_module_ucp.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@
'NOTIFY_WEBPUSH_POPUP_DISABLE_EXPLAIN' => 'Мы показываем напоминание с просьбой разрешить уведомления браузера, если они сейчас не включены или если мы не можем их обнаружить. Отключите эту функцию, чтобы навсегда убрать эти напоминания на всех ваших устройствах. Если вы отключите эту функцию, вы больше не будете получать предупреждения, если уведомления браузера перестанут работать в будущем.',
'NOTIFY_WEBPUSH_POPUP_ENABLER' => 'Включить напоминания',
'NOTIFY_WEBPUSH_POPUP_DISABLER' => 'Отключить напоминания',
'NOTIFY_WEBPUSH_PRIVACY_POLICY' => '<br><br><h3>Браузерные push—уведомления</h3>Браузерные 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—уведомления в настройках конференции или браузера.',
]);
3 changes: 3 additions & 0 deletions styles/all/template/privacy_policy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<br><br>
<h3>{{ lang('NOTIFY_WEBPUSH_PRIVACY_POLICY_TITLE') }}</h3>
{{ lang('NOTIFY_WEBPUSH_PRIVACY_POLICY_TEXT', SITENAME) }}
27 changes: 21 additions & 6 deletions tests/event/listener_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<br><br><h3>Push Notifications</h3>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);
Expand Down
18 changes: 18 additions & 0 deletions tests/functional/functional_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down