You are here

function sf_prematch_list in Salesforce Suite 6.2

Same name and namespace in other branches
  1. 7 sf_prematch/sf_prematch.admin.inc \sf_prematch_list()
  2. 7.2 sf_prematch/sf_prematch.admin.inc \sf_prematch_list()

@file Admin functions for sf_prematch module.

1 string reference to 'sf_prematch_list'
sf_prematch_menu in sf_prematch/sf_prematch.module
Implementation of hook_menu().

File

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

Code

function sf_prematch_list() {

  // Define the header for the admin table.
  $header = array(
    t('Drupal object'),
    t('Salesforce object'),
    array(
      'data' => t('Operations'),
      'colspan' => 3,
    ),
  );

  //$maps = salesforce_api_salesforce_field_map_load_all();
  $result = db_query("SELECT fm.*, pm.rule " . "FROM {salesforce_field_map} fm LEFT JOIN {salesforce_prematch} pm " . "ON fm.name = pm.name");
  $rows = array();

  // Loop through all the indexed field maps.
  while ($map = db_fetch_object($result)) {
    if ($map->rule) {
      $op_add_edit = l(t('edit prematch'), SALESFORCE_PATH_FIELDMAPS . '/' . $map->name . '/prematching');
      $op_del = l(t('delete prematch'), SALESFORCE_PATH_FIELDMAPS . '/' . $map->name . '/prematching/delete');
    }
    else {
      $op_add_edit = l(t('add prematch'), SALESFORCE_PATH_FIELDMAPS . '/' . $map->name . '/prematching');
      $op_del = '';
    }

    // Add the row to the table with the basic operations.
    $rows[] = array(
      salesforce_api_fieldmap_object_label('drupal', $map->drupal),
      salesforce_api_fieldmap_object_label('salesforce', $map->salesforce),
      $op_add_edit,
      $op_del,
    );
  }

  // Add a message if no objects have been mapped.
  if (empty($rows)) {
    $rows[] = array(
      array(
        'data' => t('You have not yet assigned prematching to any fieldmaps.'),
        'colspan' => 7,
      ),
    );
  }
  $output = theme('table', $header, $rows);
  return $output;
}