Skip to content

Commit

Permalink
Show values of [MIN|MAX]_POST_PREVIEW_LENGTH in ACP module
Browse files Browse the repository at this point in the history
  • Loading branch information
m-ober committed Mar 31, 2024
1 parent 355aa12 commit 062dee8
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 36 deletions.
73 changes: 44 additions & 29 deletions acp/discord_notifications_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,33 +126,34 @@ public function main($id, $mode)

// Assign template values so that the page reflects the state of the extension settings
$this->template->assign_vars([
'DN_MASTER_ENABLE' => $this->config['discord_notifications_enabled'],
'DN_POST_PREVIEW_LENGTH' => $this->config['discord_notifications_post_preview_length'],
'DN_TEST_MESSAGE_TEXT' => $this->language->lang('DN_TEST_MESSAGE_TEXT'),
'DN_CONNECT_TIMEOUT' => $this->config['discord_notifications_connect_timeout'],
'DN_EXEC_TIMEOUT' => $this->config['discord_notifications_exec_timeout'],

'DN_POST_CREATE' => $this->config['discord_notification_type_post_create'],
'DN_POST_UPDATE' => $this->config['discord_notification_type_post_update'],
'DN_POST_DELETE' => $this->config['discord_notification_type_post_delete'],
'DN_POST_LOCK' => $this->config['discord_notification_type_post_lock'],
'DN_POST_UNLOCK' => $this->config['discord_notification_type_post_unlock'],
'DN_POST_APPROVE' => $this->config['discord_notification_type_post_approve'],

'DN_TOPIC_CREATE' => $this->config['discord_notification_type_topic_create'],
'DN_TOPIC_UPDATE' => $this->config['discord_notification_type_topic_update'],
'DN_TOPIC_DELETE' => $this->config['discord_notification_type_topic_delete'],
'DN_TOPIC_LOCK' => $this->config['discord_notification_type_topic_lock'],
'DN_TOPIC_UNLOCK' => $this->config['discord_notification_type_topic_unlock'],
'DN_TOPIC_APPROVE' => $this->config['discord_notification_type_topic_approve'],

'DN_USER_CREATE' => $this->config['discord_notification_type_user_create'],
'DN_USER_DELETE' => $this->config['discord_notification_type_user_delete'],

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

'DN_CURL_AVAILABLE' => $this->curl_available,
'U_ACTION' => $this->u_action,
'DN_MASTER_ENABLE' => $this->config['discord_notifications_enabled'],
'DN_POST_PREVIEW_LENGTH' => $this->config['discord_notifications_post_preview_length'],
'DN_POST_PREVIEW_DESCRIPTION' => sprintf($this->language->lang('DN_POST_PREVIEW_DESCRIPTION'), self::MIN_POST_PREVIEW_LENGTH, self::MAX_POST_PREVIEW_LENGTH),
'DN_TEST_MESSAGE_TEXT' => $this->language->lang('DN_TEST_MESSAGE_TEXT'),
'DN_CONNECT_TIMEOUT' => $this->config['discord_notifications_connect_timeout'],
'DN_EXEC_TIMEOUT' => $this->config['discord_notifications_exec_timeout'],

'DN_POST_CREATE' => $this->config['discord_notification_type_post_create'],
'DN_POST_UPDATE' => $this->config['discord_notification_type_post_update'],
'DN_POST_DELETE' => $this->config['discord_notification_type_post_delete'],
'DN_POST_LOCK' => $this->config['discord_notification_type_post_lock'],
'DN_POST_UNLOCK' => $this->config['discord_notification_type_post_unlock'],
'DN_POST_APPROVE' => $this->config['discord_notification_type_post_approve'],

'DN_TOPIC_CREATE' => $this->config['discord_notification_type_topic_create'],
'DN_TOPIC_UPDATE' => $this->config['discord_notification_type_topic_update'],
'DN_TOPIC_DELETE' => $this->config['discord_notification_type_topic_delete'],
'DN_TOPIC_LOCK' => $this->config['discord_notification_type_topic_lock'],
'DN_TOPIC_UNLOCK' => $this->config['discord_notification_type_topic_unlock'],
'DN_TOPIC_APPROVE' => $this->config['discord_notification_type_topic_approve'],

'DN_USER_CREATE' => $this->config['discord_notification_type_user_create'],
'DN_USER_DELETE' => $this->config['discord_notification_type_user_delete'],

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

'DN_CURL_AVAILABLE' => $this->curl_available,
'U_ACTION' => $this->u_action,
]);
}

Expand Down Expand Up @@ -247,12 +248,26 @@ private function process_settings_form_submit()
// Verify that the post preview length is a numeric string, convert to an int and check the valid range
if (!is_numeric($preview_length))
{
trigger_error($this->language->lang('DN_POST_PREVIEW_INVALID') . adm_back_link($this->u_action), E_USER_WARNING);
trigger_error(
sprintf(
$this->language->lang('DN_POST_PREVIEW_INVALID'),
self::MIN_POST_PREVIEW_LENGTH,
self::MAX_POST_PREVIEW_LENGTH
) . adm_back_link($this->u_action),
E_USER_WARNING
);
}
$preview_length = (int) $preview_length;
if ($preview_length != 0 && ($preview_length < self::MIN_POST_PREVIEW_LENGTH || $preview_length > self::MAX_POST_PREVIEW_LENGTH))
{
trigger_error($this->language->lang('DN_POST_PREVIEW_INVALID') . adm_back_link($this->u_action), E_USER_WARNING);
trigger_error(
sprintf(
$this->language->lang('DN_POST_PREVIEW_INVALID'),
self::MIN_POST_PREVIEW_LENGTH,
self::MAX_POST_PREVIEW_LENGTH
) . adm_back_link($this->u_action),
E_USER_WARNING
);
}

$connect_timeout = max(1, (int) $this->request->variable('dn_connect_to', 0));
Expand Down
2 changes: 1 addition & 1 deletion adm/style/acp_discord_notifications_settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h1>{{ lang('ACP_DISCORD_NOTIFICATIONS') }}</h1>
<label><input type="radio" class="radio" name="dn_master_enable" value="0" {% if not DN_MASTER_ENABLE %}checked="checked"{% endif %} /> {{ lang('NO') }}</label></dd>
</dl>
<dl>
<dt><label for="dn_post_preview_length">{{ lang('DN_POST_PREVIEW_LENGTH') }}{{ lang('COLON') }}</label><br /><span>{{ lang('DN_POST_PREVIEW_DESCRIPTION') }}</span></dt>
<dt><label for="dn_post_preview_length">{{ lang('DN_POST_PREVIEW_LENGTH') }}{{ lang('COLON') }}</label><br /><span>{{ DN_POST_PREVIEW_DESCRIPTION }}</span></dt>
<dd>
<input id="dn_post_preview_length" name="dn_post_preview_length" type="text" value="{{ DN_POST_PREVIEW_LENGTH }}" size="4" maxlength="4" />
</dd>
Expand Down
4 changes: 2 additions & 2 deletions language/de/acp_discord_notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
'DN_MAIN_SETTINGS' => 'Konfiguration',
'DN_MASTER_ENABLE' => 'Discord Benachrichtigungen aktivieren',
'DN_POST_PREVIEW_LENGTH' => 'Länge der Vorschau',
'DN_POST_PREVIEW_DESCRIPTION' => 'Wie viele Zeichen eines Beitrags sollen in der Vorschau angezeigt werden? (10-2000, 0 deaktiviert die Vorschau)',
'DN_POST_PREVIEW_DESCRIPTION' => 'Wie viele Zeichen eines Beitrags sollen in der Vorschau angezeigt werden? (%1$d-%2$d), 0 deaktiviert die Vorschau)',
'DN_TEST_MESSAGE' => 'Nachricht',
'DN_TEST_MESSAGE_TEXT' => 'Dies ist ein Test: Hallo, Discord!',
'DN_TEST_DESCRIPTION' => 'Nachricht, die beim Starten eines Tests geschickt wird.',
Expand Down Expand Up @@ -80,5 +80,5 @@
// Success/Failure messages that can be generated once the user saves
'DN_SETTINGS_SAVED' => 'Einstellungen aktualisiert.',
'DN_WEBHOOK_URL_INVALID' => 'Die Webhook-URL ist ungültig. Bitte überprüfe die Konfiguration.',
'DN_POST_PREVIEW_INVALID' => 'Länge der Vorschau muss zwischen 10 und 2000 Zeichen sein (oder 0 zum Deaktivieren der Vorschau).',
'DN_POST_PREVIEW_INVALID' => 'Länge der Vorschau muss zwischen %1$d und %2$d Zeichen sein (oder 0 zum Deaktivieren der Vorschau).',
));
4 changes: 2 additions & 2 deletions language/en/acp_discord_notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
'DN_MAIN_SETTINGS' => 'Main Settings',
'DN_MASTER_ENABLE' => 'Enable Discord Notifications',
'DN_POST_PREVIEW_LENGTH' => 'Post Preview Length',
'DN_POST_PREVIEW_DESCRIPTION' => 'Specify the number of characters to display in a post preview (10 - 2000). A zero value disables post preview.',
'DN_POST_PREVIEW_DESCRIPTION' => 'Specify the number of characters to display in a post preview (%1$d-%2$d). A zero value disables post preview.',
'DN_TEST_MESSAGE' => 'Message',
'DN_TEST_MESSAGE_TEXT' => 'This is a test: Hello Discord!',
'DN_TEST_DESCRIPTION' => 'A message to send to Discord to verify that the connection with phpBB is functioning.',
Expand Down Expand Up @@ -80,5 +80,5 @@
// Success/Failure messages that can be generated once the user saves
'DN_SETTINGS_SAVED' => 'Discord Notification settings modified successfully.',
'DN_WEBHOOK_URL_INVALID' => 'Discord webhook URL must be a full and valid URL.',
'DN_POST_PREVIEW_INVALID' => 'Post preview length must be a number between 10 and 2000, or 0 to disable previews.',
'DN_POST_PREVIEW_INVALID' => 'Post preview length must be a number between %1$d and %2$d, or 0 to disable previews.',
));
4 changes: 2 additions & 2 deletions language/fr/acp_discord_notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
'DN_MAIN_SETTINGS' => 'Paramètres généraux',
'DN_MASTER_ENABLE' => 'Activer les notifications Discord',
'DN_POST_PREVIEW_LENGTH' => 'Longueur de l’aperçu des messages',
'DN_POST_PREVIEW_DESCRIPTION' => 'Permet de saisir le nombre de caractères à afficher dans l’aperçu des messages (10 - 2000). Définir sur la valeur 0 pour désactiver l’aperçu des messages.',
'DN_POST_PREVIEW_DESCRIPTION' => 'Permet de saisir le nombre de caractères à afficher dans l’aperçu des messages (%1$d-%2$d). Définir sur la valeur 0 pour désactiver l’aperçu des messages.',
'DN_TEST_MESSAGE' => 'Message',
'DN_TEST_MESSAGE_TEXT' => 'Texte du message de test : Hello Discord!',
'DN_TEST_DESCRIPTION' => 'Permet d’envoyer un message sur le serveur Discord afin de vérifier que la connexion avec phpBB est fonctionnelle.',
Expand Down Expand Up @@ -101,5 +101,5 @@
// Success/Failure messages that can be generated once the user saves
'DN_SETTINGS_SAVED' => 'Les paramètres de notification Discord ont été modifiés avec succès !',
'DN_WEBHOOK_URL_INVALID' => 'L’adresse URL Webhook du serveur Discord doit être complète et correspondre à une adresse URL valide.',
'DN_POST_PREVIEW_INVALID' => 'La longueur de l’aperçu des messages doit être comprise entre 10 et 2000 ou définie sur 0 pour la désactivation de l’aperçu.',
'DN_POST_PREVIEW_INVALID' => 'La longueur de l’aperçu des messages doit être comprise entre %1$d et %2$d ou définie sur 0 pour la désactivation de l’aperçu.',
));

0 comments on commit 062dee8

Please sign in to comment.