You are here

function uc_importer_admin_settings in Ubercart 5

Configure the importer behaviour when handling duplicate objects.

See also

uc_importer_admin_settings_validate

uc_importer_admin_settings_submit

1 string reference to 'uc_importer_admin_settings'
uc_importer_menu in uc_importer/uc_importer.module
Implementation of hook_menu().

File

uc_importer/uc_importer.module, line 83
XML product importer and exporter.

Code

function uc_importer_admin_settings() {
  $form = array();
  $options = array(
    UC_IMPORTER_DO_NOTHING => t('Do not save the new item.'),
    UC_IMPORTER_REPLACE => t('Overwrite the existing item.'),
    UC_IMPORTER_INCREMENT => t('Save the new item as a separate entity,'),
  );
  $form['uc_importer_vocabulary_duplicates'] = array(
    '#type' => 'radios',
    '#title' => t('How should similarly named vocabularies be handled during import?'),
    '#options' => $options,
    '#default_value' => variable_get('uc_importer_vocabulary_duplicates', UC_IMPORTER_DO_NOTHING),
  );
  $form['uc_importer_category_duplicates'] = array(
    '#type' => 'radios',
    '#title' => t('How should similarly named categories be handled during import?'),
    '#options' => $options,
    '#default_value' => variable_get('uc_importer_category_duplicates', UC_IMPORTER_DO_NOTHING),
  );
  $form['uc_importer_class_duplicates'] = array(
    '#type' => 'radios',
    '#title' => t('How should similarly named classes be handled during import?'),
    '#options' => $options,
    '#default_value' => variable_get('uc_importer_class_duplicates', UC_IMPORTER_DO_NOTHING),
  );
  $form['uc_importer_attribute_duplicates'] = array(
    '#type' => 'radios',
    '#title' => t('How should similarly named attributes be handled during import?'),
    '#options' => $options,
    '#default_value' => variable_get('uc_importer_attribute_duplicates', UC_IMPORTER_DO_NOTHING),
  );
  $form['uc_importer_product_duplicates'] = array(
    '#type' => 'radios',
    '#title' => t('How should similarly identified products be handled during import?'),
    '#options' => $options,
    '#default_value' => variable_get('uc_importer_product_duplicates', UC_IMPORTER_DO_NOTHING),
  );
  $account = user_load(array(
    'uid' => variable_get('uc_importer_user', 0),
  ));
  $form['uc_importer_user'] = array(
    '#type' => 'textfield',
    '#title' => t('Authored by'),
    '#maxlength' => 60,
    '#autocomplete_path' => 'user/autocomplete',
    '#default_value' => $account ? $account->name : '',
    '#description' => t('The "author" of imported products. Leave blank for %anonymous.', array(
      '%anonymous' => variable_get('anonymous', t('Anonymous')),
    )),
  );
  $form['buttons']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save configuration'),
  );
  $form['buttons']['reset'] = array(
    '#type' => 'submit',
    '#value' => t('Reset to defaults'),
  );
  if (!empty($_POST) && form_get_errors()) {
    drupal_set_message(t('The settings have not been saved because of the errors.'), 'error');
  }
  return $form;
}