You are here

function sf_user_fieldmap_objects in Salesforce Suite 5.2

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

Implementation of hook_fieldmap_objects().

File

sf_user/sf_user.module, line 65
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'),
          'type' => SALESFORCE_FIELD_REQUIRED,
        ),
        'mail' => array(
          'label' => t('E-mail address'),
          'type' => SALESFORCE_FIELD_REQUIRED,
        ),
        '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'),
        ),
      ),
    );

    // 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 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)) {
        $objects['user']['fields'][$field['name']] = array(
          'label' => t('@category: @title', array(
            '@category' => $field['category'],
            '@title' => $field['title'],
          )),
          'group' => t('Profile fields'),
        );
      }
    }
  }
  return $objects;
}