mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/17010] Add settings and some more notification code
PHPBB3-17010
This commit is contained in:
parent
3feeb237ca
commit
769f5bc397
4 changed files with 94 additions and 0 deletions
|
@ -485,6 +485,19 @@ class acp_board
|
|||
);
|
||||
break;
|
||||
|
||||
case 'webpush':
|
||||
$display_vars = [
|
||||
'title' => 'ACP_WEBPUSH_SETTINGS',
|
||||
'vars' => [
|
||||
'legend1' => 'GENERAL_SETTINGS',
|
||||
'webpush_vapid_public' => ['lang' => 'WEBPUSH_VAPID_PUBLIC', 'validate' => 'string', 'type' => 'text:25:255', 'explain' => true],
|
||||
'webpush_vapid_private' => ['lang' => 'WEBPUSH_VAPID_PUBLIC', 'validate' => 'string', 'type' => 'text:25:255', 'explain' => true],
|
||||
|
||||
'legend3' => 'ACP_SUBMIT_CHANGES',
|
||||
],
|
||||
];
|
||||
break;
|
||||
|
||||
default:
|
||||
trigger_error('NO_MODE', E_USER_ERROR);
|
||||
break;
|
||||
|
|
|
@ -30,6 +30,7 @@ class acp_board_info
|
|||
|
||||
'auth' => array('title' => 'ACP_AUTH_SETTINGS', 'auth' => 'acl_a_server', 'cat' => array('ACP_CLIENT_COMMUNICATION')),
|
||||
'email' => array('title' => 'ACP_EMAIL_SETTINGS', 'auth' => 'acl_a_server', 'cat' => array('ACP_CLIENT_COMMUNICATION')),
|
||||
'webpush' => array('title' => 'ACP_WEBPUSH_SETTINGS', 'auth' => 'acl_a_server', 'cat' => array('ACP_CLIENT_COMMUNICATION')),
|
||||
|
||||
'cookie' => array('title' => 'ACP_COOKIE_SETTINGS', 'auth' => 'acl_a_server', 'cat' => array('ACP_SERVER_CONFIGURATION')),
|
||||
'server' => array('title' => 'ACP_SERVER_SETTINGS', 'auth' => 'acl_a_server', 'cat' => array('ACP_SERVER_CONFIGURATION')),
|
||||
|
|
|
@ -52,4 +52,31 @@ class add_notification_push_table extends migration
|
|||
'drop_tables' => [$this->table_prefix . 'notification_push'],
|
||||
];
|
||||
}
|
||||
|
||||
public function update_data(): array
|
||||
{
|
||||
return [
|
||||
['config.add', ['webpush_vapid_public', '']],
|
||||
['config.add', ['webpush_vapid_private', '']],
|
||||
['module.add', [
|
||||
'acp',
|
||||
'ACP_BOARD_CONFIGURATION',
|
||||
[
|
||||
'module_basename' => 'acp_board',
|
||||
'module_langname' => 'ACP_WEBPUSH_SETTINGS',
|
||||
'module_mode' => 'webpush',
|
||||
'module_auth' => 'acl_a_board',
|
||||
'after' => ['settings', 'ACP_JABBER_SETTINGS'],
|
||||
],
|
||||
]],
|
||||
];
|
||||
}
|
||||
|
||||
public function revert_data(): array
|
||||
{
|
||||
return [
|
||||
['config.remove', ['webpush_vapid_public']],
|
||||
['config.remove', ['webpush_vapid_private']],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,10 +115,63 @@ class webpush extends \phpbb\notification\method\messenger_base
|
|||
$insert_buffer->flush();
|
||||
|
||||
// @todo: add actual web push code
|
||||
$this->notify_using_webpush();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function notify_using_webpush()
|
||||
{
|
||||
if (empty($this->queue))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Load all users we want to notify (we need their email address)
|
||||
$user_ids = [];
|
||||
foreach ($this->queue as $notification)
|
||||
{
|
||||
$user_ids[] = $notification->user_id;
|
||||
}
|
||||
|
||||
// We do not send emails to banned users
|
||||
if (!function_exists('phpbb_get_banned_user_ids'))
|
||||
{
|
||||
include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
|
||||
}
|
||||
$banned_users = phpbb_get_banned_user_ids($user_ids);
|
||||
|
||||
// Load all the users we need
|
||||
$this->user_loader->load_users(array_diff($user_ids, $banned_users), array(USER_IGNORE));
|
||||
|
||||
// Time to go through the queue and send emails
|
||||
/** @var type_interface $notification */
|
||||
foreach ($this->queue as $notification)
|
||||
{
|
||||
$user = $this->user_loader->get_user($notification->user_id);
|
||||
|
||||
if ($user['user_type'] == USER_INACTIVE && $user['user_inactive_reason'] == INACTIVE_MANUAL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// add actual web push data
|
||||
$data['data'] = [
|
||||
'badge' => '', // @todo: to be filled?
|
||||
'body' => $notification->get_title(),
|
||||
'icon' => '', // @todo: to be filled?
|
||||
'image' => '', // @todo: to be filled?
|
||||
'title' => $this->config['sitename'],
|
||||
'url' => $notification->get_url(),
|
||||
];
|
||||
|
||||
// @todo: start implementing actual web push code
|
||||
}
|
||||
|
||||
// We're done, empty the queue
|
||||
$this->empty_queue();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue