1 contact.admin.inc contact_settings_form($form, &$form_state)

Contact settings form.

@since 1.11.0

See also

contact_menu()

Related topics

File

core/modules/contact/contact.admin.inc, line 14
Admin page callbacks for the Contact module.

Code

function contact_settings_form($form, &$form_state) {
  $config = config('contact.settings');
  $form['#config'] = 'contact.settings';

  $form['fields'] = array(
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#title' => t("Fields"),
  );
  $form['fields']['phone'] = array(
    '#type' => 'select',
    '#title' => t('Phone number'),
    '#description' => t('Allow users to enter their phone number.'),
    '#options' => array(
      'optional' => t('Optional'),
      'required' => t('Required'),
    ),
    '#empty_value' => '',
    '#default_value' => $config->get('phone'),
  );
  $form['fields']['copy'] = array(
    '#type' => 'checkbox',
    '#title' => t("Allow users to send themselves a copy of the submission."),
    '#description' => t("Include a 'Send yourself a copy' checkbox on site-wide and personal contact forms."),
    '#default_value' => contact_show_personal_copy_checkbox()
  );

  $form['permissions_wrapper'] = array(
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#title' => t("Permissions"),
  );
  $form['permissions_wrapper']['permissions'] = contact_form_permissions();
  $form['permissions_wrapper']['permissions']['#tree'] = TRUE;

  $form['threshold'] = array(
    '#type' => 'fieldset',
    '#title' => t("Spam prevention"),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['threshold']['wrapper'] = array(
    '#type' => 'container',
    '#attributes' => array('class' => array('container-inline')),
  );
  $form['threshold']['wrapper']['contact_threshold_limit'] = array(
    '#type' => 'select',
    '#title' => t('Email send limit'),
    '#title_display' => 'invisible',
    '#options' => backdrop_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' => $config->get('contact_threshold_limit'),
    '#prefix' => '<span aria-hidden="true">' . t('Limit to') . '</span>',
  );
  $form['threshold']['wrapper']['contact_threshold_window'] = array(
    '#type' => 'select',
    '#title' => t('Email send time window'),
    '#title_display' => 'invisible',
    '#options' => array(0 => t('None (disabled)')) + backdrop_map_assoc(array(60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400), 'format_interval'),
    '#default_value' => $config->get('contact_threshold_window'),
    '#prefix' => '<span aria-hidden="true">' . t('messages per') . '</span>',
  );
  $form['threshold']['help'] = array(
    '#type' => 'item',
    '#description' => t("Limit the amount of emails that can be sent from contact forms, from the same IP, within a specific window of time. This helps prevent malicious users from sending multiple emails."),
  );

  $form['#submit'][] = 'contact_settings_form_submit';
  return system_settings_form($form);
}