function agreement_settings_form in Agreement 7.2
Agreement settings form.
Parameters
array $form: The form array.
array &$form_state: The form state array.
array $info: (Optional) The agreement type info.
Return value
array The form array.
1 string reference to 'agreement_settings_form'
- agreement_menu in ./
agreement.module - Implements hook_menu().
File
- ./
agreement.admin.inc, line 85 - Agreement administration page callback.
Code
function agreement_settings_form($form, &$form_state, $info = NULL) {
$is_new = NULL === $info || !isset($info['id']);
$form_state['is_new'] = $is_new;
$destination = drupal_get_destination();
// Get a list of user role IDs without the anonymous user role.
$role_options = user_roles();
unset($role_options[1]);
if (!$is_new) {
$form_state['agreement'] = $info;
}
else {
$form_state['agreement'] = array();
}
$form['type'] = array(
'#description' => t('Provide a human-readable label for this agreement type.'),
'#default_value' => $is_new ? '' : check_plain($info['type']),
'#required' => TRUE,
'#title' => t('Label'),
'#type' => 'textfield',
);
$form['name'] = array(
'#default_value' => $is_new ? '' : check_plain($info['name']),
'#disabled' => !$is_new,
'#required' => TRUE,
'#maxlength' => 21,
'#machine_name' => array(
'exists' => 'agreement_type_name_exists',
'source' => array(
'type',
),
),
'#type' => 'machine_name',
);
$form['settings'] = array(
'#collapsible' => FALSE,
'#collapsed' => FALSE,
'#title' => t('Configuration'),
'#tree' => TRUE,
'#type' => 'fieldset',
);
$form['settings']['role'] = array(
'#description' => t('Which users need to accept the agreement?'),
'#default_value' => !$is_new ? $info['settings']['role'] : DRUPAL_AUTHENTICATED_RID,
'#options' => $role_options,
'#required' => TRUE,
'#title' => t('User role'),
'#type' => 'select',
'#multiple' => TRUE,
);
$form['settings']['frequency'] = array(
'#description' => t('How often should users be required to accept the agreement?'),
'#default_value' => !$is_new ? $info['settings']['frequency'] : 0,
'#options' => array(
-1 => t('Only once'),
0 => t('On every log in'),
365 => t('Once a year'),
),
'#required' => TRUE,
'#title' => t('Frequency'),
'#type' => 'select',
);
$form['agreement'] = array(
'#description' => t('This is the agreement text.'),
'#default_value' => !$is_new ? $info['agreement'] : '',
'#title' => t('Agreement Text'),
'#rows' => 12,
'#type' => 'text_format',
'#format' => !$is_new ? $info['settings']['format'] : agreement_get_translated_message('AGREEMENT_FORMAT'),
);
$form['settings']['title'] = array(
'#description' => t('What should the title of the agreement page be?'),
'#default_value' => !$is_new ? $info['settings']['title'] : variable_get('agreement_page_title', agreement_get_translated_message('AGREEMENT_PAGE_TITLE')),
'#required' => TRUE,
'#title' => t('Agreement Page Title'),
'#type' => 'textfield',
);
$form['path'] = array(
'#description' => t('At what URL should the agreement page be located? Relative to site root. No leading or trailing slashes.'),
'#default_value' => !$is_new ? $info['path'] : variable_get('agreement_page_url', agreement_get_translated_message('AGREEMENT_PAGE_URL')),
'#element_validate' => array(
'agreement_path_validate',
),
'#required' => TRUE,
'#title' => t('Agreement Page URL'),
'#type' => 'textfield',
);
$form['settings']['checkbox'] = array(
'#description' => t('This text will be displayed next to the "I agree" checkbox.'),
'#default_value' => !$is_new ? $info['settings']['checkbox'] : agreement_get_translated_message('AGREEMENT_CHECKBOX_TEXT'),
'#required' => TRUE,
'#title' => t('Agreement Checkbox Text'),
'#type' => 'textfield',
);
$form['settings']['submit'] = array(
'#description' => t('This text will be displayed on the "Submit" button.'),
'#default_value' => !$is_new ? $info['settings']['submit'] : agreement_get_translated_message('AGREEMENT_SUBMIT_TEXT'),
'#required' => TRUE,
'#title' => t('Agreement Submit Text'),
'#type' => 'textfield',
);
$form['settings']['success'] = array(
'#description' => t('What message should be displayed to the users once they accept the agreement?'),
'#default_value' => !$is_new ? $info['settings']['success'] : agreement_get_translated_message('AGREEMENT_MESSAGE_SUCCESS'),
'#title' => t('Agreement Success Message'),
'#type' => 'textfield',
);
$form['settings']['destination'] = array(
'#description' => t('What page should be displayed after the user accepts the agreement? Leave blank
to go to original destination that triggered the agreement. %front is the front
page. Users who log in via the one-time login link will always be redirected to
their user profile to change their password.', array(
'%front' => '<front>',
)),
'#default_value' => !$is_new ? $info['settings']['destination'] : '',
'#title' => t('Agreement Success Destination'),
'#type' => 'textfield',
);
$form['settings']['failure'] = array(
'#description' => t('What message should be displayed to the users if they do not accept the agreement?'),
'#default_value' => !$is_new ? $info['settings']['failure'] : agreement_get_translated_message('AGREEMENT_MESSAGE_FAILURE'),
'#title' => t('Agreement Failure Message'),
'#type' => 'textfield',
);
$form['settings']['revoked'] = array(
'#description' => t('What message should be displayed to the users if they revoke their agreement?'),
'#default_value' => !$is_new ? $info['settings']['revoked'] : agreement_get_translated_message('AGREEMENT_MESSAGE_REVOKED'),
'#title' => t('Agreement Revoke Message'),
'#type' => 'textfield',
);
$form['settings']['visibility_settings'] = array(
'#type' => 'radios',
'#title' => t('Show agreement on specific pages'),
'#options' => array(
t('Show on every page except the listed pages.'),
t('Show on only the listed pages.'),
),
'#required' => TRUE,
'#default_value' => !$is_new ? $info['settings']['visibility_settings'] : 0,
);
$form['settings']['visibility_pages'] = array(
'#type' => 'textarea',
'#title' => t('Pages'),
'#default_value' => !$is_new ? $info['settings']['visibility_pages'] : '<front>',
'#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths\n are %blog for the blog page and %blog-wildcard for every personal blog. %front is the\n front page.", array(
'%blog' => 'blog',
'%blog-wildcard' => 'blog/*',
'%front' => '<front>',
)),
);
$form['settings']['email_recipient'] = array(
'#type' => 'textfield',
'#title' => t('Email notification of agreement acceptance to'),
'#default_value' => !$is_new ? $info['settings']['email_recipient'] : '',
'#description' => t('If an email address is entered here, an email will be sent to that email address each time a user agrees. To have no email sent, leave this blank.'),
'#element_validate' => array(
'valid_email_address',
),
);
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save configuration'),
);
$destination = agreement_settings_form_get_destination('admin/config/people/agreement');
$form['actions']['cancel'] = array(
'#options' => array(
'attributes' => array(),
'html' => FALSE,
'query' => $destination['query'],
),
'#path' => $destination['path'],
'#text' => t('Cancel'),
'#theme' => 'link',
'#weight' => 10,
);
// Provide delete button if not default agreement.
if (!$is_new && $info['name'] !== 'default') {
$form['actions']['delete'] = array(
'#submit' => array(
'agreement_settings_form_delete',
),
'#type' => 'submit',
'#value' => t('Remove'),
);
}
return $form;
}