function _civicrm_entity_profile_process_field_item in CiviCRM Entity 7.2
- Helper function to process field item on entity insert or update
Parameters
$entity_type:
$entity:
$instance:
$item:
2 calls to _civicrm_entity_profile_process_field_item()
- civicrm_entity_profile_field_insert in modules/
civicrm_entity_profile/ civicrm_entity_profile.module - Implements hook_field_insert().
- civicrm_entity_profile_field_update in modules/
civicrm_entity_profile/ civicrm_entity_profile.module - Implements hook_field_update().
File
- modules/
civicrm_entity_profile/ civicrm_entity_profile.module, line 346
Code
function _civicrm_entity_profile_process_field_item($entity_type, $entity, $instance, $item, $delta) {
if ($entity_type == 'civicrm_event') {
$module = !empty($instance['settings']['registrant_type']) ? $instance['settings']['registrant_type'] : 'CiviEvent';
}
else {
$module = 'CiviContribute';
}
if (!empty($item['target_id'])) {
if (!empty($item['uf_group_id'])) {
$uf_join = entity_load_single('civicrm_uf_join', $item['target_id']);
$uf_join->uf_group_id = $item['uf_group_id'];
$uf_join->weight = $delta + 1;
$uf_join->is_active = 1;
$uf_join_wrapper = entity_metadata_wrapper('civicrm_uf_join', $uf_join);
$uf_join_wrapper
->save();
}
else {
entity_delete('civicrm_uf_join', $item['target_id']);
}
}
else {
if (!empty($item['uf_group_id'])) {
$uf_join = new CivicrmEntity(array(
'is_active' => 1,
'module' => $module,
'entity_table' => $entity_type,
'entity_id' => $entity->id,
'weight' => $delta + 1,
'uf_group_id' => $item['uf_group_id'],
), 'civicrm_uf_join');
$uf_join_wrapper = entity_metadata_wrapper('civicrm_uf_join', $uf_join);
$uf_join_wrapper
->save();
}
}
}