Details
-
Type: Patch
-
Status: Done/Fixed
-
Priority: Minor
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.2.6
-
Fix Version/s: 4.3.0
-
Component/s: Drupal Integration Modules
-
Labels:
Description
In order to get views relationships working for civicrm_contact_ref, Drupal's hook_field_views_data() needs to implemented, specifically the property that defines the relationship to another base table - in this case,
{civicrm_contact}. This enables one to add views relationship (to a node-based view) on that civicrm_contact_ref field and then to add fields to the view that come from the related contact.
But there's more: while just making this change gets the basic views query working, adding further views relationships to CiviCRM Relationships (via the new Contact relationship) doesn't work. This is because (in the scenario above), the views handler defined in civicrm_handler_relationship.inc fails to 'swap' the contact_id_a and contact_id_b, or vice versa, when the CiviCRM Relationships relationship is second in the chain. That's because the relevant if-statement assumes a particular naming convention for the $this->view->query->table_queue array keys (namely, 'civicrm_relationship'), but when this relationship is second or later in a chain, this key actually gets the 'table_alias' value, which is longer and more dynamic. The additional patch for views/civicrm/civicrm_handler_relationship.inc changes the condition on this if-statement to take into account this sort of chaining.