function password_policy_admin_form in Password Policy 6
Same name and namespace in other branches
- 7 password_policy.admin.inc \password_policy_admin_form()
Form display for new or to be edited password policies.
1 string reference to 'password_policy_admin_form'
- password_policy_menu in ./
password_policy.module - Implements hook_menu().
File
- ./
password_policy.admin.inc, line 213 - Admin page callback file for the password_policy module.
Code
function password_policy_admin_form($form_state, $policy = NULL) {
$form['policy']['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#default_value' => $policy['name'],
'#maxlength' => 64,
'#required' => TRUE,
);
$form['policy']['description'] = array(
'#type' => 'textarea',
'#title' => t('Description'),
'#default_value' => $policy['description'],
);
$form['roles'] = array(
'#type' => 'fieldset',
'#title' => t('Roles'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['roles']['roles'] = array(
'#type' => 'checkboxes',
'#title' => t('Roles'),
'#options' => user_roles(TRUE),
'#default_value' => isset($policy['roles']) ? $policy['roles'] : array(),
'#description' => t('Select the roles that this policy will apply to.'),
);
$form['expiration'] = array(
'#type' => 'fieldset',
'#title' => t('Expiration'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['expiration']['expiration'] = array(
'#type' => 'textfield',
'#title' => t('Password Expiration'),
'#default_value' => $policy['expiration'],
'#size' => 5,
'#maxlength' => 5,
'#description' => t('The passwords will expire after this number of days. The users with expired passwords will be blocked. Leaving this field empty won\'t put any password expiration constraints.'),
);
$form['expiration']['warning'] = array(
'#type' => 'textfield',
'#title' => t('Password Expiration Warning'),
'#default_value' => $policy['warning'],
'#size' => 10,
'#field_suffix' => t("days before password expiration"),
'#description' => t("When to send a password expiration warning e-mail. To send warning e-mails on multiple days, enter numbers separated by commas. For example, '30,7' will cause an expiration warning e-mail to be sent both 30 and 7 days before expiration. Leave blank to not send or display any warnings."),
);
$form['constraints'] = array(
'#type' => 'fieldset',
'#title' => t('Constraints'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
foreach (_password_policy_constraints() as $constraint) {
$desc = _password_policy_constraint_description($constraint);
$form['constraints']['constraint_' . $constraint] = array(
'#type' => 'textfield',
'#size' => 5,
'#default_value' => isset($policy['policy'][$constraint]) ? $policy['policy'][$constraint] : NULL,
'#maxlength' => 2,
'#title' => filter_xss($desc['name']),
'#description' => filter_xss($desc['description']),
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => is_array($policy) ? t('Save') : t('Create'),
);
if ($policy) {
$form['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete'),
);
$form['pid'] = array(
'#type' => 'hidden',
'#value' => $policy['pid'],
);
}
return $form;
}