Skip to content

Commit cad0c69

Browse files
committed
Make notification dropdown subscribe toggle an option
Signed-off-by: Matt Friedman <maf675@gmail.com>
1 parent 1485314 commit cad0c69

File tree

8 files changed

+18
-9
lines changed

8 files changed

+18
-9
lines changed

acp/wpn_acp_module.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,12 @@ public function main($id, $mode)
9898
public function display_settings()
9999
{
100100
$this->template->assign_vars([
101-
'S_WEBPUSH_ENABLE' => $this->config['wpn_webpush_enable'],
102-
'WEBPUSH_VAPID_PUBLIC' => $this->config['wpn_webpush_vapid_public'],
103-
'WEBPUSH_VAPID_PRIVATE' => $this->config['wpn_webpush_vapid_private'] ? self::MASKED_PRIVATE_KEY : '',
104-
'S_WEBPUSH_METHOD_ENABLED' => $this->config['wpn_webpush_method_enabled'],
105-
'U_ACTION' => $this->u_action,
101+
'S_WEBPUSH_ENABLE' => $this->config['wpn_webpush_enable'],
102+
'WEBPUSH_VAPID_PUBLIC' => $this->config['wpn_webpush_vapid_public'],
103+
'WEBPUSH_VAPID_PRIVATE' => $this->config['wpn_webpush_vapid_private'] ? self::MASKED_PRIVATE_KEY : '',
104+
'S_WPN_WEBPUSH_DROPDOWN_SUBSCRIBE' => $this->config['wpn_webpush_dropdown_subscribe'],
105+
'S_WEBPUSH_METHOD_ENABLED' => $this->config['wpn_webpush_method_enabled'],
106+
'U_ACTION' => $this->u_action,
106107
]);
107108
}
108109

@@ -118,6 +119,7 @@ public function save_settings()
118119
'wpn_webpush_enable' => ['validate' => 'bool'],
119120
'wpn_webpush_vapid_public' => ['validate' => 'string:25:255', 'lang' => 'WEBPUSH_VAPID_PUBLIC'],
120121
'wpn_webpush_vapid_private'=> ['validate' => 'string:25:255', 'lang' => 'WEBPUSH_VAPID_PRIVATE'],
122+
'wpn_webpush_dropdown_subscribe' => ['validate' => 'bool'],
121123
'wpn_webpush_method_enabled' => ['validate' => 'bool'],
122124
];
123125

adm/style/wpn_acp_settings.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ <h3>{{ lang('WARNING') }}</h3>
2929
<dt><label for="webpush_vapid_private">{{ lang('WEBPUSH_VAPID_PRIVATE') ~ lang('COLON') }}</label><br><span>{{ lang('WEBPUSH_VAPID_PRIVATE_EXPLAIN') }}</span></dt>
3030
<dd><label><input id="webpush_vapid_private" type="password" name="config[wpn_webpush_vapid_private]" size="25" maxlength="255" autocomplete="off" value="{{ WEBPUSH_VAPID_PRIVATE }}"></label></dd>
3131
</dl>
32+
<dl>
33+
<dt><label>{{ lang('WPN_WEBPUSH_DROPDOWN_SUBSCRIBE') ~ lang('COLON') }}</label><br><span>{{ lang('WPN_WEBPUSH_DROPDOWN_SUBSCRIBE_EXPLAIN') }}</span></dt>
34+
<dd><label><input type="radio" class="radio" name="config[wpn_webpush_dropdown_subscribe]" value="1" {% if S_WPN_WEBPUSH_DROPDOWN_SUBSCRIBE %}checked="checked"{% endif %}> {{ lang('YES') }}</label>
35+
<label><input type="radio" class="radio" name="config[wpn_webpush_dropdown_subscribe]" value="0"{% if not S_WPN_WEBPUSH_DROPDOWN_SUBSCRIBE %} checked="checked"{% endif %}> {{ lang('NO') }}</label>
36+
</dl>
3237
<dl>
3338
<dt><label>{{ lang('WEBPUSH_METHOD_ENABLED') ~ lang('COLON') }}</label><br><span>{{ lang('WEBPUSH_METHOD_ENABLED_EXPLAIN') }}</span></dt>
3439
<dd><label><input type="radio" class="radio" name="config[wpn_webpush_method_enabled]" value="1" {% if S_WEBPUSH_METHOD_ENABLED %}checked="checked"{% endif %}> {{ lang('YES') }}</label>

language/en/webpushnotifications_module_acp.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,6 @@
4848
'WEBPUSH_VAPID_PRIVATE_EXPLAIN' => 'The Voluntary Application Server Identification (VAPID) private key is used to generate authenticated push messages dispatched from your site. The VAPID private key <strong>must</strong> form a valid public-private key pair alongside the VAPID public key.<br><em><strong>Caution:</strong> Modifying the VAPID private key will automatically render all Web Push subscriptions invalid.</em>',
4949
'WEBPUSH_METHOD_ENABLED' => 'Enable user-based web push notifications by default',
5050
'WEBPUSH_METHOD_ENABLED_EXPLAIN'=> 'When this setting is enabled, users who subscribe and allow browser notifications will start receiving them automatically. They only need to visit the UCP Notification settings to disable any unwanted notifications.<br><br>If this setting is disabled, users will not receive any notifications, even if they have subscribed, until they visit the UCP Notification settings to enable the specific notifications they wish to receive.',
51+
'WPN_WEBPUSH_DROPDOWN_SUBSCRIBE' => 'Show “Subscribe” button in notification dropdown',
52+
'WPN_WEBPUSH_DROPDOWN_SUBSCRIBE_EXPLAIN'=> 'Enable or disable the “Subscribe” button in the Notification dropdown, allowing users to easily subscribe to push notifications from any page of the forum.',
5153
]);

language/en/webpushnotifications_module_ucp.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,4 @@
4545
'NOTIFY_WEBPUSH_SUBSCRIBE' => 'Subscribe',
4646
'NOTIFY_WEBPUSH_UNSUBSCRIBE' => 'Unsubscribe',
4747
'NOTIFY_WEBPUSH_SUBSCRIBED' => 'Subscribed',
48-
'NOTIFY_WEBPUSH_DROPDOWN_TITLE' => 'Visit notifications settings to set your preferred push notifications.',
4948
]);

language/ru/webpushnotifications_module_ucp.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,4 @@
4545
'NOTIFY_WEBPUSH_SUBSCRIBE' => 'Подписаться',
4646
'NOTIFY_WEBPUSH_UNSUBSCRIBE' => 'Отписаться',
4747
'NOTIFY_WEBPUSH_SUBSCRIBED' => 'Включено',
48-
'NOTIFY_WEBPUSH_DROPDOWN_TITLE' => 'Посетите настройки уведомлений, чтобы установить предпочтительные push-уведомления.',
4948
]);

migrations/add_acp_configs.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ public function update_data(): array
2828
{
2929
return [
3030
['config.add', ['wpn_webpush_method_enabled', false]],
31+
['config.add', ['wpn_webpush_dropdown_subscribe', false]],
3132
];
3233
}
3334

3435
public function revert_data(): array
3536
{
3637
return [
3738
['config.remove', ['wpn_webpush_method_enabled']],
39+
['config.remove', ['wpn_webpush_dropdown_subscribe']],
3840
];
3941
}
4042
}

notification/method/webpush.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ public function get_ucp_template_data(helper $controller_helper, form_helper $fo
364364
}
365365

366366
return [
367-
'NOTIFICATIONS_WEBPUSH_ENABLE' => true,
367+
'NOTIFICATIONS_WEBPUSH_ENABLE' => $this->config['wpn_webpush_dropdown_subscribe'] || stripos($this->user->page['page'], 'notification_options'),
368368
'U_WEBPUSH_SUBSCRIBE' => $controller_helper->route('phpbb_webpushnotifications_ucp_push_subscribe_controller'),
369369
'U_WEBPUSH_UNSUBSCRIBE' => $controller_helper->route('phpbb_webpushnotifications_ucp_push_unsubscribe_controller'),
370370
'VAPID_PUBLIC_KEY' => $this->config['wpn_webpush_vapid_public'],

styles/all/template/event/notification_dropdown_footer_after.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% if NOTIFICATIONS_WEBPUSH_ENABLE and notification_types is not defined %}
2-
<div class="wpn-notification-dropdown-footer" title="{{ lang('NOTIFY_WEBPUSH_DROPDOWN_TITLE') }}">
2+
<div class="wpn-notification-dropdown-footer">
33
<span class="ellipsis-text">{{ lang('NOTIFY_WEBPUSH_ENABLE_SHORT') ~ lang('COLON') }}</span>
44
<button id="subscribe_webpush" name="subscribe_webpush"><i class="icon fa-toggle-off fa-fw icon-lightgray"></i><span>{{ lang('NOTIFY_WEBPUSH_SUBSCRIBE') }}</span></button>
55
<button id="unsubscribe_webpush" name="unsubscribe_webpush" class="hidden"><i class="icon fa-toggle-on fa-fw icon-blue"></i><span>{{ lang('NOTIFY_WEBPUSH_SUBSCRIBED') }}</span></button>

0 commit comments

Comments
 (0)