Projet

Général

Profil

Paste
Télécharger (868 octets) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / feeds / mappers / profile.inc @ 74f6bef0

1
<?php
2

    
3
/**
4
 * @file
5
 * On behalf implementation of Feeds mapping API for user profiles.
6
 */
7

    
8
/**
9
 * Implements hook_feeds_processor_target_alter().
10
 */
11
function profile_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_name) {
12

    
13
  if ($entity_type != 'user') {
14
    return;
15
  }
16

    
17
  $categories = profile_user_categories();
18

    
19
  foreach ($categories as $category) {
20
    foreach (_profile_get_fields($category['name']) as $record) {
21
      $targets[$record->name] = array(
22
        'name' => t('Profile: @name', array('@name' => $record->title)),
23
        'description' => t('Profile: @name', array('@name' => $record->title)),
24
        'callback' => 'profile_feeds_set_target',
25
      );
26
    }
27
  }
28
}
29

    
30
/**
31
 * Set the user profile target after import.
32
 */
33
function profile_feeds_set_target($source, $entity, $target, $value, $mapping) {
34
  $entity->$target = $value;
35
}