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:
@@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user