You are here

function sf_prematch_list in Salesforce Suite 7

Same name and namespace in other branches
  1. 6.2 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 8
Admin functions for sf_prematch module.

Code

function sf_prematch_list() {

  // Define the header for the admin table.
  $header = array(
    t('Index'),
    t('Drupal object'),
    t('Salesforce object'),
    array(
      'data' => t('Operations'),
      'colspan' => 3,
    ),
  );
  $result = db_query("SELECT salesforce_field_map.*, salesforce_prematch.rule " . "FROM salesforce_field_map LEFT JOIN salesforce_prematch " . "ON salesforce_field_map.fieldmap = salesforce_prematch.fieldmap");
  $rows = array();

  // Loop through all the indexed field maps.
  while ($map = db_fetch_array($result)) {
    if ($map['rule']) {
      $op_0 = l(t('edit prematch'), SALESFORCE_PATH_FIELDMAPS . '/prematching/' . $map['fieldmap']);
      $op1 = l(t('delete prematch'), SALESFORCE_PATH_FIELDMAPS . '/prematching/' . $map['fieldmap'] . '/delete');
    }
    else {
      $op_0 = l(t('add prematch'), SALESFORCE_PATH_FIELDMAPS . '/prematching/' . $map['fieldmap']);
      $op1 = '';
    }

    // Add the row to the table with the basic operations.
    $rows[] = array(
      $map['fieldmap'],
      salesforce_api_fieldmap_object_label('drupal', $map['drupal']),
      salesforce_api_fieldmap_object_label('salesforce', $map['salesforce']),
      $op_0,
      $op1,
    );
  }

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