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