function apply_for_role_apply_form in Apply for role 7
Same name and namespace in other branches
- 5 apply_for_role.module \apply_for_role_apply_form()
- 6 apply_for_role.module \apply_for_role_apply_form()
- 7.2 apply_for_role.module \apply_for_role_apply_form()
Callback for the apply for role form.
1 string reference to 'apply_for_role_apply_form'
- apply_for_role_menu in ./
apply_for_role.module - Implements hook_menu().
File
- ./
apply_for_role.module, line 225 - Allows users to apply for roles.
Code
function apply_for_role_apply_form($form, $form_state, $user) {
drupal_set_title($user->name);
// 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(
'#markup' => theme('item_list', array(
'title' => t('Approved roles'),
'items' => $approved,
)),
);
}
$filter_roles = apply_for_role_available_roles($user);
if (count($filter_roles)) {
$form['user'] = array(
'#type' => 'value',
'#value' => $user,
);
$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,
);
if (variable_get('apply_for_role_allow_message', 0)) {
$form['message'] = array(
'#type' => 'textarea',
'#title' => t('Application details'),
'#description' => t('Enter an explanation for how you will use the role, if it is granted.'),
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Apply'),
);
}
else {
drupal_set_message(t('No new roles are available to you at this time.'));
}
return $form;
}