function salesforce_api_fieldmap_options in Salesforce Suite 5.2
Same name and namespace in other branches
- 6.2 salesforce_api/salesforce_api.module \salesforce_api_fieldmap_options()
- 7 salesforce_api/salesforce_api.module \salesforce_api_fieldmap_options()
- 7.2 salesforce_api/salesforce_api.module \salesforce_api_fieldmap_options()
Returns an array of fieldmaps for use as options in the Forms API.
Parameters
$action: Filters the fieldmaps by action.
$drupal: Filters the fieldmaps by Drupal object.
$salesforce: Filters the fieldmaps by Salesforce object.
Return value
A FAPI options array of all the matching fieldmaps.
2 calls to salesforce_api_fieldmap_options()
- sf_node_salesforce_form in sf_node/
sf_node.module - sf_user_salesforce_form in sf_user/
sf_user.module
File
- salesforce_api/
salesforce_api.module, line 548 - Defines an API that enables modules to interact with the Salesforce server.
Code
function salesforce_api_fieldmap_options($action = NULL, $drupal = NULL, $salesforce = NULL) {
$options = array();
// Loop through all the indexed field maps.
for ($i = 1; $i <= variable_get('salesforce_fieldmap_index', 0); $i++) {
// Load the map for this index.
$map = variable_get('salesforce_fieldmap_' . $i, array());
// Skip the fieldmap if it is not for the appropriate action.
if (!empty($action) && $map['action'] != $action) {
continue;
}
// Skip the fieldmap if it is not for the appropriate Drupal object.
if (!empty($drupal) && $map['drupal'] != $drupal) {
continue;
}
// Skip the fieldmap if it is not for the appropriate Salesforce object.
if (!empty($salesforce) && $map['salesforce'] != $salesforce) {
continue;
}
// Setup some replacement args for the label.
$args = array(
'@drupal' => salesforce_api_fieldmap_object_label('drupal', $map['drupal']),
'@salesforce' => salesforce_api_fieldmap_object_label('salesforce', $map['salesforce']),
);
// Add the fieldmap to the options array with an appropriate title.
if ($map['action'] == 'import') {
$options[$map['index']] = t('Salesforce @salesforce to Drupal @drupal', $args);
}
else {
$options[$map['index']] = t('Drupal @drupal to Salesforce @salesforce', $args);
}
}
return $options;
}