You are here

function views_join_term_edge::join in Taxonomy Edge 6

File

views_taxonomy_edge/handlers/views_join_term_edge.inc, line 6

Class

views_join_term_edge
@file

Code

function join($table, &$query) {
  $found = FALSE;

  // If there's a condition on parent, then let it be unless it's blank.
  // If it's blank we set it to the root of the tree.
  foreach ($query->where as $data) {
    foreach ($data['clauses'] as $condition) {
      if (strpos($condition, $table['alias'] . '.parent ') !== FALSE) {
        $found = TRUE;
        break;
      }
    }
  }
  $result = parent::join($table, $query);
  $result .= ' AND ' . $table['alias'] . '.vid = ' . $this->left_table . '.vid';

  // If no condition on parent was found, add the root pid as a condition.
  if (!$found) {
    $result .= ' AND ' . $table['alias'] . '.parent = 0 ';
  }
  return $result;
}