You are here

function apply_for_role_settings_form in Apply for role 7.2

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 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("Choosing '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['description'] = array(
    '#type' => 'textarea',
    '#title' => t('Apply for role description/instructions for visitors'),
    '#description' => t('All text entered here will be displayed in the apply for role form, both in page and in block listings.'),
    '#default_value' => variable_get('apply_for_role_intro_text'),
  );
  $form['email'] = array(
    '#type' => 'fieldset',
    '#title' => t('Apply for role email options'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['email']['apply_for_role_email_admin'] = array(
    '#type' => 'checkbox',
    '#title' => t('Send administrators email on approval'),
    '#default_value' => variable_get('apply_for_role_email_admin', 0),
    '#weight' => -10,
  );
  $form['email']['apply_for_role_email_admin_content'] = array(
    '#type' => 'fieldset',
    '#title' => t('Admin email settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#weight' => -5,
  );
  $form['email']['apply_for_role_email_admin_content']['apply_for_role_custom_admin_email'] = array(
    '#type' => 'textfield',
    '#title' => t('Admin email addressess'),
    '#description' => t('A comma seperated list of emails -OR- Leave blank to use site admin (UID 1) email address.'),
    '#default_value' => variable_get('apply_for_role_custom_admin_email', ''),
    '#size' => 60,
    '#maxlength' => 128,
  );
  $form['email']['apply_for_role_email_admin_content']['apply_for_role_email_admin_subject'] = array(
    '#type' => 'textfield',
    '#title' => t('Admin email subject'),
    '#default_value' => variable_get('apply_for_role_email_admin_subject', 'New role application.'),
    '#size' => 60,
    '#maxlength' => 128,
  );
  $form['email']['apply_for_role_email_admin_content']['apply_for_role_email_admin_body'] = array(
    '#type' => 'textarea',
    '#title' => t('Admin email message body'),
    '#description' => 'Body of the email. Use %USER for user name, and %ROLE for role(s) applied for. NO HTML ALLOWED without a custom extension of drupal.',
    '#default_value' => variable_get('apply_for_role_email_admin_body', 'An application has been submit by %USER for %ROLE.'),
    '#size' => 60,
  );
  $form['email']['apply_for_role_approve_email'] = array(
    '#type' => 'checkbox',
    '#title' => t('Send email on approval'),
    '#default_value' => variable_get('apply_for_role_approve_email', 0),
    '#weight' => -1,
  );
  $form['email']['send_approve_email_content'] = array(
    '#type' => 'fieldset',
    '#title' => t('Approval email settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#weight' => 0,
  );
  $form['email']['send_approve_email_content']['apply_for_role_approve_email_subject'] = array(
    '#type' => 'textfield',
    '#title' => t('Subject'),
    '#default_value' => variable_get('apply_for_role_approve_email_subject', 'Your role application has been approved.'),
    '#size' => 60,
    '#maxlength' => 128,
  );
  $form['email']['send_approve_email_content']['apply_for_role_approve_email_body'] = array(
    '#type' => 'textarea',
    '#title' => t('Message Body'),
    '#description' => 'Body of the email. Use %URL for your site URL, and %ROLE for approved role(s). NO HTML ALLOWED without a custom extension of drupal.',
    '#default_value' => variable_get('apply_for_role_approve_email_body', 'Your role application has been approved at %URL for %ROLE.'),
    '#size' => 60,
  );
  $form['email']['apply_for_role_deny_email'] = array(
    '#type' => 'checkbox',
    '#title' => t('Send email on Denial'),
    '#default_value' => variable_get('apply_for_role_deny_email', 0),
    '#weight' => 10,
  );
  $form['email']['send_denial_email_content'] = array(
    '#type' => 'fieldset',
    '#title' => t('Denial email settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#weight' => 15,
  );
  $form['email']['send_denial_email_content']['apply_for_role_denial_email_subject'] = array(
    '#type' => 'textfield',
    '#title' => t('Subject'),
    '#default_value' => variable_get('apply_for_role_denial_email_subject', 'Your role application has been denied.'),
    '#size' => 60,
    '#maxlength' => 128,
  );
  $form['email']['send_denial_email_content']['apply_for_role_denial_email_body'] = array(
    '#type' => 'textarea',
    '#title' => t('Message Body'),
    '#description' => 'Body of the email. Use %URL for your site URL, and %ROLE for denied role(s). NO HTML ALLOWED without a custom extension of drupal.',
    '#default_value' => variable_get('apply_for_role_denial_email_body', 'Your role application has been denied at %URL for %ROLE.'),
    '#size' => 60,
  );

  // Collapse email fieldset if neither approve or deny emails are configured
  if (variable_get('apply_for_role_deny_email') || variable_get('apply_for_role_approve_email')) {
    $form['email']['#collapsed'] = FALSE;
  }

  /* Submit button */
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Update'),
  );
  return $form;
}