You are here

function agreement_settings in Agreement 6

Same name and namespace in other branches
  1. 6.2 agreement.module \agreement_settings()

Callback for admin/settings/agreement Defines the settings form using FAPI.

1 string reference to 'agreement_settings'
agreement_menu in ./agreement.module
Implementation of hook_menu().

File

./agreement.module, line 172
agreement.module - Agreement module code

Code

function agreement_settings() {

  // When a user changes the URL of the page the menu will need to be rebuilt.
  // Submitting the form lands the user right back here.
  menu_rebuild();
  $form = array();
  $roles = array(
    NULL => '',
  ) + user_roles();
  unset($roles[1]);
  $form['agreement_role'] = array(
    '#description' => t('Which users need to accept the agreement?'),
    '#default_value' => variable_get('agreement_role', 2),
    '#options' => $roles,
    '#required' => TRUE,
    '#title' => t('User role'),
    '#type' => 'select',
  );
  $options = array(
    t('Only once'),
    t('On every log in'),
  );
  $form['agreement_frequency'] = array(
    '#description' => t('How often should users be required to accept the agreement?'),
    '#default_value' => variable_get('agreement_frequency', 0),
    '#options' => $options,
    '#required' => TRUE,
    '#title' => t('Frequency'),
    '#type' => 'select',
  );
  $form['agreement_text'] = array(
    '#description' => t('This is the agreement text.'),
    '#default_value' => variable_get('agreement_text', ''),
    '#title' => t('Agreement Text'),
    '#rows' => 12,
    '#type' => 'textarea',
  );
  $form['agreement_page_title'] = array(
    '#description' => t('What should the title of the agreement page be?'),
    '#default_value' => variable_get('agreement_page_title', AGREEMENT_PAGE_TITLE),
    '#title' => t('Agreement Page Title'),
    '#type' => 'textfield',
  );
  $form['agreement_page_url'] = array(
    '#description' => t('At what URL should the agreement page be located? Relative
      to site root. No leading or trailing slashes.'),
    '#default_value' => variable_get('agreement_page_url', AGREEMENT_PAGE_URL),
    '#required' => TRUE,
    '#title' => t('Agreement Page URL'),
    '#type' => 'textfield',
  );
  $form['agreement_checkbox_text'] = array(
    '#description' => t('This text will be displayed next to the "I agree" checkbox.'),
    '#default_value' => variable_get('agreement_checkbox_text', AGREEMENT_CHECKBOX_TEXT),
    '#required' => TRUE,
    '#title' => t('Agreement Checkbox Text'),
    '#type' => 'textfield',
  );
  $form['agreement_submit_text'] = array(
    '#description' => t('This text will be displayed on the "Submit" button.'),
    '#default_value' => variable_get('agreement_submit_text', AGREEMENT_SUBMIT_TEXT),
    '#required' => TRUE,
    '#title' => t('Agreement Submit Text'),
    '#type' => 'textfield',
  );
  $form['agreement_message_success'] = array(
    '#description' => t('What message should be displayed to the users once they
      accept the agreement?'),
    '#default_value' => variable_get('agreement_message_success', AGREEMENT_MESSAGE_SUCCESS),
    '#title' => t('Agreement Success Message'),
    '#type' => 'textfield',
  );
  $form['agreement_success_destination'] = array(
    '#description' => t("What page should be displayed after the user accepts the \n      agreement? Leave blank to go to original destination that triggered the \n      agreement. %front is the front page. Users who log in via the one-time login link\n      will always be redirected to their user profile to change their password.", array(
      '%front' => '<front>',
    )),
    '#default_value' => variable_get('agreement_success_destination', ''),
    '#title' => t('Agreement Success Destination'),
    '#type' => 'textfield',
  );
  $form['agreement_message_failure'] = array(
    '#description' => t('What message should be displayed to the users if they do not
      accept the agreement?'),
    '#default_value' => variable_get('agreement_message_failure', AGREEMENT_MESSAGE_FAILURE),
    '#title' => t('Agreement Failure Message'),
    '#type' => 'textfield',
  );
  $form['agreement_page_visibility_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Page specific visibility settings'),
    '#collapsible' => TRUE,
  );
  $options = array(
    t('Show on every page except the listed pages.'),
    t('Show on only the listed pages.'),
  );
  $description = t("Enter one page per line as Drupal paths. The '*' character is a\n    wildcard. Example paths are %blog for the blog page and %blog-wildcard for every \n    personal blog. %front is the front page.", array(
    '%blog' => 'blog',
    '%blog-wildcard' => 'blog/*',
    '%front' => '<front>',
  ));
  $form['agreement_page_visibility_settings']['agreement_page_visibility_settings'] = array(
    '#type' => 'radios',
    '#title' => t('Show agreement on specific pages'),
    '#options' => $options,
    '#required' => TRUE,
    '#default_value' => variable_get('agreement_page_visibility_settings', '0'),
  );
  $form['agreement_page_visibility_settings']['agreement_page_visibility_pages'] = array(
    '#type' => 'textarea',
    '#title' => t('Pages'),
    '#default_value' => variable_get('agreement_page_visibility_pages', '<front>'),
    '#description' => $description,
  );
  return system_settings_form($form);
}