Skip to content

Commit 0c8a05f

Browse files
committed
Show admin warning msg on insecure servers
Signed-off-by: Matt Friedman <maf675@gmail.com>
1 parent 8f45b4e commit 0c8a05f

3 files changed

Lines changed: 27 additions & 6 deletions

File tree

acp/wpn_acp_module.php

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ public function display_settings()
105105
'S_WEBPUSH_METHOD_ENABLED' => $this->config['wpn_webpush_method_enabled'],
106106
'U_ACTION' => $this->u_action,
107107
]);
108+
109+
if (!$this->request->server('HTTPS', false))
110+
{
111+
$this->errors[] = $this->lang->lang('WEBPUSH_INSECURE_SERVER_ERROR');
112+
}
113+
114+
$this->display_errors();
108115
}
109116

110117
/**
@@ -135,13 +142,8 @@ public function save_settings()
135142
validate_config_vars($display_settings, $config_array, $this->errors);
136143
}
137144

138-
if (count($this->errors))
145+
if ($this->display_errors())
139146
{
140-
$this->template->assign_vars([
141-
'S_ERROR' => (bool) count($this->errors),
142-
'ERROR_MSG' => implode('<br>', $this->errors),
143-
]);
144-
145147
return;
146148
}
147149

@@ -154,4 +156,21 @@ public function save_settings()
154156

155157
trigger_error($this->lang->lang('CONFIG_UPDATED') . adm_back_link($this->u_action), E_USER_NOTICE);
156158
}
159+
160+
/**
161+
* Display any errors
162+
*
163+
* @return bool
164+
*/
165+
public function display_errors()
166+
{
167+
$has_errors = (bool) count($this->errors);
168+
169+
$this->template->assign_vars([
170+
'S_ERROR' => $has_errors,
171+
'ERROR_MSG' => $has_errors ? implode('<br>', $this->errors) : '',
172+
]);
173+
174+
return $has_errors;
175+
}
157176
}

language/en/webpushnotifications_module_acp.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,5 @@
5050
'WEBPUSH_METHOD_ENABLED_EXPLAIN'=> 'When this setting is enabled, users who subscribe and allow browser notifications will start receiving them automatically. They only need to visit the UCP Notification settings to disable any unwanted notifications.<br><br>If this setting is disabled, users will not receive any notifications, even if they have subscribed, until they visit the UCP Notification settings to enable the specific notifications they wish to receive.',
5151
'WEBPUSH_DROPDOWN_SUBSCRIBE' => 'Show “Subscribe” button in notification dropdown',
5252
'WEBPUSH_DROPDOWN_SUBSCRIBE_EXPLAIN'=> 'Enable or disable the “Subscribe” button in the Notification dropdown, allowing users to easily subscribe to push notifications from any page of the forum.',
53+
'WEBPUSH_INSECURE_SERVER_ERROR' => 'This board is not using a secure SSL/HTTPS server protocol, which is required to enable and use web push notifications.',
5354
]);

language/ru/webpushnotifications_module_acp.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,5 @@
5050
'WEBPUSH_METHOD_ENABLED_EXPLAIN'=> 'Если включено, то пользователи, подписавшиеся на браузерные push—уведомления, будут автоматически получать все их типы. Если отключено, то пользователи не будут получать браузерные push—уведомления до тех пор, пока хотя бы один их тип не выбран.<br><br>Отключить нежелательные или выбрать нужные типы браузерных push—уведомлений можно в настройках уведомлений в Личном разделе.',
5151
'WEBPUSH_DROPDOWN_SUBSCRIBE' => 'Показать кнопку «Подписаться» в выпадающем меню уведомлений',
5252
'WEBPUSH_DROPDOWN_SUBSCRIBE_EXPLAIN'=> 'Включить или отключить отображение кнопки «Подписаться» в выпадающем списке уведомлений. Если включено, то пользователи смогут подписываться на браузерные push-уведомления с любой страницы конференции.',
53+
'WEBPUSH_INSECURE_SERVER_ERROR' => 'This board is not using a secure SSL/HTTPS server protocol, which is required to enable and use web push notifications.',
5354
]);

0 commit comments

Comments
 (0)