You are here

function profanity_admin_settings in Profanity 7

Admin settings form callback.

1 string reference to 'profanity_admin_settings'
profanity_menu in ./profanity.module
Implements hook_menu().

File

./profanity.module, line 433
Main {profanity} file.

Code

function profanity_admin_settings() {
  $form = array();
  $form['profanity_protect_the_titles'] = array(
    '#type' => 'checkbox',
    '#title' => t('Run profanity filters on Entity titles?'),
    '#default_value' => variable_get('profanity_protect_the_titles', 0),
    '#description' => t('Tick this to enable more options.'),
  );
  $form['titles'] = array(
    '#type' => 'fieldset',
    '#title' => t('Entity title settings'),
    '#states' => array(
      'visible' => array(
        ':input[id="edit-profanity-protect-the-titles"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $entity_options = array();
  foreach (entity_get_info() as $entity_type => $entity_info) {
    $entity_options[$entity_type] = filter_xss($entity_info['label']);
  }
  $form['titles']['profanity_title_entities'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Which Entity types should have their titles processed?'),
    '#options' => $entity_options,
    '#default_value' => variable_get('profanity_title_entities', array()),
    '#states' => array(
      'required' => array(
        ':input[id="edit-profanity-protect-the-titles"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['titles']['profanity_title_lists'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Which lists should be applied?'),
    '#options' => profanity_get_lists_flat(),
    '#default_value' => variable_get('profanity_title_lists', array()),
    '#states' => array(
      'required' => array(
        ':input[id="edit-profanity-protect-the-titles"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['profanity_supply_entity_properties'] = array(
    '#type' => 'checkbox',
    '#title' => t('Supply a profanity filtered title property for all entities'),
    '#default_value' => variable_get('profanity_supply_entity_properties', 0),
  );
  $form['profanity_supply_entity_properties_fieldset'] = array(
    '#type' => 'fieldset',
    '#title' => t('User registration validation settings'),
    '#states' => array(
      'visible' => array(
        ':input[id="edit-profanity-supply-entity-properties"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['profanity_supply_entity_properties_fieldset']['profanity_supply_entity_properties_lists'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Which lists should be applied?'),
    '#options' => profanity_get_lists_flat(),
    '#default_value' => variable_get('profanity_supply_entity_properties_lists', array()),
    '#states' => array(
      'required' => array(
        ':input[id="edit-profanity-supply-entity-properties"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['profanity_protect_user_reg'] = array(
    '#type' => 'checkbox',
    '#title' => t('Prevent users registering with a username that contains matches'),
    '#default_value' => variable_get('profanity_protect_user_reg', 0),
    '#description' => t("Tick this to choose which lists are run against the entered username. Users won't be able to register until they choose a username which doesn't contain a matched word."),
  );
  $form['user_reg'] = array(
    '#type' => 'fieldset',
    '#title' => t('User registration validation settings'),
    '#states' => array(
      'visible' => array(
        ':input[id="edit-profanity-protect-user-reg"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['user_reg']['profanity_protect_user_reg_lists'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Which lists should be applied?'),
    '#options' => profanity_get_lists_flat(),
    '#default_value' => variable_get('profanity_protect_user_reg_lists', array()),
    '#states' => array(
      'required' => array(
        ':input[id="edit-profanity-protect-user-reg"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['user_reg']['profanity_protect_user_reg_message'] = array(
    '#type' => 'textfield',
    '#title' => t('Error message to display when matched words are found'),
    '#default_value' => variable_get('profanity_protect_user_reg_message', "The username you've entered contains a word or words which aren't allowed."),
    '#states' => array(
      'required' => array(
        ':input[id="edit-profanity-protect-user-reg"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  return system_settings_form($form);
}