You are here

function sf_import_create in Salesforce Suite 6.2

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

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

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

File

sf_import/sf_import.admin.inc, line 220
Admin settings for the SF Import module.

Code

function sf_import_create(&$form_state, $ongoing = 0) {
  $form = $options = array();
  $fieldmaps = salesforce_api_salesforce_field_map_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', $map->salesforce) . ' => ' . salesforce_api_fieldmap_object_label('drupal', $map->drupal) . ' - <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 nodes to Salesforce objects on import?'),
    '#description' => t('Links the imported Drupal node 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 reference 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;
}