Skip to content

Commit

Permalink
Show warning if ext-curl is not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
m-ober committed Nov 4, 2023
1 parent 1e30138 commit bf98ae9
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 1 deletion.
6 changes: 6 additions & 0 deletions acp/discord_notifications_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,13 @@ class discord_notifications_module
/** @var \phpbb\user */
protected $user;

/** @var bool */
private $curl_available;

public function main($id, $mode)
{
global $phpbb_container;

$this->cache = $phpbb_container->get('cache.driver');
$this->config = $phpbb_container->get('config');
$this->db = $phpbb_container->get('dbal.conn');
Expand All @@ -69,6 +73,7 @@ public function main($id, $mode)
$this->request = $phpbb_container->get('request');
$this->template = $phpbb_container->get('template');
$this->user = $phpbb_container->get('user');
$this->curl_available = extension_loaded('curl');

$this->language->add_lang('acp_discord_notifications', 'mober/discordnotifications');
$this->page_title = $this->language->lang('ACP_DISCORD_NOTIFICATIONS');
Expand Down Expand Up @@ -146,6 +151,7 @@ public function main($id, $mode)

'DN_DEFAULT_WEBHOOK' => $this->config['discord_notification_default_webhook'],

'DN_CURL_AVAILABLE' => $this->curl_available,
'U_ACTION' => $this->u_action,
));
}
Expand Down
6 changes: 6 additions & 0 deletions adm/style/acp_discord_notifications_mapping.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ <h1>{{ lang('ACP_DISCORD_NOTIFICATIONS') }}</h1>

<p>{{ DN_ACP_DESCRIPTION }}</p>

{% if not DN_CURL_AVAILABLE %}
<div class="errorbox">
<p>{{ lang('DN_MISSING_CURL') }}</p>
</div>
{% endif %}

<form id="acp_board" method="post" action="{{ U_ACTION }}">

<fieldset>
Expand Down
6 changes: 6 additions & 0 deletions adm/style/acp_discord_notifications_settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ <h1>{{ lang('ACP_DISCORD_NOTIFICATIONS') }}</h1>

<p>{{ DN_ACP_DESCRIPTION }}</p>

{% if not DN_CURL_AVAILABLE %}
<div class="errorbox">
<p>{{ lang('DN_MISSING_CURL') }}</p>
</div>
{% endif %}

<form id="acp_board" method="post" action="{{ U_ACTION }}">

<fieldset>
Expand Down
7 changes: 6 additions & 1 deletion adm/style/acp_discord_notifications_webhooks.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ <h1>{{ lang('ACP_DISCORD_NOTIFICATIONS') }}</h1>

<p>{{ DN_ACP_DESCRIPTION }}</p>

<form id="acp_board" method="post" action="{{ U_ACTION }}">
{% if not DN_CURL_AVAILABLE %}
<div class="errorbox">
<p>{{ lang('DN_MISSING_CURL') }}</p>
</div>
{% endif %}

<form id="acp_board" method="post" action="{{ U_ACTION }}">

<fieldset>
<legend>{{ lang('DN_WEBHOOK_SETTINGS') }}</legend>
Expand Down
1 change: 1 addition & 0 deletions language/de/acp_discord_notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
$lang = array_merge($lang, array(
// ACP Extension Settings Page
'DN_ACP_DESCRIPTION' => 'Diese Einstellungen erlauben es, bei verschiedenen Ereignissen eine Benachrichtigung an einen Discord-Kanal zu schicken.',
'DN_MISSING_CURL' => 'Damit diese Erweiterung funktioniert, musst du das <a href="https://www.php.net/manual/de/curl.installation.php">ext-curl Modul für PHP installieren.</a>',

'DN_MAIN_SETTINGS' => 'Konfiguration',
'DN_MASTER_ENABLE' => 'Discord Benachrichtigungen aktivieren',
Expand Down
1 change: 1 addition & 0 deletions language/en/acp_discord_notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
$lang = array_merge($lang, array(
// ACP Extension Settings Page
'DN_ACP_DESCRIPTION' => 'These settings allow for various forum events to send notification messages to a Discord server.',
'DN_MISSING_CURL' => 'Please install the <a href="https://www.php.net/manual/en/curl.installation.php">ext-curl module for PHP</a>, otherwise this extension will not work.',

'DN_MAIN_SETTINGS' => 'Main Settings',
'DN_MASTER_ENABLE' => 'Enable Discord Notifications',
Expand Down
1 change: 1 addition & 0 deletions language/fr/acp_discord_notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
$lang = array_merge($lang, array(
// ACP Extension Settings Page
'DN_ACP_DESCRIPTION' => 'Depuis cette page il est possible de définir les paramètres permettant à différents évènements du forum d’être envoyés comme notification sur un serveur Discord.',
'DN_MISSING_CURL' => 'Pour que cette extension fonctionne, tu dois installer le module <a href="https://www.php.net/manual/fr/curl.installation.php">ext-curl pour PHP</a>.',

'DN_MAIN_SETTINGS' => 'Paramètres généraux',
'DN_MASTER_ENABLE' => 'Activer les notifications Discord',
Expand Down

0 comments on commit bf98ae9

Please sign in to comment.