You are here

function select_translation_filter_handler::node_access_join in Select translation 7

Join to the node table where the nodes have the given language.

Parameters

views_join $join: The views join object.

string $language: The language of the nodes that should be retrieved.

string $alias: The alias of the main node table.

string $sub_query_alias: The alias of the sub query node table.

string $extra: A string with extra join conditions.

1 call to select_translation_filter_handler::node_access_join()
select_translation_filter_handler::better_query in ./select_translation_filter_handler.inc
A query that doesn't use correlated sub-queries.

File

./select_translation_filter_handler.inc, line 245
Views select translation filter handler.

Class

select_translation_filter_handler

Code

function node_access_join(&$join, $language, $alias, $sub_query_alias, $extra = NULL) {
  $sub_query = db_select('node', $sub_query_alias);
  $sub_query
    ->addField($sub_query_alias, 'nid');
  $sub_query
    ->addField($sub_query_alias, 'tnid');
  $sub_query
    ->addfield($sub_query_alias, 'status');
  $sub_query
    ->addField($sub_query_alias, 'language');
  $sub_query
    ->where("{$sub_query_alias}.language = '{$language}'");

  // If not extra argument was sent, use the default one.
  if ($extra === NULL) {

    // Nodes have translations when translation id is different from 0.
    $extra = "{$alias}.tnid != 0";
  }
  $join
    ->construct($sub_query, $alias, 'tnid', 'tnid', array(
    $extra,
  ));
}