You are here

function sf_user_fieldmap_objects in Salesforce Suite 6.2

Same name and namespace in other branches
  1. 5.2 sf_user/sf_user.module \sf_user_fieldmap_objects()

Implementation of hook_fieldmap_objects().

File

sf_user/sf_user.module, line 164
Integrates the core user object and profile module with the Salesforce API.

Code

function sf_user_fieldmap_objects($type) {
  $objects = array();

  // Define the data fields available for Drupal objects.
  if ($type == 'drupal') {
    $objects['user'] = array(
      'label' => t('User account'),
      'fields' => array(
        'uid' => array(
          'label' => t('User ID'),
          'type' => SALESFORCE_FIELD_SOURCE_ONLY,
        ),
        'name' => array(
          'label' => t('Username'),
        ),
        'mail' => array(
          'label' => t('E-mail address'),
        ),
        'created' => array(
          'label' => t('Created timestamp'),
        ),
        'access' => array(
          'label' => t('Last access timestamp'),
        ),
        'login' => array(
          'label' => t('Last login timestamp'),
        ),
        'status' => array(
          'label' => t('Account status'),
        ),
        'picture' => array(
          'label' => t('Picture'),
        ),
      ),
    );

    // Add profile fields to the user object if the module is enabled.
    if (module_exists('profile')) {

      // Load all the profile fields from the database.
      $result = db_query("SELECT fid, name, title, category, type FROM {profile_fields} ORDER BY category, weight");

      // Loop through the fields and add them to the Drupal user object.
      while ($field = db_fetch_array($result)) {
        if ($field['type'] != 'date') {
          $objects['user']['fields'][$field['name']] = array(
            'label' => t('@category: @title', array(
              '@category' => $field['category'],
              '@title' => $field['title'],
            )),
            'group' => t('Profile fields'),
          );
        }
        else {
          $objects['user']['fields'][$field['name']] = array(
            'label' => t('@category: @title', array(
              '@category' => $field['category'],
              '@title' => $field['title'],
            )),
            'group' => t('Profile fields'),
            'export' => '_sf_user_export_profile_date',
          );
        }
      }
    }
  }
  return $objects;
}