You are here

function og_handler_relationship::query in Organic groups 7.2

Same name and namespace in other branches
  1. 7 includes/views/og_handler_relationship.inc \og_handler_relationship::query()

Called to implement a relationship in a query.

Overrides views_handler_relationship::query

File

includes/views/handlers/og_handler_relationship.inc, line 19
Contains various relationship handlers.

Class

og_handler_relationship
Specialized relationship handler associating groups and their entity.

Code

function query() {

  // If the entity type is specific for the og_membership
  // filter the join to select membership of those entity types.
  if (isset($this->definition['entity'])) {
    $extra = array(
      'field' => 'entity_type',
      'value' => $this->definition['entity'],
    );

    // Only add the table if og_membership is the left table since when the
    // table is specified to views_join, it only translates the table alias
    // of tables in the left position, however if no table is specified,
    // then views_join correctly inserts the alias of the table in the right
    // position of the join.
    if ($this->definition['base'] != 'og_membership') {
      $extra['table'] = 'og_membership';
    }
    $this->definition['extra'][] = $extra;
  }

  // If the group type is specific for the og_membership
  // filter the join to select membership of those group types.
  if (isset($this->definition['group_type'])) {
    $extra = array(
      'field' => 'group_type',
      'value' => $this->definition['group_type'],
    );

    // Only add the table if og_membership is the left table since when the
    // table is specified to views_join, it only translates the table alias
    // of tables in the left position, however if no table is specified,
    // then views_join correctly inserts the alias of the table in the right
    // position of the join.
    if ($this->definition['base'] != 'og_membership') {
      $extra['table'] = 'og_membership';
    }
    $this->definition['extra'][] = $extra;
  }
  parent::query();
}