--- nodereferrer_view_handler_relationship.inc 22 Sep 2009 11:15:35 -0000 1.1.2.3 +++ nodereferrer_view_handler_relationship.inc 26 May 2010 00:12:44 -0000 @@ -76,4 +76,40 @@ return $this->table_alias; } + + /** + * Called to implement a relationship in a query. + */ + function query() { + // Figure out what base table this relationship brings to the party. + $table_data = views_fetch_data($this->definition['base']); + $base_field = empty($this->definition['base field']) ? $table_data['table']['base']['field'] : $this->definition['base field']; + + $this->ensure_my_table(); + + $def = $this->definition; + $def['table'] = $this->definition['base']; + $def['field'] = 'vid'; + $def['left_table'] = $this->table_alias; + $def['left_field'] = 'vid'; + if (!empty($this->options['required'])) { + $def['type'] = 'INNER'; + } + + if (!empty($def['join_handler']) && class_exists($def['join_handler'])) { + $join = new $def['join_handler']; + } + else { + $join = new views_join(); + } + + $join->definition = $def; + $join->construct(); + $join->adjusted = TRUE; + + // use a short alias for this: + $alias = $def['table'] . '_' . $this->table; + + $this->alias = $this->query->add_relationship($alias, $join, $this->definition['base'], $this->relationship); + } }