You are here

function salesforce_api_admin_object in Salesforce Suite 7

Same name and namespace in other branches
  1. 6.2 salesforce_api/ \salesforce_api_admin_object()
  2. 7.2 salesforce_api/ \salesforce_api_admin_object()

Ask salesforce for a list of objects and display a checklist for the user. Based on user selection, set up or tear down cached/synched Salesforce data. @TODO make this more user friendly. At the moment it's possible for an admin user to blow away their entire local SalesForce cache with a few clicks. This is not necessarily desirable.

@author aaron


string $form_state:

Return value


1 string reference to 'salesforce_api_admin_object'
salesforce_api_menu in salesforce_api/salesforce_api.module
Implements hook_menu().


salesforce_api/, line 529
Contains the admin page callbacks for the Salesforce module, including forms for general settings and fieldmap administration.


function salesforce_api_admin_object($form, &$form_state) {
  $response = salesforce_api_describeGlobal();
  if (empty($response->types)) {
    drupal_set_message(t('There was an error retrieving the list of SalesForce objects. Please verify that your SalesForce instance is properly configured.'), 'error');
  $defaults = salesforce_api_fieldmap_objects();
  $defaults = array_keys($defaults['salesforce']);
  $options = $disabled = array();
  foreach ($response->types as $obj) {
    $options[$obj->name] = $obj->name . ' (' . $obj->label . ')';

  // Disable any SF Object types currently in use by fieldmap(s).
  $query = db_select('salesforce_field_map', 's');
    ->addExpression('DISTINCT s.salesforce', 'salesforce');
  $result = $query
  while ($type = $result
    ->fetch(PDO::FETCH_ASSOC)) {
    $disabled[$type] = $type;
  $fields = array(
    'objects' => array(
      '#type' => 'checkboxes',
      '#title' => 'Object Name (Object Label)',
      '#description' => 'Check the SalesForce objects you would like to synchronize locally.',
      '#options' => $options,
      '#default_value' => $defaults,
    'disabled_types' => array(
      '#type' => 'value',
      '#value' => $disabled,
    '#theme' => 'salesforce_api_object_options',
    'submit' => array(
      '#type' => 'submit',
      '#value' => 'Save',
  return $fields;