1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

[ticket/17010] Add Webpush settings and language entries

PHPBB3-17010
This commit is contained in:
Marc Alexander
2022-08-30 20:21:03 +02:00
parent d05e2dd043
commit 873a22176d
5 changed files with 35 additions and 3 deletions

View File

@@ -19,6 +19,7 @@
* @ignore
*/
use Minishlink\WebPush\VAPID;
use phpbb\config\config;
use phpbb\language\language;
use phpbb\user;
@@ -490,6 +491,7 @@ class acp_board
'title' => 'ACP_WEBPUSH_SETTINGS',
'vars' => [
'legend1' => 'GENERAL_SETTINGS',
'webpush_enable' => ['lang' => 'WEBPUSH_ENABLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true],
'webpush_vapid_public' => ['lang' => 'WEBPUSH_VAPID_PUBLIC', 'validate' => 'string', 'type' => 'text:25:255', 'explain' => true],
'webpush_vapid_private' => ['lang' => 'WEBPUSH_VAPID_PRIVATE', 'validate' => 'string', 'type' => 'password:25:255', 'explain' => true],
@@ -537,6 +539,27 @@ class acp_board
}
}
if ($mode == 'webpush')
{
// Create VAPID keys if keys are empty and web push is enabled
if ($submit && $cfg_array['webpush_enable'] && $cfg_array['webpush_enable'] != $config['webpush_enable']
&& empty($cfg_array['webpush_vapid_public']) && empty($cfg_array['webpush_vapid_private'])
&& empty($config['webpush_vapid_public']) && empty($config['webpush_vapid_private']))
{
try
{
$vapid_keys = VAPID::createVapidKeys();
$cfg_array['webpush_vapid_public'] = $vapid_keys['publicKey'];
$cfg_array['webpush_vapid_private'] = $vapid_keys['privateKey'];
}
catch (\ErrorException $exception)
{
// Nothing we can do about this, user will have to follow the
// documentation and manually create these.
}
}
}
// We validate the complete config if wished
validate_config_vars($display_vars['vars'], $cfg_array, $error);