function salesforce_api_demo in Salesforce Suite 7.2
Same name and namespace in other branches
- 5.2 salesforce_api/salesforce_api.module \salesforce_api_demo()
- 6.2 salesforce_api/salesforce_api.admin.inc \salesforce_api_demo()
- 7 salesforce_api/salesforce_api.admin.inc \salesforce_api_demo()
Demonstrates some of the API functionality through the Salesforce class and fieldmap functionality.
@todo Rewrite the demos to make them more useful, cf. [#692378]
Parameters
$demo: The name of the demonstration to perform.
Return value
A string containing the page output.
1 string reference to 'salesforce_api_demo'
- salesforce_api_menu in salesforce_api/
salesforce_api.module - Implements hook_menu().
File
- salesforce_api/
salesforce_api.admin.inc, line 1359 - Contains the admin page callbacks for the Salesforce module, including forms for general settings and fieldmap administration.
Code
function salesforce_api_demo($demo = NULL, $arg = NULL) {
global $user;
// Attempt to connect to Salesforce.
$sf = salesforce_api_connect();
// Display an error message if the connection failed.
if (!$sf) {
return t('Could not connect to Salesforce. Please doublecheck your API credentials.');
}
// Display the server timestamp first.
$response = $sf->client
->getServerTimestamp();
$output = '<p><strong>' . t('Salesforce server timestamp') . ': </strong>' . $response->timestamp . '</p>';
// Add a specific demo's output.
switch ($demo) {
case 'data-structure':
if ($arg) {
$response = salesforce_api_describeSObjects(array(
check_plain($arg),
));
if (function_exists('dpm')) {
dpm($response);
}
elseif (function_exists('krumo')) {
$output .= krumo($response);
}
else {
$output .= '<pre>' . print_r($response, 1) . '</pre>';
}
}
else {
$response = salesforce_api_describeGlobal();
if (is_array($response->types)) {
foreach ($response->types as $type) {
$items[] = l($type->label, SALESFORCE_PATH_DEMO . '/data-structure/' . $type->name);
}
$output .= theme('item_list', array(
'items' => $items,
'title' => t('Global Data Structure'),
));
}
}
break;
}
$items = array(
l(t('Examine Data Structure'), SALESFORCE_PATH_DEMO . '/data-structure'),
);
if (module_exists('sf_entity')) {
$items[] = l(t('Export your user account as a contact'), 'user/' . $user->uid . '/salesforce');
$nodes = node_load_multiple(array(), array(
'type' => 'page',
));
if (count($nodes)) {
$node = array_shift($nodes);
$items[] = l(t('Export node @nid as a Campaign', array(
'@nid' => $node->nid,
)), 'node/' . $node->nid . '/salesforce');
}
}
$output .= '<p><strong>' . t('Choose from the following demonstrations:') . '</strong>' . theme('item_list', array(
'items' => $items,
)) . '</p>';
return $output;
}