Index: nodereference.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cck/nodereference.module,v retrieving revision 1.25.2.31 diff -u -r1.25.2.31 nodereference.module --- nodereference.module 11 Feb 2007 23:07:20 -0000 1.25.2.31 +++ nodereference.module 28 Feb 2007 13:36:01 -0000 @@ -491,3 +491,54 @@ $options = $options + _nodereference_potential_references($filterinfo['extra']['field']); return $options; } + +/* + * Implementation of hook_views_fusion() + */ +function nodereference_views_fusion() { + $field_types = _content_field_types(); + $return = array(); + foreach (content_fields() as $field) { + if ($field['type'] == 'nodereference') { + $db_info = content_database_info($field); + $fusion = array( + 'title' => $field_types[$field['type']]['label'] .': '. $field['widget']['label'] .' ('. $field['field_name'] .')', + 'field' => $db_info['columns']['nid']['column'], + ); + $return['node_data_'. $field['field_name']] = $fusion; + $fusion = array( + 'title' => $field_types[$field['type']]['label'] .': '. $field['widget']['label'] .' ('. $field['field_name'] .') - reverse direction', + 'field' => 'nid', + ); + $return['node_data_'. $field['field_name'] .'_reverse'] = $fusion; + } + } + return $return; +} + +/** + * Implementation of hook_views_tables(). + * Exposes further table definitions to views, which are needed by views_fusion for using the nodereference reverse + */ +function nodereference_views_tables() { + $field_types = _content_field_types(); + $tables = array(); + foreach (content_fields() as $field) { + if ($field['type'] == 'nodereference') { + $db_info = content_database_info($field); + $tables['node_data_'. $field['field_name'] .'_reverse'] = array( + 'name' => $db_info['table'], + 'join' => array( + 'left' => array( + 'table' => 'node', + 'field' => 'nid', + ), + 'right' => array( + 'field' => $db_info['columns']['nid']['column'] + ), + ), + ); + } + } + return $tables; +}