You are here

function location_cck_field_delete in Location 7.5

Same name and namespace in other branches
  1. 7.3 contrib/location_cck/location_cck.module \location_cck_field_delete()

Implement hook_field_delete().

File

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

Code

function location_cck_field_delete($entity_type, $entity, $field, $instance, $langcode, &$items) {
  if ($entity_type == 'node') {

    // @TODO: Fix this properly.
    // Use the CCK storage to figure out the vids that need to be deleted,
    // and clean up all the applicable references.
    // $db_info = content_database_info($field);
    //  $result = db_query('SELECT vid FROM {' . $db_info['table'] . '} WHERE nid = :nid', array(':nid' => $node->nid));
    $result = db_query('SELECT vid FROM {node_revision} WHERE nid = :nid', array(
      ':nid' => $entity->nid,
    ));
    foreach ($result as $row) {
      $genid = 'cck:' . $field['field_name'] . ':' . $row->vid;
      $locs = array();
      location_save_locations($locs, array(
        'genid' => $genid,
      ));
    }
  }
}