You are here

function password_policy_expire_admin_form in Password Policy 7.2

Admin form callback for expiration plugin.

1 string reference to 'password_policy_expire_admin_form'
expire.inc in plugins/item/expire.inc

File

plugins/item/expire.inc, line 25

Code

function password_policy_expire_admin_form($form, &$form_state, $constraint) {
  $sub_form['expire_fieldset'] = array(
    '#type' => 'fieldset',
    '#title' => 'Password expiration',
    '#collapsible' => TRUE,
    '#collapsed' => !$constraint->config['expire_enabled'],
  );
  $sub_form['expire_fieldset']['expire_enabled'] = array(
    '#type' => 'checkbox',
    '#title' => 'Expire passwords',
    '#default_value' => $constraint->config['expire_enabled'],
    '#description' => t('Enable password expiration.'),
  );

  // Container for controls that should only be visible if expiration enabled.
  $sub_form['expire_fieldset']['enabled_container'] = array(
    '#type' => 'container',
    '#states' => array(
      'visible' => array(
        ':input[name="expire_enabled"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $enabled_container =& $sub_form['expire_fieldset']['enabled_container'];
  $enabled_container['expire_limit'] = array(
    '#type' => 'textfield',
    '#title' => 'Expire limit',
    '#default_value' => $constraint->config['expire_limit'],
    '#description' => t('Password will expire after being used for this long. (Use normal English, like 90 days or 5 hours.)'),
  );
  $enabled_container['expire_warning_message'] = array(
    '#type' => 'textfield',
    '#title' => 'Warning message',
    '#default_value' => $constraint->config['expire_warning_message'],
    '#description' => t('A message to show to users on screen when requiring them to change password. <strong>If left empty, no message will be shown.</strong>'),
  );
  $enabled_container['expire_warning_email_sent'] = array(
    '#type' => 'textfield',
    '#title' => 'When to send warning e-mails',
    '#default_value' => $constraint->config['expire_warning_email_sent'],
    '#description' => t('A comma separated list of time intervals, when to send warning e-mails. (Use normal English, like 90 days or 5 hours.)  If prefixed with a negative (like -2 days) then this will be before the expiration. If left empty, no e-mail will be sent.'),
  );
  $enabled_container['expire_warning_email_subject'] = array(
    '#type' => 'textfield',
    '#title' => 'Warning e-mail subject',
    '#default_value' => $constraint->config['expire_warning_email_subject'],
    '#maxlength' => 180,
    '#states' => array(
      'visible' => array(
        ':input[name="expire_warning_email_sent"]' => array(
          'empty' => FALSE,
        ),
      ),
    ),
  );
  $enabled_container['expire_warning_email_message'] = array(
    '#type' => 'textarea',
    '#title' => 'Warning e-mail message',
    '#default_value' => $constraint->config['expire_warning_email_message'],
    '#states' => array(
      'visible' => array(
        ':input[name="expire_warning_email_sent"]' => array(
          'empty' => FALSE,
        ),
      ),
    ),
  );
  if (module_exists('token')) {
    $enabled_container['expire_warning_email_message_token'] = array(
      '#theme' => 'token_tree',
      '#token_types' => array(
        'user',
        'site',
        'current-date',
        'password_expiration_date',
      ),
      '#global_types' => FALSE,
      '#click_insert' => TRUE,
      '#states' => array(
        'visible' => array(
          ':input[name="expire_warning_email_sent"]' => array(
            'empty' => FALSE,
          ),
        ),
      ),
    );
  }
  return $sub_form;
}