You are here

function janrain_capture_ui_country_selection in Janrain Registration 7.4

1 string reference to 'janrain_capture_ui_country_selection'
janrain_capture_block_view in ./janrain_capture.module
Implements hook_block_view().

File

janrain_capture_ui/janrain_capture_ui.module, line 96
Janrain Capture UI Module

Code

function janrain_capture_ui_country_selection($form, &$form_state) {
  $form = array();
  $countries = janrain_capture_ui_get_all_countries();
  if (empty($countries)) {
    $form['markup_warning'] = array(
      '#markup' => t('No countries are configured.'),
    );
    return $form;
  }
  foreach ($countries as $country) {
    $options[$country['id']] = $country['name'];
  }
  if (!isset($_SESSION['country_id'])) {
    array_unshift($options, t('Select Country'));
  }
  $form['markup_title'] = array(
    '#markup' => t('Information only for Healthcare Professionals'),
  );
  $form['country'] = array(
    '#type' => 'select',
    '#title' => t('Please select your country:'),
    '#description' => t('I confirm that I’m a Healthcare Professional authorized in the selected country.'),
    '#options' => $options,
    '#default_value' => isset($_SESSION['country_id']) ? $_SESSION['country_id'] : 0,
    '#attributes' => array(
      'onChange' => 'document.getElementById("janrain-capture-ui-country-selection").submit();',
    ),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Confirm and continue'),
    '#attributes' => array(
      'style' => array(
        'display: none;',
      ),
    ),
  );
  if (isset($_SESSION['country_id'])) {
    $form['submit-link'] = array(
      '#markup' => l(t('Confirm and continue'), '<front>', array(
        'attributes' => array(
          'class' => array(
            'submit-grv-initiate',
          ),
        ),
      )),
    );
    drupal_add_js('jQuery(document).ready(function() {
      jQuery(".submit-grv-initiate").click(function(e) {
        janrain.capture.ui.start();
        e.preventDefault();
      });});', array(
      'type' => 'inline',
      'scope' => 'footer',
    ));
  }
  return $form;
}