Skip to content

Commit

Permalink
Add respective ACP button with handler method and language entries.
Browse files Browse the repository at this point in the history
  • Loading branch information
rxu committed Jan 8, 2024
1 parent 931681d commit 44377dd
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
25 changes: 25 additions & 0 deletions acp/wpn_acp_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,19 @@ public function main($id, $mode)
$this->save_settings();
}

if ($this->request->is_set_post('webpush_enable_for_all_users')
&& $this->config['wpn_webpush_enable']
&& $this->config['wpn_webpush_vapid_public']
)
{
if (!check_form_key($form_key))
{
trigger_error($this->lang->lang('FORM_INVALID'), E_USER_WARNING);
}

$this->webpush_enable_for_all_users();
}

$this->display_settings();
}
}
Expand Down Expand Up @@ -147,4 +160,16 @@ public function save_settings()

trigger_error($this->lang->lang('CONFIG_UPDATED') . adm_back_link($this->u_action), E_USER_NOTICE);
}

/**
* Enable webpush notifications for all users having
* board notifications enabled for the same notification types
*
* @return void
*/
public function webpush_enable_for_all_users()
{
/* TODO: handle subscriptions */
trigger_error($this->lang->lang('WEBPUSH_ENABLED_FOR_ALL_USERS') . adm_back_link($this->u_action), E_USER_NOTICE);
}
}
4 changes: 4 additions & 0 deletions adm/style/wpn_acp_settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ <h3>{{ lang('WARNING') }}</h3>
<dt><label for="webpush_vapid_private">{{ lang('WEBPUSH_VAPID_PRIVATE') ~ lang('COLON') }}</label><br><span>{{ lang('WEBPUSH_VAPID_PRIVATE_EXPLAIN') }}</span></dt>
<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>
</dl>
<dl>
<dt><label>{{ lang('WEBPUSH_ENABLE_FOR_ALL_USERS') ~ lang('COLON') }}</label><br><span>{{ lang('WEBPUSH_ENABLE_FOR_ALL_USERS_EXPLAIN') }}</span></dt>
<dd><input id="webpush_enable_for_all_users" class="button2" type="submit" name="webpush_enable_for_all_users" value="{{ lang('WEBPUSH_ENABLE_FOR_ALL_USERS') }}"></dd>
</dl>
</fieldset>
<fieldset class="submit-buttons">
<input class="button1" type="submit" id="submit" name="submit" value="{{ lang('SUBMIT') }}">&nbsp;
Expand Down
3 changes: 3 additions & 0 deletions language/en/webpushnotifications_module_acp.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
'ACP_WEBPUSH_SETTINGS_EXPLAIN' => 'Here you can enable and control the use of Web Push for board notifications. Web Push is a simple protocol for the delivery of real-time events to user agents, more commonly known as push messages. It is supported by most modern browsers on desktop and mobile devices.',
'WEBPUSH_ENABLE' => 'Enable Web Push',
'WEBPUSH_ENABLE_EXPLAIN' => 'Allow receiving notifications via Web Push. It is required to enter or generate valid VAPID identification keys to be able to use Web Push.',
'WEBPUSH_ENABLE_FOR_ALL_USERS' => 'Enable Web Push for all users',
'WEBPUSH_ENABLE_FOR_ALL_USERS_EXPLAIN' => 'This switch allows receiving notifications via Web Push to be enabled for all users having board notifications enabled. If enabled, users will be subscribed to receive notifications via Web Push for the same notification types they have board notifications enabled.',
'WEBPUSH_ENABLED_FOR_ALL_USERS' => 'Users were subscribed to receive notifications via Web Push successfully.',
'WEBPUSH_GENERATE_VAPID_KEYS' => 'Generate Identification keys',
'WEBPUSH_VAPID_PUBLIC' => 'Server identification public key',
'WEBPUSH_VAPID_PUBLIC_EXPLAIN' => 'The Voluntary Application Server Identification (VAPID) public key will be shared to authenticate push messages sent by your site.<br><em><strong>Warning:</strong> Changing the VAPID public key will automatically invalidate all Webpush subscriptions.</em>',
Expand Down

0 comments on commit 44377dd

Please sign in to comment.