You are here

function autoassignrole_user_settings in Auto Assign Role 7.2

Same name and namespace in other branches
  1. 7 autoassignrole.admin.inc \autoassignrole_user_settings()

Form builder; The settings form for user selectable role assignment.

See also

system_settings_form()

1 string reference to 'autoassignrole_user_settings'
autoassignrole_menu in ./autoassignrole.module
Implements hook_menu().

File

./autoassignrole.admin.inc, line 82
Administrative functionality for auto assign role.

Code

function autoassignrole_user_settings() {
  $form['autoassignrole_user_active'] = array(
    '#type' => 'radios',
    '#title' => t('User role assignment'),
    '#default_value' => variable_get('autoassignrole_user_active', 0),
    '#description' => t('Toggles allowing end users to select roles when creating their accounts.'),
    '#options' => array(
      1 => t('Enabled'),
      0 => t('Disabled'),
    ),
  );
  if ($roles = autoassignrole_get_roles()) {
    $form['autoassignrole_user_roles'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Roles'),
      '#default_value' => variable_get('autoassignrole_user_roles', array()),
      '#description' => t('Check the specific roles the user will have the option of choosing. The Authenticated User role is automatically assigned by Drupal core and can not be edited.'),
      '#options' => $roles,
      '#states' => array(
        'visible' => array(
          ':input[name="autoassignrole_user_active"]' => array(
            'value' => 1,
          ),
        ),
      ),
    );
  }
  $form['autoassignrole_user_multiple'] = array(
    '#type' => 'radios',
    '#title' => t('User role selection'),
    '#default_value' => variable_get('autoassignrole_user_multiple', 0),
    '#description' => t('Should the end user be allowed to choose a single role or can they choose multiple roles?'),
    '#options' => array(
      0 => t('Single role'),
      1 => t('Multiple roles'),
    ),
    '#states' => array(
      'visible' => array(
        ':input[name="autoassignrole_user_active"]' => array(
          'value' => 1,
        ),
      ),
    ),
  );
  $form['autoassignrole_user_selection'] = array(
    '#type' => 'radios',
    '#title' => t('Selection method'),
    '#default_value' => variable_get('autoassignrole_user_selection', AUTOASSIGNROLE_ELEMENT_RADIO_CHECKBOX),
    '#description' => t('The type of form elements the end user will be presented with.'),
    '#options' => array(
      AUTOASSIGNROLE_ELEMENT_RADIO_CHECKBOX => t('Radio Buttons/Checkboxes'),
      AUTOASSIGNROLE_ELEMENT_SELECT => t('Selection Box'),
    ),
    '#states' => array(
      'visible' => array(
        ':input[name="autoassignrole_user_active"]' => array(
          'value' => 1,
        ),
      ),
    ),
  );
  $form['autoassignrole_user_required'] = array(
    '#type' => 'radios',
    '#title' => t('Required'),
    '#default_value' => variable_get('autoassignrole_user_required', 0),
    '#description' => t('Should the end user be required to choose a role?'),
    '#options' => array(
      0 => t('No'),
      1 => t('Yes'),
    ),
    '#states' => array(
      'visible' => array(
        ':input[name="autoassignrole_user_active"]' => array(
          'value' => 1,
        ),
      ),
    ),
  );
  $form['autoassignrole_user_sort'] = array(
    '#type' => 'radios',
    '#title' => t('Sorting'),
    '#default_value' => variable_get('autoassignrole_user_sort', 'SORT_ASC'),
    '#description' => t('Default sort order of roles the user will see.'),
    '#options' => array(
      'SORT_ASC' => t('Ascending'),
      'SORT_DESC' => t('Descending'),
      'SORT_WEIGHT' => t('Weight of field'),
    ),
    '#states' => array(
      'visible' => array(
        ':input[name="autoassignrole_user_active"]' => array(
          'value' => 1,
        ),
      ),
    ),
  );

  // Set the user description filter format.
  $autoassignrole_user_description = _autoassignrole_get_user_description();
  $form['autoassignrole_user_description'] = array(
    '#type' => 'text_format',
    '#title' => t('User Role Description'),
    '#description' => t('The description displayed to the end user when they are selecting their role during registration.'),
    '#default_value' => $autoassignrole_user_description['value'],
    '#required' => FALSE,
    '#format' => $autoassignrole_user_description['format'],
    '#prefix' => '<div id="autoassignrole_user_description_wrapper">',
    '#suffix' => '</div>',
  );
  $form['autoassignrole_user_fieldset_title'] = array(
    '#type' => 'textfield',
    '#title' => t('User Role Fieldset Title'),
    '#description' => t('The title of the fieldset that contains role options.'),
    '#default_value' => variable_get('autoassignrole_user_fieldset_title', t('User Roles')),
    '#size' => 60,
    '#maxlength' => 128,
    '#states' => array(
      'visible' => array(
        ':input[name="autoassignrole_user_active"]' => array(
          'value' => 1,
        ),
      ),
    ),
  );
  $form['autoassignrole_user_title'] = array(
    '#type' => 'textfield',
    '#title' => t('User Role Title'),
    '#description' => t('The title of the field that contains the role options the end user sees during registration.'),
    '#default_value' => variable_get('autoassignrole_user_title', t('Role')),
    '#size' => 60,
    '#maxlength' => 128,
    '#required' => FALSE,
    '#states' => array(
      'visible' => array(
        ':input[name="autoassignrole_user_active"]' => array(
          'value' => 1,
        ),
      ),
    ),
  );
  return system_settings_form($form);
}