Skip to content

Commit 71f4216

Browse files
committed
Rename config values to wpn-prefixed.
1 parent 9e7eb26 commit 71f4216

File tree

8 files changed

+28
-48
lines changed

8 files changed

+28
-48
lines changed

acp/wpn_acp_module.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ public function main($id, $mode)
101101
public function display_settings()
102102
{
103103
$this->template->assign_vars([
104-
'S_WEBPUSH_ENABLE' => $this->config['webpush_enable'],
105-
'WEBPUSH_VAPID_PUBLIC' => $this->config['webpush_vapid_public'],
106-
'WEBPUSH_VAPID_PRIVATE' => $this->config['webpush_vapid_private'],
104+
'S_WEBPUSH_ENABLE' => $this->config['wpn_webpush_enable'],
105+
'WEBPUSH_VAPID_PUBLIC' => $this->config['wpn_webpush_vapid_public'],
106+
'WEBPUSH_VAPID_PRIVATE' => $this->config['wpn_webpush_vapid_private'],
107107
'U_ACTION' => $this->u_action,
108108
]);
109109
}
@@ -117,12 +117,12 @@ public function save_settings()
117117
{
118118
$config_array = $this->request->variable('config', ['' => ''], true);
119119
$display_settings = [
120-
'webpush_enable' => ['validate' => 'bool'],
121-
'webpush_vapid_public' => ['validate' => 'string:25:255', 'lang' => 'WEBPUSH_VAPID_PUBLIC'],
122-
'webpush_vapid_private'=> ['validate' => 'string:25:255', 'lang' => 'WEBPUSH_VAPID_PRIVATE'],
120+
'wpn_webpush_enable' => ['validate' => 'bool'],
121+
'wpn_webpush_vapid_public' => ['validate' => 'string:25:255', 'lang' => 'WEBPUSH_VAPID_PUBLIC'],
122+
'wpn_webpush_vapid_private'=> ['validate' => 'string:25:255', 'lang' => 'WEBPUSH_VAPID_PRIVATE'],
123123
];
124124

125-
if ($config_array['webpush_enable'])
125+
if ($config_array['wpn_webpush_enable'])
126126
{
127127
// Validate config values
128128
validate_config_vars($display_settings, $config_array, $this->errors);
@@ -140,9 +140,9 @@ public function save_settings()
140140

141141
$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_CONFIG_WEBPUSH');
142142

143-
$this->config->set('webpush_enable', $config_array['webpush_enable']);
144-
$this->config->set('webpush_vapid_public', $config_array['webpush_vapid_public']);
145-
$this->config->set('webpush_vapid_private', $config_array['webpush_vapid_private']);
143+
$this->config->set('webpush_enable', $config_array['wpn_webpush_enable']);
144+
$this->config->set('webpush_vapid_public', $config_array['wpn_webpush_vapid_public']);
145+
$this->config->set('webpush_vapid_private', $config_array['wpn_webpush_vapid_private']);
146146

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

adm/style/wpn_acp_settings.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ <h3>{{ lang('WARNING') }}</h3>
1717
<legend>{{ lang('GENERAL_SETTINGS') }}</legend>
1818
<dl>
1919
<dt><label>{{ lang('WEBPUSH_ENABLE') ~ lang('COLON') }}</label><br><span>{{ lang('WEBPUSH_ENABLE_EXPLAIN') }}</span></dt>
20-
<dd><label><input type="radio" class="radio" name="config[webpush_enable]" value="1" {% if S_WEBPUSH_ENABLE %}checked="checked"{% endif %}> {{ lang('YES') }}</label>
21-
<label><input type="radio" class="radio" name="config[webpush_enable]" value="0"{% if not S_WEBPUSH_ENABLE %} checked="checked"{% endif %}> {{ lang('NO') }}</label>
20+
<dd><label><input type="radio" class="radio" name="config[wpn_webpush_enable]" value="1" {% if S_WEBPUSH_ENABLE %}checked="checked"{% endif %}> {{ lang('YES') }}</label>
21+
<label><input type="radio" class="radio" name="config[wpn_webpush_enable]" value="0"{% if not S_WEBPUSH_ENABLE %} checked="checked"{% endif %}> {{ lang('NO') }}</label>
2222
<input class="button2" data-ajax="generate_vapid_keys" type="button" name="config[webpush_enable]" value="{{ lang('WEBPUSH_GENERATE_VAPID_KEYS') }}"></dd>
2323
</dl>
2424
<dl>
2525
<dt><label for="webpush_vapid_public">{{ lang('WEBPUSH_VAPID_PUBLIC') ~ lang('COLON') }}</label><br><span>{{ lang('WEBPUSH_VAPID_PUBLIC_EXPLAIN') }}</span></dt>
26-
<dd><label><input id="webpush_vapid_public" type="text" name="config[webpush_vapid_public]" size="25" maxlength="255" value="{{ WEBPUSH_VAPID_PUBLIC }}"></label></dd>
26+
<dd><label><input id="webpush_vapid_public" type="text" name="config[wpn_webpush_vapid_public]" size="25" maxlength="255" value="{{ WEBPUSH_VAPID_PUBLIC }}"></label></dd>
2727
</dl>
2828
<dl>
2929
<dt><label for="webpush_vapid_private">{{ lang('WEBPUSH_VAPID_PRIVATE') ~ lang('COLON') }}</label><br><span>{{ lang('WEBPUSH_VAPID_PRIVATE_EXPLAIN') }}</span></dt>
30-
<dd><label><input id="webpush_vapid_private" type="password" name="config[webpush_vapid_private]" size="25" maxlength="255" autocomplete="off" value="{{ WEBPUSH_VAPID_PRIVATE }}"></label></dd>
30+
<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>
3232
</fieldset>
3333
<fieldset class="submit-buttons">

config/services.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ services:
3838
phpbb.wpn.ucp.controller.webpush:
3939
class: phpbb\webpushnotifications\ucp\controller\webpush
4040
arguments:
41-
- '@config'
4241
- '@controller.helper'
4342
- '@dbal.conn'
4443
- '@phpbb.wpn.form_helper'

migrations/add_webpush.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ public function revert_schema(): array
6767
public function update_data(): array
6868
{
6969
return [
70-
['config.add', ['webpush_enable', false]],
71-
['config.add', ['webpush_vapid_public', '']],
72-
['config.add', ['webpush_vapid_private', '']],
70+
['config.add', ['wpn_webpush_enable', false]],
71+
['config.add', ['wpn_webpush_vapid_public', '']],
72+
['config.add', ['wpn_webpush_vapid_private', '']],
7373
['module.add', ['acp', 'ACP_CLIENT_COMMUNICATION', [
7474
'module_basename' => '\phpbb\webpushnotifications\acp\wpn_acp_module',
7575
'module_langname' => 'ACP_WEBPUSH_SETTINGS',

notification/method/webpush.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ public function get_type(): string
8686
*/
8787
public function is_available(type_interface $notification_type = null): bool
8888
{
89-
return parent::is_available($notification_type) && $this->config['webpush_enable']
90-
&& !empty($this->config['webpush_vapid_public']) && !empty($this->config['webpush_vapid_private']);
89+
return parent::is_available($notification_type) && $this->config['wpn_webpush_enable']
90+
&& !empty($this->config['wpn_webpush_vapid_public']) && !empty($this->config['wpn_webpush_vapid_private']);
9191
}
9292

9393
/**
@@ -181,8 +181,8 @@ protected function notify_using_webpush(): void
181181
$auth = [
182182
'VAPID' => [
183183
'subject' => generate_board_url(false),
184-
'publicKey' => $this->config['webpush_vapid_public'],
185-
'privateKey' => $this->config['webpush_vapid_private'],
184+
'publicKey' => $this->config['wpn_webpush_vapid_public'],
185+
'privateKey' => $this->config['wpn_webpush_vapid_private'],
186186
],
187187
];
188188

@@ -341,7 +341,7 @@ public function get_ucp_template_data(helper $controller_helper, form_helper $fo
341341
'NOTIFICATIONS_WEBPUSH_ENABLE' => true,
342342
'U_WEBPUSH_SUBSCRIBE' => $controller_helper->route('phpbb_webpushnotifications_ucp_push_subscribe_controller'),
343343
'U_WEBPUSH_UNSUBSCRIBE' => $controller_helper->route('phpbb_webpushnotifications_ucp_push_unsubscribe_controller'),
344-
'VAPID_PUBLIC_KEY' => $this->config['webpush_vapid_public'],
344+
'VAPID_PUBLIC_KEY' => $this->config['wpn_webpush_vapid_public'],
345345
'U_WEBPUSH_WORKER_URL' => $controller_helper->route('phpbb_webpushnotifications_ucp_push_worker_controller'),
346346
'SUBSCRIPTIONS' => $subscriptions,
347347
'WEBPUSH_FORM_TOKENS' => $form_helper->get_form_tokens(\phpbb\webpushnotifications\ucp\controller\webpush::FORM_TOKEN_UCP),

tests/functional/functional_test.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ public function test_acp_module()
4545
$this->assertContainsLang('WEBPUSH_GENERATE_VAPID_KEYS', $crawler->filter('input[type="button"]')->attr('value'));
4646

4747
$form_data = [
48-
'config[webpush_enable]' => 1,
49-
'config[webpush_vapid_public]' => 'BDnYSJHVZBxq834LqDGr893IfazEez7q-jYH2QBNlT0ji2C9UwGosiqz8Dp_ZN23lqAngBZyRjXVWF4ZLA8X2zI',
50-
'config[webpush_vapid_private]' => 'IE5OYlmfWsMbBU1lzvr0bxrxVAXIteSkAnwGlZIhmRk',
48+
'config[wpn_webpush_enable]' => 1,
49+
'config[wpn_webpush_vapid_public]' => 'BDnYSJHVZBxq834LqDGr893IfazEez7q-jYH2QBNlT0ji2C9UwGosiqz8Dp_ZN23lqAngBZyRjXVWF4ZLA8X2zI',
50+
'config[wpn_webpush_vapid_private]' => 'IE5OYlmfWsMbBU1lzvr0bxrxVAXIteSkAnwGlZIhmRk',
5151
];
5252
$form = $crawler->selectButton('submit')->form($form_data);
5353
$crawler = self::submit($form);
@@ -72,5 +72,4 @@ public function test_ucp_module()
7272
$this->assertContainsLang('NOTIFY_WEBPUSH_ENABLE', $crawler->filter('label[for="subscribe_webpush"]')->text());
7373
$this->assertContainsLang('PHPBB_WPN_NOTIFICATION_METHOD_WEBPUSH', $crawler->filter('th.mark')->eq(2)->text());
7474
}
75-
7675
}

tests/notification/notification_method_webpush_test.php

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ protected function setUp(): void
101101
'allow_topic_notify' => true,
102102
'allow_forum_notify' => true,
103103
'allow_board_notifications' => true,
104-
'webpush_vapid_public' => self::VAPID_KEYS['publicKey'],
105-
'webpush_vapid_private' => self::VAPID_KEYS['privateKey'],
104+
'wpn_webpush_vapid_public' => self::VAPID_KEYS['publicKey'],
105+
'wpn_webpush_vapid_private' => self::VAPID_KEYS['privateKey'],
106106
]);
107107
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
108108
$lang = new \phpbb\language\language($lang_loader);
@@ -144,16 +144,6 @@ protected function setUp(): void
144144
$phpbb_container->setParameter('tables.notification_emails', 'phpbb_notification_emails');
145145
$phpbb_container->setParameter('tables.phpbb.wpn.notification_push', 'phpbb_wpn_notification_push');
146146
$phpbb_container->setParameter('tables.phpbb.wpn.push_subscriptions', 'phpbb_wpn_push_subscriptions');
147-
// $phpbb_container->set(
148-
// 'text_formatter.s9e.mention_helper',
149-
// new \phpbb\textformatter\s9e\mention_helper(
150-
// $this->db,
151-
// $auth,
152-
// $this->user,
153-
// $phpbb_root_path,
154-
// $phpEx
155-
// )
156-
// );
157147

158148
$this->notification_method_webpush = new webpush(
159149
$phpbb_container->get('config'),
@@ -185,8 +175,6 @@ protected function setUp(): void
185175

186176
$phpbb_container->set('notification_manager', $this->notifications);
187177

188-
// $phpbb_container->addCompilerPass(new \phpbb\di\pass\markpublic_pass());
189-
190178
$phpbb_container->compile();
191179

192180
$this->notifications->setDependencies($this->auth, $this->config);

ucp/controller/webpush.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
namespace phpbb\webpushnotifications\ucp\controller;
1212

13-
use phpbb\config\config;
1413
use phpbb\controller\helper as controller_helper;
1514
use phpbb\db\driver\driver_interface;
1615
use phpbb\exception\http_exception;
@@ -32,9 +31,6 @@ class webpush
3231
/** @var string UCP form token name */
3332
public const FORM_TOKEN_UCP = 'ucp_webpush';
3433

35-
/** @var config */
36-
protected $config;
37-
3834
/** @var controller_helper */
3935
protected $controller_helper;
4036

@@ -65,7 +61,6 @@ class webpush
6561
/**
6662
* Constructor for webpush controller
6763
*
68-
* @param config $config
6964
* @param controller_helper $controller_helper
7065
* @param driver_interface $db
7166
* @param form_helper $form_helper
@@ -76,10 +71,9 @@ class webpush
7671
* @param string $notification_webpush_table
7772
* @param string $push_subscriptions_table
7873
*/
79-
public function __construct(config $config, controller_helper $controller_helper, driver_interface $db, form_helper $form_helper, path_helper $path_helper,
74+
public function __construct(controller_helper $controller_helper, driver_interface $db, form_helper $form_helper, path_helper $path_helper,
8075
request_interface $request, user $user, Environment $template, string $notification_webpush_table, string $push_subscriptions_table)
8176
{
82-
$this->config = $config;
8377
$this->controller_helper = $controller_helper;
8478
$this->db = $db;
8579
$this->form_helper = $form_helper;

0 commit comments

Comments
 (0)