You are here

function realname_registration_settings_form in Realname registration 6.2

Same name and namespace in other branches
  1. 7.2 realname_registration.admin.inc \realname_registration_settings_form()
  2. 7 realname_registration.admin.inc \realname_registration_settings_form()

Form builder;

See also

system_settings_form()

1 string reference to 'realname_registration_settings_form'
realname_registration_menu in ./realname_registration.module
Implementation of hook_menu().

File

./realname_registration.admin.inc, line 14
Admin page callbacks for the realname_registration module.

Code

function realname_registration_settings_form() {
  $form = array();
  if (!module_exists('content_profile_registration')) {
    variable_del('realname_registration_use_content_profile_firstname_field');
    variable_del('realname_registration_content_profile_firstname_field_node');
    variable_del('realname_registration_use_content_profile_middlename_field');
    variable_del('realname_registration_content_profile_middlename_field_node');
    variable_del('realname_registration_use_content_profile_lastname_field');
    variable_del('realname_registration_content_profile_lastname_field_node');
  }
  $field_req = '<ul><li>' . t('The field name is correct and represents an existing profile field') . '</li><li>' . t('The field is required and displays on the registration form') . '</li></ul>';
  $form['fields'] = array(
    '#type' => 'fieldset',
    '#title' => t('Realname registration fields'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['fields']['firstname'] = array(
    '#type' => 'fieldset',
    '#title' => t('First name field'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['fields']['firstname']['realname_registration_firstname_field'] = array(
    '#type' => 'textfield',
    '#title' => t('First name field'),
    '#required' => TRUE,
    '#default_value' => variable_get('realname_registration_firstname_field', ''),
    '#description' => t('The name of your first name field. Ensure that:') . $field_req,
  );
  $form['fields']['firstname']['realname_registration_firstname_field_category'] = array(
    '#type' => 'value',
    '#value' => variable_get('realname_registration_firstname_field_category', ''),
  );
  if (module_exists('content_profile_registration')) {
    $form['fields']['firstname']['content_profile_firstname'] = array(
      '#type' => 'fieldset',
      '#title' => t('Content profile first name'),
      '#collapsible' => TRUE,
      '#collapsed' => FALSE,
    );
    $form['fields']['firstname']['content_profile_firstname']['realname_registration_use_content_profile_firstname_field'] = array(
      '#type' => 'checkbox',
      '#title' => t('Use the content profile module to store your first names.'),
      '#default_value' => variable_get('realname_registration_use_content_profile_firstname_field', 0),
      '#description' => t('When this checkbox is checked, Realname registration will use content profile fields to store first names.'),
    );
    $form['fields']['firstname']['content_profile_firstname']['realname_registration_content_profile_firstname_field_node'] = array(
      '#title' => t('Content profile type'),
      '#type' => 'textfield',
      '#default_value' => variable_get('realname_registration_content_profile_firstname_field_node', ''),
      '#description' => t('Please provide the machine name of the Content profile you wish for Realname registration to use.'),
    );
  }
  $form['fields']['middlename'] = array(
    '#type' => 'fieldset',
    '#title' => t('Middle name field'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['fields']['middlename']['realname_registration_middlename_field'] = array(
    '#type' => 'textfield',
    '#title' => t('Middle name field'),
    '#default_value' => variable_get('realname_registration_middlename_field', ''),
    '#description' => t('The name of your middle name field. Ensure that:') . '<ul><li>' . t('The field name is correct and represents an existing profile field') . '</li><li>' . t('The field is displayed on the registration form') . '</li></ul>',
  );
  $form['fields']['middlename']['realname_registration_middlename_field_category'] = array(
    '#type' => 'value',
    '#value' => variable_get('realname_registration_middlename_field_category', ''),
  );
  if (module_exists('content_profile_registration')) {
    $form['fields']['middlename']['content_profile_middlename'] = array(
      '#type' => 'fieldset',
      '#title' => t('Content profile middle name'),
      '#collapsible' => TRUE,
      '#collapsed' => FALSE,
    );
    $form['fields']['middlename']['content_profile_middlename']['realname_registration_use_content_profile_middlename_field'] = array(
      '#type' => 'checkbox',
      '#title' => t('Use the content profile module to store your middle names.'),
      '#default_value' => variable_get('realname_registration_use_content_profile_middlename_field', 0),
      '#description' => t('When this checkbox is checked, Realname registration will use content profile fields to store middle names.'),
    );
    $form['fields']['middlename']['content_profile_middlename']['realname_registration_content_profile_middlename_field_node'] = array(
      '#title' => t('Content profile type'),
      '#type' => 'textfield',
      '#default_value' => variable_get('realname_registration_content_profile_middlename_field_node', ''),
      '#description' => t('Please provide the machine name of the Content profile you wish for Realname registration to use.'),
    );
  }
  $form['fields']['lastname'] = array(
    '#type' => 'fieldset',
    '#title' => t('Last name field'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['fields']['lastname']['realname_registration_lastname_field'] = array(
    '#type' => 'textfield',
    '#title' => t('Last name field'),
    '#required' => TRUE,
    '#default_value' => variable_get('realname_registration_lastname_field', ''),
    '#description' => t('The name of your last name field. Ensure that:') . $field_req,
  );
  $form['fields']['lastname']['realname_registration_lastname_field_category'] = array(
    '#type' => 'value',
    '#value' => variable_get('realname_registration_lastname_field_category', ''),
  );
  if (module_exists('content_profile_registration')) {
    $form['fields']['lastname']['content_profile_lastname'] = array(
      '#type' => 'fieldset',
      '#title' => t('Content profile last name'),
      '#collapsible' => TRUE,
      '#collapsed' => FALSE,
    );
    $form['fields']['lastname']['content_profile_lastname']['realname_registration_use_content_profile_lastname_field'] = array(
      '#type' => 'checkbox',
      '#title' => t('Use the content profile module to store your last names.'),
      '#default_value' => variable_get('realname_registration_use_content_profile_lastname_field', 0),
      '#description' => t('When this checkbox is checked, Realname registration will use content profile fields to store last names.'),
    );
    $form['fields']['lastname']['content_profile_lastname']['realname_registration_content_profile_lastname_field_node'] = array(
      '#title' => t('Content profile type'),
      '#type' => 'textfield',
      '#default_value' => variable_get('realname_registration_content_profile_lastname_field_node', ''),
      '#description' => t('Please provide the machine name of the Content profile you wish for Realname registration to use.'),
    );
  }
  $form['fields']['realname_registration_ucfirst'] = array(
    '#type' => 'checkbox',
    '#title' => t('Force the first letters of the first, middle, and last names to uppercase'),
    '#default_value' => variable_get('realname_registration_ucfirst', 1),
    '#description' => t("Ensures that the first letter of the users first name, middle name, and last name are capitalized."),
  );
  $form['username_format'] = array(
    '#type' => 'fieldset',
    '#title' => t('Realname registration username creation'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['username_format']['realname_registration_format'] = array(
    '#type' => 'radios',
    '#title' => t('Username format'),
    '#description' => t('Select the format in which Realname registration will create new usernames.'),
    '#default_value' => variable_get('realname_registration_format', 0),
    '#options' => array(
      t('First name and last name (e.g., John Smith)'),
      t('First initial and last name (e.g., JSmith)'),
      t('First name, middle name, and last name (e.g., John Jacob Smith)'),
      t('First name, middle initial, and last name (e.g., John J Smith)'),
      t('First initial, middle initial, and last name (e.g., JJSmith)'),
      t('First name and last name without spaces (e.g., JohnSmith)'),
      t('First name, middle name, and last name without spaces (e.g., JohnJacobSmith)'),
      t('First name, middle initial, and last name without spaces (e.g., JohnJSmith)'),
    ),
    '#required' => TRUE,
  );
  $form['username_format']['realname_registration_tolower'] = array(
    '#type' => 'checkbox',
    '#title' => t('Force lowercase'),
    '#default_value' => variable_get('realname_registration_tolower', 1),
    '#description' => t("Usernames will be created using only lowercase characters."),
  );
  $form['username_format']['realname_registration_use_validation'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use Realname registration validation'),
    '#default_value' => variable_get('realname_registration_use_validation', 1),
    '#description' => t('Ensure that names contain only letters, hyphens, and apostrophes.'),
  );
  $form['#validate'][] = 'realname_registration_settings_validate';
  return system_settings_form($form);
}