You are here

function location_cck_field_update in Location 7.3

Same name and namespace in other branches
  1. 7.5 contrib/location_cck/location_cck.module \location_cck_field_update()
  2. 7.4 contrib/location_cck/location_cck.module \location_cck_field_update()

Implement hook_field_update().

File

contrib/location_cck/location_cck.module, line 196
Defines location field type.

Code

function location_cck_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) {
  $criteria = array();
  if ($entity_type == 'node') {
    if (!empty($items)) {

      // Store instances of locations by field name and vid.
      $criteria = array(
        'genid' => 'cck:' . $field['field_name'] . ':' . $entity->vid,
        'vid' => $entity->vid,
        'nid' => $entity->nid,
      );
      location_save_locations($items, $criteria);
    }
  }
  elseif ($entity_type == 'user') {
    if (!empty($items)) {

      // Store instances of locations by field name and vid.
      $criteria = array(
        'genid' => 'cck:' . $field['field_name'] . ':' . $entity->uid,
        'uid' => $entity->uid,
      );
      location_save_locations($items, $criteria);
    }
  }
  elseif (!empty($items)) {
    list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);

    // Store instances of locations by field name and vid.
    $criteria = array(
      'genid' => 'field:' . $field['field_name'] . ':' . $entity_type . ':' . $id,
      'vid' => $vid ? $vid : $id,
      'nid' => $id,
    );
    location_save_locations($items, $criteria);
  }
}