profile.inc 915 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * @file
  4. * On behalf implementation of Feeds mapping API for profile.module.
  5. */
  6. /**
  7. * Implements hook_feeds_processor_targets().
  8. */
  9. function profile_feeds_processor_targets($entity_type, $bundle_name) {
  10. $targets = array();
  11. if ($entity_type != 'user') {
  12. return $targets;
  13. }
  14. $categories = profile_user_categories();
  15. foreach ($categories as $category) {
  16. foreach (_profile_get_fields($category['name']) as $record) {
  17. $targets[$record->name] = array(
  18. 'name' => t('Profile: @name', array('@name' => $record->title)),
  19. 'description' => t('Profile: @name', array('@name' => $record->title)),
  20. 'callback' => 'profile_feeds_set_target',
  21. );
  22. }
  23. }
  24. return $targets;
  25. }
  26. /**
  27. * Set the user profile target after import.
  28. */
  29. function profile_feeds_set_target(FeedsSource $source, $entity, $target, array $values) {
  30. $entity->$target = reset($values);
  31. }