You are here

function user_import_edit in User Import 7.2

Same name and namespace in other branches
  1. 8 user_import.admin.inc \user_import_edit()
  2. 6.4 user_import.admin.inc \user_import_edit()
  3. 6.2 user_import.admin.inc \user_import_edit()
  4. 7.3 user_import.admin.inc \user_import_edit()
  5. 7 user_import.admin.inc \user_import_edit()
1 string reference to 'user_import_edit'
user_import_preferences in ./user_import.admin.inc

File

./user_import.admin.inc, line 503
Provide administration configuration pages to import users.

Code

function user_import_edit($form, $form_state, $import_id, $template_id = NULL) {

  // load code for supported modules
  user_import_load_supported();
  $form = array();
  $import = _user_import_settings_select($import_id);
  $import['template_id'] = $template_id;
  $form['ftp'] = array(
    '#type' => 'value',
    '#value' => $import['options']['ftp'],
  );

  // add setting template values
  if ($import['setting'] == 'file set') {
    $import = _user_import_initialise_import($import);
  }
  $form['import_id'] = array(
    '#type' => 'value',
    '#value' => $import_id,
  );
  $form['setting'] = array(
    '#type' => 'value',
    '#value' => $import['setting'],
  );
  $form['return_path'] = array(
    '#type' => 'value',
    '#default_value' => 'admin/people/user_import',
  );
  $form['og_id'] = array(
    '#type' => 'value',
    '#default_value' => 0,
  );

  // don't use hook because these need to be added in this order;
  user_import_edit_file_fields($form, $import);
  user_import_form_field_match($form, $import);
  $collapsed = empty($import['name']) ? FALSE : TRUE;
  $additional_fieldsets = module_invoke_all('user_import_form_fieldset', $import, $collapsed);
  if (is_array($additional_fieldsets)) {
    $form = $form + $additional_fieldsets;
  }
  $update_user = module_invoke_all('user_import_form_update_user');
  if (is_array($update_user)) {
    $form['update_user'] = array(
      '#type' => 'fieldset',
      '#title' => t('Update Existing Users'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#tree' => TRUE,
    );
    foreach ($update_user as $module => $display) {
      $options = array(
        UPDATE_NONE => t('No Update'),
        UPDATE_REPLACE => t('Replace Data'),
        UPDATE_ADD => t('Add Data'),
      );
      if (isset($display['exclude_add']) && $display['exclude_add'] == TRUE) {
        unset($options[UPDATE_ADD]);
      }
      if (isset($display['exclude_replace']) && $display['exclude_replace'] == TRUE) {
        unset($options[UPDATE_REPLACE]);
      }
      $form['update_user'][$module] = array(
        '#type' => 'radios',
        '#title' => $display['title'],
        '#options' => $options,
        '#default_value' => empty($import['options']['update_user'][$module]) ? UPDATE_NONE : $import['options']['update_user'][$module],
        '#description' => $display['description'],
      );
    }
  }

  // don't show test option if import has started
  if ($import['setting'] != 'import' && $import['setting'] != 'imported') {
    $form['test'] = array(
      '#type' => 'submit',
      '#value' => t('Test'),
      '#weight' => 100,
      '#submit' => array(
        'user_import_test_submit',
        'user_import_edit_submit',
      ),
    );
  }
  $form['import'] = array(
    '#type' => 'submit',
    '#value' => t('Import'),
    '#weight' => 100,
    '#submit' => array(
      'user_import_import_submit',
      'user_import_edit_submit',
    ),
  );
  $form['cancel'] = array(
    '#type' => 'submit',
    '#value' => t('Cancel'),
    '#weight' => 100,
    '#validate' => array(
      'user_import_edit_cancel_validate',
    ),
  );
  return $form;
}