You are here

function uc_termsofservice_admin_form in Ubercart Terms of Service 7

Same name and namespace in other branches
  1. 6 uc_termsofservice.module \uc_termsofservice_admin_form()

Settings form for checkout & cart panes.

2 calls to uc_termsofservice_admin_form()
uc_termsofservice_checkout_pane_callback in ./uc_termsofservice.module
Callback form for checkout pane.
uc_termsofservice_form_uc_cart_cart_panes_form_alter in ./uc_termsofservice.module
Implements hook_form_FORM_ID_alter() for uc_cart_cart_panes_form.

File

./uc_termsofservice.module, line 251
Ubercart Terms of Service.

Code

function uc_termsofservice_admin_form($type = NULL) {
  if ($type) {
    $form = array();

    // Required option only for checkout by the moment.
    if ($type == 'checkout') {
      $form['uc_termsofservice_' . $type . '_required'] = array(
        '#type' => 'checkbox',
        '#title' => t('ToS agreement is required'),
        '#default_value' => variable_get('uc_termsofservice_' . $type . '_required', 0),
        '#weight' => 1,
      );
    }

    // Autocomplete textfield for selecting the ToS node.
    $form['uc_termsofservice_' . $type . '_node'] = array(
      '#type' => 'textfield',
      '#title' => t('Select the node that corresponds to the Terms of Service. Note that this node will be shown regardless of node access permissions.'),
      '#autocomplete_path' => 'uc_termsofservice/node/autocomplete',
      '#default_value' => variable_get('uc_termsofservice_' . $type . '_node', NULL),
      '#weight' => 0,
    );

    // Hide node title
    $form['uc_termsofservice_' . $type . '_title'] = array(
      '#type' => 'select',
      '#title' => t('Show the node title?'),
      '#description' => t('Showing the node title will render it as a link.'),
      '#options' => array(
        1 => t('Yes'),
        0 => t('No'),
      ),
      '#default_value' => variable_get('uc_termsofservice_' . $type . '_title', 1),
    );

    // ToS node display mode
    $entity_info = entity_get_info();
    $display_types = array();
    foreach ($entity_info['node']['view modes'] as $key => $val) {
      $display_types[$key] = $val['label'];
    }
    $form['uc_termsofservice_' . $type . '_display'] = array(
      '#type' => 'select',
      '#title' => t('Node display'),
      '#description' => t('Display type to use to display the node (usually Teaser or Full content).'),
      '#options' => $display_types,
      '#default_value' => variable_get('uc_termsofservice_' . $type . '_display', 'teaser'),
    );

    // Handle ToS in a popup window.
    if (module_exists('modalframe')) {

      // Container for advanced settings.
      $form['uc_termsofservice_advanced_settings'] = array(
        '#type' => 'fieldset',
        '#title' => t('Advanced settings'),
        '#weight' => 2,
        '#collapsible' => TRUE,
        '#collapsed' => FALSE,
      );
      $form['uc_termsofservice_advanced_settings']['uc_termsofservice_' . $type . '_popup'] = array(
        '#type' => 'checkbox',
        '#title' => t('Open ToS in a popup modal window.'),
        '#default_value' => variable_get('uc_termsofservice_' . $type . '_popup', 0),
      );
      $form['uc_termsofservice_advanced_settings']['uc_termsofservice_' . $type . '_popup_width'] = array(
        '#type' => 'textfield',
        '#title' => t('Width of the popup window'),
        '#default_value' => variable_get('uc_termsofservice_' . $type . '_popup_width', NULL),
        '#size' => 4,
      );
      $form['uc_termsofservice_advanced_settings']['uc_termsofservice_' . $type . '_popup_height'] = array(
        '#type' => 'textfield',
        '#title' => t('Height of the popup window'),
        '#default_value' => variable_get('uc_termsofservice_' . $type . '_popup_height', NULL),
        '#size' => 4,
      );
    }
    return $form;
  }
}