You are here

function apply_for_role_settings_form in Apply for role 7

Same name and namespace in other branches
  1. 5 apply_for_role.module \apply_for_role_settings_form()
  2. 6 apply_for_role.admin.inc \apply_for_role_settings_form()
  3. 7.2 apply_for_role.admin.inc \apply_for_role_settings_form()
1 string reference to 'apply_for_role_settings_form'
apply_for_role_menu in ./apply_for_role.module
Implements hook_menu().

File

./apply_for_role.admin.inc, line 15
Administration forms for the Apply for Role (AFR) module.

Code

function apply_for_role_settings_form($form, $form_state) {
  $selected_roles = variable_get('users_apply_roles', array());
  if (!empty($selected_roles)) {
    foreach ((array) $selected_roles as $rid => $value) {
      if ($rid > 2) {
        $selected_rids[] = $rid;
      }
    }
  }
  $form['options'] = array(
    '#type' => 'fieldset',
    '#title' => t('Apply for role options'),
  );
  $form['options']['multiple'] = array(
    '#type' => 'radios',
    '#title' => t('Allow multiple roles per application'),
    '#options' => array(
      t('No'),
      t('Yes'),
    ),
    '#default_value' => variable_get('apply_for_role_multiple', 0),
    '#description' => t("Chosing 'no' will limit users to applying for only one role per role application. Choosing 'yes' will allow users to apply for multiple roles per role application."),
    '#required' => TRUE,
  );
  $form['options']['register'] = array(
    '#type' => 'radios',
    '#title' => t('Apply for role on registration'),
    '#options' => array(
      t('No'),
      t('Optional'),
      t('Required'),
    ),
    '#default_value' => variable_get('apply_for_role_register', 0),
    '#description' => t("Choosing 'optional' will allow users to apply for roles when creating a new account. Choosing 'required' will require users to apply for roles when creating a new account."),
    '#required' => TRUE,
  );
  $form['options']['display_approved'] = array(
    '#type' => 'radios',
    '#title' => t('Display approved roles in an application form'),
    '#options' => array(
      t('No'),
      t('Yes'),
    ),
    '#default_value' => variable_get('apply_for_role_display_approved', 0),
    '#description' => t("Choosing 'yes' will allow a user to see which role applications were approved."),
    '#required' => TRUE,
  );
  $form['options']['apply_for_role_allow_message'] = array(
    '#type' => 'radios',
    '#title' => t('Allow application message'),
    '#options' => array(
      t('No'),
      t('Yes'),
    ),
    '#default_value' => variable_get('apply_for_role_allow_message', 0),
    '#description' => t("Allows applicants to submit a message along with each application, explaining why they need the role."),
  );
  $roles = user_roles(TRUE);
  unset($roles[DRUPAL_AUTHENTICATED_RID]);
  $form['roles'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Roles'),
    '#default_value' => isset($selected_rids) ? $selected_rids : array(
      2,
    ),
    '#options' => $roles,
    '#description' => t('Select the roles that users will be able to apply for.'),
    '#required' => TRUE,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Update'),
  );
  return $form;
}