As part of the move of OG Contact to D7, I was looking through Contact module's code and saw that is uses flood control for its now hidden threshold variables. I have decided to move in that direction for OG Contact.

When looking at flood control, I realized that it didn't provide any way for me to do that.

This patch creates hook_flood_control_add_setting(), which allows other modules to add items to the flood control settings page.

I have also attached a new api file for documentation; though that probably needs to be worked on a bit.

When implemented by another module it looks something like:

/**
 * Implements hook_flood_control_add_setting().
 */
function og_contact_flood_control_add_setting($form) {
    // Contact module flood events.
  $form['og_contact'] = array(
    '#type' => 'fieldset',
    '#title' => t('OG Contact forms'),
    '#access' => user_access('administer og contact form'),
  );
  $form['og_contact']['og_contact_threshold_limit'] = array(
    '#type' => 'select',
    '#title' => t('Sending e-mails limit'),
    '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 75, 100, 125, 150, 200, 250, 500)),
    '#default_value' => variable_get('og_contact_threshold_limit', 3),
  );
  $form['og_contact']['og_contact_threshold_window'] = array(
    '#type' => 'select',
    '#title' => t('Sending e-mails window'),
    '#options' => array(0 => t('None (disabled)')) + drupal_map_assoc(array(60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400), 'format_interval'),
    '#default_value' => variable_get('og_contact_threshold_window', 3600),
  );
  return $form;
}

It is currently working for me.

Comments

gnat’s picture

I'm following up, to see if a patch like this will ever be included in flood control. I don't mind if it isn't, but I just want to know if I should make different plans for OG Contact's flood control settings.

damienmckenna’s picture

Any reason to not just use hook_form_alter()?

batigolix’s picture

Status: Needs review » Closed (won't fix)

I close this because it is a request for the 7.x version.