You are here

function nodequeue_handler_relationship_nodequeue::query in Nodequeue 7.2

Same name and namespace in other branches
  1. 6.2 includes/views/nodequeue_handler_relationship_nodequeue.inc \nodequeue_handler_relationship_nodequeue::query()
  2. 7.3 includes/views/nodequeue_handler_relationship_nodequeue.inc \nodequeue_handler_relationship_nodequeue::query()

Called to implement a relationship in a query.

Overrides views_handler_relationship::query

File

includes/views/nodequeue_handler_relationship_nodequeue.inc, line 82
Specialized relationship handler to add nodequeues.

Class

nodequeue_handler_relationship_nodequeue
@file Specialized relationship handler to add nodequeues.

Code

function query() {

  // Figure out what base table this relationship brings to the party.
  $join = new views_join();
  $join->definition = array(
    'table' => 'nodequeue_nodes',
    'field' => 'nid',
    'left_table' => 'node',
    'left_field' => 'nid',
  );
  if (!empty($this->options['required'])) {
    $join->definition['type'] = 'INNER';
  }
  if (!empty($this->options['limit'])) {
    $names = array_keys(array_filter($this->options['names']));
    $qids = array();
    $map = nodequeue_get_qid_map();
    foreach ($names as $name) {
      if (isset($map[$name])) {
        $qids[] = $map[$name];
      }
    }
    $join->definition['extra'] = array(
      array(
        'field' => 'qid',
        'value' => $qids,
      ),
    );
  }
  $join
    ->construct();
  $alias = $join->definition['table'] . '_' . $join->definition['left_table'];
  $this->alias = $this->query
    ->add_relationship($alias, $join, 'nodequeue_nodes', $this->relationship);
}