You are here

function legal_administration in Legal 5

Same name and namespace in other branches
  1. 6.8 legal.admin.inc \legal_administration()
  2. 6.7 legal.module \legal_administration()
  3. 7.2 legal.admin.inc \legal_administration()
  4. 7 legal.admin.inc \legal_administration()
1 string reference to 'legal_administration'
legal_menu in ./legal.module

File

./legal.module, line 157

Code

function legal_administration() {
  $conditions = legal_get_conditions();
  $form = legal_display_fields($conditions);
  $form['conditions'] = array(
    '#type' => 'textarea',
    '#title' => t('Terms & Conditions'),
    '#default_value' => $conditions['conditions'],
    '#description' => t('Your Terms & Conditions'),
    '#required' => TRUE,
  );

  // overide accept checbox requirement on preview
  $form['legal']['legal_accept']['#required'] = FALSE;

  // overide display setting
  $form['display'] = array(
    '#type' => 'radios',
    '#title' => t('Display Style'),
    '#default_value' => variable_get('legal_display', '0'),
    '#options' => array(
      t('Scroll Box'),
      t('Scroll Box (CSS)'),
      t('HTML Text'),
      t('Page Link'),
    ),
    '#description' => t('How terms & conditions should be displayed to users.'),
    '#required' => TRUE,
  );

  // additional checkboxes
  $form['extras'] = array(
    '#type' => 'fieldset',
    '#title' => t('Additional Checkboxes'),
    '#description' => t('Each field will be shown as a checkbox which the user must tick to register.'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#tree' => TRUE,
  );
  $extras_count = count($conditions['extras']);
  if ($extras_count < 5) {
    $extras_count = 5;
  }
  for ($counter = 1; $counter <= $extras_count; $counter++) {
    $form['extras']['extras-' . $counter] = array(
      '#type' => 'textfield',
      '#title' => t('Label'),
      '#default_value' => $conditions['extras']['extras-' . $counter],
    );

    // overide extra checkboxes
    $form['legal']['extras-' . $counter] = array(
      '#type' => 'checkbox',
      '#title' => filter_xss_admin($conditions['extras']['extras-' . $counter]),
      '#default_value' => 0,
      '#weight' => 2,
      '#required' => FALSE,
    );
  }

  // notes about changes to T&C
  $form['changes'] = array(
    '#type' => 'fieldset',
    '#title' => t('Explain Changes'),
    '#description' => t('Explain what changes were made to the T&C since the last version. This will only be shown to users who accepted a previous version. Each line will automatically be shown as a bullet point.'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['changes']['changes'] = array(
    '#type' => 'textarea',
    '#title' => t('Changes'),
  );
  $form['#after_build'] = array(
    'legal_preview',
  );
  $form['preview'] = array(
    '#type' => 'button',
    '#value' => t('Preview'),
  );
  $form['save'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}