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
6 changes: 4 additions & 2 deletions language/en/webpushnotifications_module_ucp.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
'NOTIFY_WEBPUSH_POPUP_MESSAGE' => 'We would like to send you browser notifications for replies, private messages, and relevant forum activity. Optional — you can manage these settings at any time.',
'NOTIFY_WEBPUSH_POPUP_ALLOW' => 'Allow',
'NOTIFY_WEBPUSH_POPUP_DENY' => 'Deny',
'NOTIFY_WEBPUSH_POPUP_DISABLE' => 'Disable “Allow Browser Notifications” prompts',
'NOTIFY_WEBPUSH_POPUP_DISABLE_EXPLAIN' => 'Toggle this on to stop us from asking you to enable web push notifications on any of your devices. Note that we won’t be able to alert you if your web push notifications ever become disabled.',
'NOTIFY_WEBPUSH_POPUP_DISABLE' => 'Notification reminder pop-ups',
'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',
]);
6 changes: 4 additions & 2 deletions language/ru/webpushnotifications_module_ucp.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
'NOTIFY_WEBPUSH_POPUP_MESSAGE' => 'Браузерные уведомления позволяют быстро получать информацию о новых ответах, личных сообщениях и других активностях на данной конференции. Функцию можно отключить или включить в любое время в настройках уведомлений в Личном разделе.',
'NOTIFY_WEBPUSH_POPUP_ALLOW' => 'Включить',
'NOTIFY_WEBPUSH_POPUP_DENY' => 'Отклонить',
'NOTIFY_WEBPUSH_POPUP_DISABLE' => 'Отключить запросы «Включить браузерные уведомления»',
'NOTIFY_WEBPUSH_POPUP_DISABLE_EXPLAIN' => 'Включите этот параметр, чтобы мы больше не спрашивали вас о включении веб-push-уведомлений на любом из ваших устройств. Обратите внимание, что в этом случае мы не сможем предупредить вас, если веб-push-уведомления будут отключены.',
'NOTIFY_WEBPUSH_POPUP_DISABLE' => 'Всплывающие напоминания о уведомлениях',
'NOTIFY_WEBPUSH_POPUP_DISABLE_EXPLAIN' => 'Мы показываем напоминание с просьбой разрешить уведомления браузера, если они сейчас не включены или если мы не можем их обнаружить. Отключите эту функцию, чтобы навсегда убрать эти напоминания на всех ваших устройствах. Если вы отключите эту функцию, вы больше не будете получать предупреждения, если уведомления браузера перестанут работать в будущем.',
'NOTIFY_WEBPUSH_POPUP_ENABLER' => 'Включить напоминания',
'NOTIFY_WEBPUSH_POPUP_DISABLER' => 'Отключить напоминания',
]);
2 changes: 1 addition & 1 deletion notification/method/webpush.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ public function get_ucp_template_data(helper $controller_helper, form_helper $fo
'U_WEBPUSH_WORKER_URL' => $controller_helper->route('phpbb_webpushnotifications_ucp_push_worker_controller'),
'SUBSCRIPTIONS' => $subscriptions,
'WEBPUSH_FORM_TOKENS' => $form_helper->get_form_tokens(\phpbb\webpushnotifications\ucp\controller\webpush::FORM_TOKEN_UCP),
'S_WEBPUSH_POPUP_PROMPT' => $this->config['wpn_webpush_popup_prompt'] && $this->user->id() != ANONYMOUS && $this->user->data['user_type'] != USER_IGNORE && !($this->user->data['user_wpn_popup_disabled'] ?? 0),
'S_WEBPUSH_POPUP_PROMPT' => $this->config['wpn_webpush_popup_prompt'] && $this->user->id() != ANONYMOUS && $this->user->data['user_type'] != USER_IGNORE,
'S_WEBPUSH_POPUP_DISABLED' => $this->user->data['user_wpn_popup_disabled'] ?? 0,
];
}
Expand Down
13 changes: 2 additions & 11 deletions styles/all/template/webpush.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,19 +389,10 @@ function PhpbbWebpush() {
.then(data => {
loadingIndicator.fadeOut(phpbb.alertTime);
if (data.success) {
// Update toggle icon based on new state
// Update button text based on new state
const button = document.getElementById('toggle_popup_prompt');
if (button) {
const icon = button.querySelector('i');
if (icon) {
if (data.disabled) {
icon.classList.remove('fa-toggle-off');
icon.classList.add('fa-toggle-on');
} else {
icon.classList.remove('fa-toggle-on');
icon.classList.add('fa-toggle-off');
}
}
button.value = data.disabled ? button.getAttribute('data-l-enable') : button.getAttribute('data-l-disable');
}
if ('form_tokens' in data) {
updateFormTokens(data.form_tokens);
Expand Down
2 changes: 1 addition & 1 deletion styles/all/template/webpush_popup.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% if S_WEBPUSH_POPUP_PROMPT %}
{% if S_WEBPUSH_POPUP_PROMPT and not S_WEBPUSH_POPUP_DISABLED %}
<div id="wpn_popup_prompt" class="wpn-popup-overlay" style="display:none;" role="dialog" aria-modal="true" aria-labelledby="wpn_popup_title" aria-describedby="wpn_popup_message">
<div class="wpn-popup-container">
<div class="wpn-popup-content">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
<input id="unsubscribe_webpush" type="submit" name="unsubscribe_webpush" value="{{ lang('NOTIFY_WEBPUSH_DISABLE') }}" class="wpn button1 button button-form hidden">
</dd>
</dl>
{% if S_WEBPUSH_POPUP_PROMPT %}
<dl>
<dt><label for="toggle_popup_prompt">{{ lang('NOTIFY_WEBPUSH_POPUP_DISABLE') ~ lang('COLON') }}</label><br><span>{{ lang('NOTIFY_WEBPUSH_POPUP_DISABLE_EXPLAIN') }}</span></dt>
<dd>
<button id="toggle_popup_prompt" type="button" name="toggle_popup_prompt" aria-label="{{ lang('NOTIFY_WEBPUSH_POPUP_DISABLE') }}">
<i class="icon icon-lg fa-fw fa-toggle-{% if S_WEBPUSH_POPUP_DISABLED %}on{% else %}off{% endif %}" aria-hidden="true"></i>
</button>
<input id="toggle_popup_prompt" type="button" name="toggle_popup_prompt" value="{{ lang(S_WEBPUSH_POPUP_DISABLED ? 'NOTIFY_WEBPUSH_POPUP_ENABLER' : 'NOTIFY_WEBPUSH_POPUP_DISABLER') }}" class="button1 button button-form" data-l-disable="{{ lang('NOTIFY_WEBPUSH_POPUP_DISABLER')|e('html_attr') }}" data-l-enable="{{ lang('NOTIFY_WEBPUSH_POPUP_ENABLER')|e('html_attr') }}">
</dd>
</dl>
{% endif %}
</fieldset>
</div>
</div>
Expand Down
14 changes: 6 additions & 8 deletions tests/functional/functional_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,9 @@ public function test_popup_preference_toggle()
$this->assertCount(1, $crawler->filter('#toggle_popup_prompt'));
$this->assertContainsLang('NOTIFY_WEBPUSH_POPUP_DISABLE', $crawler->filter('label[for="toggle_popup_prompt"]')->text());

// Assert toggle is initially off (prompts enabled)
$toggle_icon = $crawler->filter('#toggle_popup_prompt i');
$this->assertCount(1, $toggle_icon);
$this->assertTrue($toggle_icon->attr('class') !== null && strpos($toggle_icon->attr('class'), 'fa-toggle-off') !== false);
// Assert button text shows "Disable" initially (prompts enabled)
$button_value = $crawler->filter('#toggle_popup_prompt')->attr('value');
$this->assertContainsLang('NOTIFY_WEBPUSH_POPUP_DISABLER', $button_value);

// After user disables popup (in reality this would be via AJAX, but we test the state)
// Set user preference to disabled via DB
Expand All @@ -194,10 +193,9 @@ public function test_popup_preference_toggle()
// Reload page
$crawler = self::request('GET', 'ucp.php?i=ucp_notifications&mode=notification_options');

// Assert toggle is now on (prompts disabled)
$toggle_icon = $crawler->filter('#toggle_popup_prompt i');
$this->assertCount(1, $toggle_icon);
$this->assertTrue($toggle_icon->attr('class') !== null && strpos($toggle_icon->attr('class'), 'fa-toggle-on') !== false);
// Assert button text shows "Enable" now (prompts disabled)
$button_value = $crawler->filter('#toggle_popup_prompt')->attr('value');
$this->assertContainsLang('NOTIFY_WEBPUSH_POPUP_ENABLER', $button_value);

// Assert popup is not shown on index when user has disabled it
$crawler = self::request('GET', 'index.php');
Expand Down