You are here

function sf_import_create in Salesforce Suite 7.2

Same name and namespace in other branches
  1. 6.2 sf_import/sf_import.admin.inc \sf_import_create()

Page callback for admin/config/salesforce/import/create

1 string reference to 'sf_import_create'
sf_import_menu in sf_import/sf_import.module
Implements hook_menu().

File

sf_import/sf_import.admin.inc, line 219
Admin settings for the Salesforce Import module.

Code

function sf_import_create($form, &$form_state, $ongoing = 0) {
  $form = $options = array();
  $fieldmaps = salesforce_api_salesforce_fieldmap_load_all();
  foreach ($fieldmaps as $map) {
    $edit = l('edit', SALESFORCE_PATH_FIELDMAPS . '/' . $map->name . '/edit', array(
      'query' => array(
        'destination' => drupal_get_destination(),
      ),
    ));
    $options[$map->name] = salesforce_api_fieldmap_object_label('salesforce', 'salesforce', $map->salesforce) . ' => ' . salesforce_api_fieldmap_object_label('drupal', $map->drupal_entity, $map->drupal_bundle) . ' - <em>' . $map->description . '</em>' . ' (' . $edit . ')';
  }

  // Add a message if no objects have been mapped.
  if (empty($options)) {
    drupal_set_message(t('You have not yet defined any fieldmaps.'), 'error');
    return;
  }

  // Admin should select a mapping to use for the import.
  $form['label'] = array(
    '#type' => 'markup',
    '#value' => '<h2>' . ($ongoing ? t('Create Ongoing Import') : t('Perform One-time Import')) . '</h2>',
  );
  $form['fieldmap'] = array(
    '#title' => t('Please choose a fieldmap to use for the import'),
    '#description' => t('Salesforce Object => Drupal Content Type'),
    '#type' => 'radios',
    '#required' => TRUE,
    '#options' => $options,
  );
  $form['extra-options'] = array(
    '#title' => t('Extra Options'),
    '#type' => 'fieldset',
    '#collasible' => FALSE,
    '#collapsed' => FALSE,
  );
  $form['extra-options']['extra-linked'] = array(
    '#title' => t('Link entities to Salesforce objects on import?'),
    '#description' => t('Links the imported Drupal entity to the Salesforce object allowing the ability to issue manual syncronization of data to and from Drupal and Salesforce business objects. Linking also enables the ability to use node/term/user reference fields to relate business objects in Drupal (like Accounts to Contacts).'),
    '#type' => 'checkbox',
  );
  $form['extra-options']['extra-where'] = array(
    '#title' => t('Conditions'),
    '#description' => t("<strong>Advanced</strong>: Enter any additional SOQL \"Where\" conditions to use for this import query, e.g.<br /><code>Type != 'One-to-One Individual'</code><br />Learn more here: <a href='http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_select_conditionexpression.htm' target='_blank'>Salesforce.com SOQL Where clause</a>"),
    '#type' => 'textarea',
  );
  $form['ongoing'] = array(
    '#type' => 'value',
    '#value' => $ongoing,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Submit',
  );
  return $form;
}