You are here

function apply_for_role_apply_form in Apply for role 6

Same name and namespace in other branches
  1. 5 apply_for_role.module \apply_for_role_apply_form()
  2. 7.2 apply_for_role.module \apply_for_role_apply_form()
  3. 7 apply_for_role.module \apply_for_role_apply_form()

Implementation of hook_form().

1 string reference to 'apply_for_role_apply_form'
apply_for_role_menu in ./apply_for_role.module
Implementation of hook_menu().

File

./apply_for_role.module, line 137
Allows users to apply for roles.

Code

function apply_for_role_apply_form(&$form_state, $user) {
  drupal_set_title(check_plain($user->name));
  $form = array();
  $filter_roles = apply_for_role_available_roles($user);
  if (count($filter_roles)) {
    $form['user'] = array(
      '#type' => 'value',
      '#value' => $user,
    );

    // List of roles that were already approved.
    $approved = apply_for_role_approved_roles($user);
    if (variable_get('apply_for_role_display_approved', 0) && count($approved)) {
      $form['approved'] = array(
        '#value' => theme('item_list', $approved, t('You have applied for these roles and were approved:')),
      );
    }
    $form['rid'] = array(
      '#type' => variable_get('apply_for_role_multiple', 0) ? 'checkboxes' : 'select',
      '#title' => variable_get('apply_for_role_multiple', 0) ? t('Select a role or roles') : t('Select a role'),
      '#options' => $filter_roles,
    );
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Apply'),
    );
  }
  else {
    drupal_set_message(t('No roles are available at this time.'));
  }
  return $form;
}