function password_policy_admin_form in Password Policy 7
Same name and namespace in other branches
- 6 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 359 - Admin page callback file for the Password Policy module.
Code
function password_policy_admin_form($form, &$form_state, $policy = NULL) {
$form['policy'] = array(
'#type' => 'fieldset',
'#title' => t('Policy'),
'#collapsible' => FALSE,
'#collapsed' => FALSE,
);
$form['policy']['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#default_value' => isset($policy['name']) ? $policy['name'] : '',
'#maxlength' => 64,
'#required' => TRUE,
);
$form['policy']['description'] = array(
'#type' => 'textfield',
'#title' => t('Description'),
'#default_value' => isset($policy['description']) ? $policy['description'] : '',
'#size' => 128,
'#maxlength' => 255,
);
$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.'),
);
$authentication_modules = _password_policy_get_authentication_modules();
if (count($authentication_modules)) {
$form['excluded_authentication_modules'] = array(
'#type' => 'fieldset',
'#title' => t('Excluded Authentication Modules'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['excluded_authentication_modules']['excluded_authentication_modules'] = array(
'#type' => 'checkboxes',
'#title' => t('Excluded Authentication Modules'),
'#options' => drupal_map_assoc($authentication_modules),
'#default_value' => isset($policy['excluded_authentication_modules']) ? $policy['excluded_authentication_modules'] : array(),
'#description' => t('Select the authentication modules that this policy will not 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' => isset($policy['expiration']) ? $policy['expiration'] : '0',
'#size' => 5,
'#maxlength' => 5,
'#description' => t('The passwords will expire after this number of days. The users with expired passwords will be blocked. Setting this field to 0 will not put any password expiration constraints.'),
);
$form['expiration']['warning'] = array(
'#type' => 'textfield',
'#title' => t('Password Expiration Warning'),
'#default_value' => isset($policy['warning']) ? $policy['warning'] : '',
'#size' => 10,
'#field_suffix' => t('days before password expiration'),
'#description' => t("<p>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.</p><p><strong>Important:</strong> Drupal cron must be run once per day. Otherwise, warning e-mails might not be sent. The default Drupal cron configuration relies on site visitors to invoke cron. If your site might not receive visitors on a day, you should run cron from outside the site daily. See <a href='https://www.drupal.org/cron'>Setting Up Cron</a>.</p>"),
);
$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['constraints'][$constraint]) ? $policy['constraints'][$constraint] : NULL,
'#maxlength' => 3,
'#title' => filter_xss($desc['name']),
'#description' => filter_xss($desc['description']),
);
}
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => is_array($policy) ? t('Save') : t('Create'),
);
if ($policy) {
$form['actions']['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete'),
);
$form['actions']['pid'] = array(
'#type' => 'hidden',
'#value' => isset($policy['pid']) ? $policy['pid'] : '',
);
}
return $form;
}