Index: location_cck.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/location/contrib/location_cck/location_cck.module,v
retrieving revision 1.23
diff -u -r1.23 location_cck.module
--- location_cck.module	30 Jul 2009 20:53:48 -0000	1.23
+++ location_cck.module	1 Aug 2009 14:21:21 -0000
@@ -108,18 +108,28 @@
       );
 
     case 'views data':
-      // We want to for the most part use the CCK stuff, but we also want to
-      // patch in a relationship so location's views support can target
-      // cck fields directly.
-      $table = content_views_tablename($field);
-      $db_info = content_database_info($field);
-      $field_alias = $db_info['columns']['lid']['column'];
       $data = content_views_field_views_data($field);
-      $data[$table][$field_alias]['relationship'] = array(
-        'base' => 'location',
+      $db_info = content_database_info($field);
+      $table_alias = content_views_tablename($field);
+
+      // Filter: swap the handler to the 'in' operator.
+      $data[$table_alias][$field['field_name'] .'_lid']['filter']['handler'] = 'content_handler_filter_many_to_one';
+      // Argument: use node.title for summaries.
+      $data["location_$table_alias"]['table']['join']['node'] = array(
+        'table' => 'location',
         'field' => 'lid',
-        'handler' => 'views_handler_relationship',
-        'label' => t('Location'), // @@@ Some sort of better name?
+        'left_table' => $table_alias,
+        'left_field' => $field['field_name'] .'_lid',
+      );
+      $data[$table_alias][$field['field_name'] .'_lid']['argument']['name table'] = "location_$table_alias";
+      $data[$table_alias][$field['field_name'] .'_lid']['argument']['name field'] = 'title';
+      // Relationship: add a relationship for related node.
+      $data[$table_alias][$field['field_name'] .'_lid']['relationship'] = array(
+        'base' => 'location',
+        'field' => $db_info['columns']['lid']['column'],
+        'handler' => 'content_handler_relationship',
+        'label' => t($field['widget']['label']),
+        'content_field_name' => $field['field_name'],
       );
       return $data;
   }
@@ -142,10 +152,20 @@
     case 'load':
       $locations = array();
       // Locations are being cached by CCK now. Load the full location.
-      foreach ($items as $item) {
-        $locations[] = location_load_location($item['lid']);
+      foreach ($items as $key => $item) {
+        $location = location_load_location($item['lid']);
+        $location['field_name'] = $field['field_name'];
+        $location['offset'] = $key;
+        $locations[] = $location;
+      }
+      // Merge each location field into $node->locations for backwards compat.
+      if (isset($node->locations) && is_array($node->locations)) {
+        $node->locations = array_merge($node->locations, $locations);
+      }
+      else {
+        $node->locations = $locations;
       }
-      return array($field['field_name'] => $locations);
+      return array($field['field_name'] => $locations, 'locations' => $node->locations);
 
     case 'delete':
       // Use the CCK storage to figure out the vids that need to be deleted,

