1064666-supports-any-entity-type_0.patch 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. diff --git contrib/location_cck/location_cck.module contrib/location_cck/location_cck.module
  2. index ba1a592..a5bcc77 100644
  3. --- contrib/location_cck/location_cck.module
  4. +++ contrib/location_cck/location_cck.module
  5. @@ -162,6 +162,17 @@ function location_cck_field_insert($entity_type, $entity, $field, $instance, $la
  6. );
  7. location_save_locations($items, $criteria);
  8. }
  9. + }else{
  10. + if (!empty($items)) {
  11. + list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
  12. + // Store instances of locations by field name and vid.
  13. + $criteria = array(
  14. + 'genid' => 'field:' . $field['field_name'] . ':' . $entity_type . ':' . $id,
  15. + 'vid' => $vid ? $vid : $id,
  16. + 'nid' => $id,
  17. + );
  18. + location_save_locations($items, $criteria);
  19. + }
  20. }
  21. }
  22. @@ -179,6 +190,17 @@ function location_cck_field_update($entity_type, $entity, $field, $instance, $la
  23. );
  24. location_save_locations($items, $criteria);
  25. }
  26. + }else{
  27. + if (!empty($items)) {
  28. + list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
  29. + // Store instances of locations by field name and vid.
  30. + $criteria = array(
  31. + 'genid' => 'field:' . $field['field_name'] . ':' . $entity_type . ':' . $id,
  32. + 'vid' => $vid ? $vid : $id,
  33. + 'nid' => $id,
  34. + );
  35. + location_save_locations($items, $criteria);
  36. + }
  37. }
  38. }
  39. @@ -199,6 +221,11 @@ function location_cck_field_delete($entity_type, $entity, $field, $instance, $la
  40. $locs = array();
  41. location_save_locations($locs, array('genid' => $genid));
  42. }
  43. + }else {
  44. + list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
  45. + $genid = 'field:' . $field['field_name'] . ':' . $entity_type . ':' . $id;
  46. + $locs = array();
  47. + location_save_locations($locs, array('genid' => $genid));
  48. }
  49. }
  50. @@ -210,6 +237,11 @@ function location_cck_field_delete_revision($entity_type, $entity, $field, $inst
  51. $genid = 'cck:' . $field['field_name'] . ':' . $entity->vid;
  52. $locs = array();
  53. location_save_locations($locs, array('genid' => $genid));
  54. + } else {
  55. + list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
  56. + $genid = 'field:' . $field['field_name'] . ':' . $entity_type . ':' . $id;
  57. + $locs = array();
  58. + location_save_locations($locs, array('genid' => $genid));
  59. }
  60. }
  61. @@ -224,7 +256,6 @@ function location_cck_field_validate($entity_type, $entity, $field, $instance, $
  62. * Implement hook_field_load().
  63. */
  64. function location_cck_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) {
  65. - if ($entity_type == 'node') {
  66. foreach ($entities as $id => $entity) {
  67. foreach ($items[$id] as $delta => $item) {
  68. $location = array();
  69. @@ -238,7 +269,6 @@ function location_cck_field_load($entity_type, $entities, $field, $instances, $l
  70. $items[$id][$delta] = array_merge($location, $item);
  71. }
  72. }
  73. - }
  74. }
  75. /**