profile.inc 868 B

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