From 78f7bab9c4e4eea3ecfae81e4b34d4d988adf195 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Tue, 6 Jan 2026 09:15:31 -0800 Subject: [PATCH 1/4] Only show popup UCP setting when enabled in ACP --- .../template/event/ucp_notifications_content_before.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/styles/prosilver/template/event/ucp_notifications_content_before.html b/styles/prosilver/template/event/ucp_notifications_content_before.html index b845f61..dca8f8a 100644 --- a/styles/prosilver/template/event/ucp_notifications_content_before.html +++ b/styles/prosilver/template/event/ucp_notifications_content_before.html @@ -9,6 +9,7 @@ + {% if S_WEBPUSH_POPUP_PROMPT %}

{{ lang('NOTIFY_WEBPUSH_POPUP_DISABLE_EXPLAIN') }}
@@ -17,6 +18,7 @@
+ {% endif %} From 696febfee6328af921699367bbb6218e279a4bfd Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Tue, 6 Jan 2026 09:17:39 -0800 Subject: [PATCH 2/4] Switch from a toggle to a button --- language/en/webpushnotifications_module_ucp.php | 6 ++++-- styles/all/template/webpush.js | 13 ++----------- .../event/ucp_notifications_content_before.html | 4 +--- tests/functional/functional_test.php | 14 ++++++-------- 4 files changed, 13 insertions(+), 24 deletions(-) diff --git a/language/en/webpushnotifications_module_ucp.php b/language/en/webpushnotifications_module_ucp.php index cf5e237..18e7ff9 100644 --- a/language/en/webpushnotifications_module_ucp.php +++ b/language/en/webpushnotifications_module_ucp.php @@ -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', ]); diff --git a/styles/all/template/webpush.js b/styles/all/template/webpush.js index 440406c..2605b5f 100644 --- a/styles/all/template/webpush.js +++ b/styles/all/template/webpush.js @@ -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); diff --git a/styles/prosilver/template/event/ucp_notifications_content_before.html b/styles/prosilver/template/event/ucp_notifications_content_before.html index dca8f8a..96b4772 100644 --- a/styles/prosilver/template/event/ucp_notifications_content_before.html +++ b/styles/prosilver/template/event/ucp_notifications_content_before.html @@ -13,9 +13,7 @@

{{ lang('NOTIFY_WEBPUSH_POPUP_DISABLE_EXPLAIN') }}
- +
{% endif %} diff --git a/tests/functional/functional_test.php b/tests/functional/functional_test.php index 214ac8b..5c4d9ec 100644 --- a/tests/functional/functional_test.php +++ b/tests/functional/functional_test.php @@ -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 @@ -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'); From 5e2dfaa785bfe6ae9ef2679f59dabcaa4a4bdeb5 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Tue, 6 Jan 2026 09:26:18 -0800 Subject: [PATCH 3/4] Clean up logic --- notification/method/webpush.php | 2 +- styles/all/template/webpush_popup.html | 2 +- .../template/event/ucp_notifications_content_before.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/notification/method/webpush.php b/notification/method/webpush.php index 162c637..7d58f8f 100644 --- a/notification/method/webpush.php +++ b/notification/method/webpush.php @@ -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, ]; } diff --git a/styles/all/template/webpush_popup.html b/styles/all/template/webpush_popup.html index cff48bd..e76c102 100644 --- a/styles/all/template/webpush_popup.html +++ b/styles/all/template/webpush_popup.html @@ -1,4 +1,4 @@ -{% if S_WEBPUSH_POPUP_PROMPT %} +{% if S_WEBPUSH_POPUP_PROMPT and not S_WEBPUSH_POPUP_DISABLED %}