You are here

function sf_prematch_get_options in Salesforce Suite 6.2

Same name and namespace in other branches
  1. 7 sf_prematch/sf_prematch.admin.inc \sf_prematch_get_options()
  2. 7.2 sf_prematch/sf_prematch.admin.inc \sf_prematch_get_options()
1 call to sf_prematch_get_options()
sf_prematch_edit_form in sf_prematch/sf_prematch.admin.inc

File

sf_prematch/sf_prematch.admin.inc, line 208
Admin functions for sf_prematch module.

Code

function sf_prematch_get_options($map, $required = FALSE) {

  // Extract terms from $map.
  if ($map->actions == 'import') {
    $terms = array_keys($map->fields);
  }
  else {
    $terms = array_values($map->fields);
  }
  sort($terms);

  // Build terms into ordered options to use in select.
  $options = array();

  // Start with empty option if select is not required.
  if (!$required) {
    $options[] = '';
  }

  // Add terms to options, making key = value so form value is key not integer.
  foreach ($terms as $term) {
    if (is_array($term)) {
      $term = implode(' : ', $term);
      if (strlen($term) > 50) {
        $term = substr($term, 0, 50) . ' ...';
      }
    }
    $options[$term] = $term;
  }
  return $options;
}