Browse Source

#666 mauvais nom du flood d'inscription. Ajout d'un reglage.

FGM 13 years ago
parent
commit
0796aa9f27
2 changed files with 18 additions and 2 deletions
  1. 15 0
      fgcf.admin.inc
  2. 3 2
      fgcf.module

+ 15 - 0
fgcf.admin.inc

@@ -30,6 +30,21 @@ function fgcf_admin_settings() {
     '#default_value' => variable_get($mail_destination, variable_get('site_mail', 'support@osinet.fr')),
   );
 
+  $flood = 'fgcf_subscribe_flood';
+  $form[$flood] = array(
+    '#type' => 'select',
+    '#title' => t("Limite d'inscriptions"),
+    '#options' => array(
+      '0'  => t('Pas de limite'),
+      '1'  => '1',
+      '2'  => '2',
+      '5'  => '5',
+      '10' => '10',
+    ),
+    '#description' => t("Nombre maximum de demandes d'inscription toutes formations confondues, par personne et par heure"),
+    '#default_value' => variable_get($flood, '10'),
+  );
+
   $ret = system_settings_form($form);
   return $ret;
 }

+ 3 - 2
fgcf.module

@@ -368,7 +368,8 @@ function fgcf_subscribe_form_submit($form, &$form_state) {
   global $user;
 
   // Prevent flooding.
-  if (flood_is_allowed('fgcg_subscribe', 10)) {
+  $flood_limit = variable_get('fgcf_subscribe_flood', 10);
+  if ($flood_limit && flood_is_allowed('fgcf_subscribe', $flood_limit)) {
     $to = variable_get('fgcf_mail_destination', variable_get('site_mail', ini_get('sendmail_from')));
     $params = array(
       'account' => $user,
@@ -378,7 +379,7 @@ function fgcf_subscribe_form_submit($form, &$form_state) {
     $message = drupal_mail('fgcf', 'subscribe', $to, language_default(), $params);
     if ($message['result']) {
       drupal_set_message(t("Votre demande a été transmise aux administrateurs du site."));
-      flood_register_event('fgcg_subscribe');
+      flood_register_event('fgcf_subscribe');
     }
   }
 }