You are here

function janrain_capture_settings_mapping in Janrain Registration 7

Same name and namespace in other branches
  1. 7.4 janrain_capture_mapping/janrain_capture_mapping.admin.inc \janrain_capture_settings_mapping()
  2. 7.2 janrain_capture_mapping/janrain_capture_mapping.admin.inc \janrain_capture_settings_mapping()
  3. 7.3 janrain_capture_mapping/janrain_capture_mapping.admin.inc \janrain_capture_settings_mapping()

Menu callback for the mapping configuration screen.

1 string reference to 'janrain_capture_settings_mapping'
janrain_capture_mapping_menu in janrain_capture_mapping/janrain_capture_mapping.module
Implements hook_menu().

File

janrain_capture_mapping/janrain_capture_mapping.admin.inc, line 11
Mapping admin settings functions

Code

function janrain_capture_settings_mapping($form, &$form_state) {
  $user_field_options = janrain_capture_mapping_get_user_field_options();
  $capture_field_options = janrain_capture_mapping_get_capture_field_options();
  $map = variable_get('janrain_capture_mapping_map', array());

  // Add an empty row for saving a new mapping.
  $map[] = array();
  foreach ($map as $mid => $mapping) {
    $selected_field = isset($form_state['values'][$mid]['field']) ? $form_state['values'][$mid]['field'] : (isset($map[$mid]['field']) ? $map[$mid]['field'] : '');
    $form[$mid] = array(
      'fid' => array(
        '#type' => 'select',
        '#title' => t('Capture field'),
        '#title_display' => 'invisible',
        '#options' => $capture_field_options,
        '#default_value' => isset($map[$mid]['fid']) ? $map[$mid]['fid'] : '',
        '#empty_option' => t('- Select a data field -'),
        '#attributes' => array(
          'class' => array(
            'janrain-capture-field-select',
            'mid-' . $mid,
          ),
        ),
      ),
      'separator' => array(
        '#markup' => '=>',
      ),
      'field' => array(
        '#type' => 'select',
        '#title' => t('Field'),
        '#title_display' => 'invisible',
        '#options' => $user_field_options,
        '#empty_option' => t('- Select a field -'),
        '#default_value' => isset($map[$mid]['field']) ? $map[$mid]['field'] : '',
        '#attributes' => array(
          'class' => array(
            'field-select',
            'mid-' . $mid,
          ),
        ),
        '#ajax' => array(
          'callback' => '_janrain_capture_ajax_callback',
          'wrapper' => 'janrain-capture-columns-replace-' . $mid,
        ),
      ),
      'column' => array(
        '#type' => 'select',
        '#title' => t('Column'),
        '#title_display' => 'invisible',
        '#prefix' => '<div id="janrain-capture-columns-replace-' . $mid . '">',
        '#suffix' => '</div>',
        '#options' => _janrain_capture_mapping_get_columns($selected_field),
        '#default_value' => isset($map[$mid]['column']) ? $map[$mid]['column'] : '',
      ),
    );
  }
  if (count($form)) {
    $form['actions'] = array(
      '#type' => 'actions',
    );
    $form['actions']['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Save configuration'),
    );
  }
  $form['#tree'] = TRUE;
  return $form;
}