Skip to content

Commit

Permalink
Merge branch '4.0-dev' into group-toobar-buttons-stages-transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
chmst committed Jan 20, 2019
2 parents 26c0231 + dd6ad46 commit 830f12c
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions components/com_finder/Model/SearchModel.php
Expand Up @@ -171,13 +171,15 @@ protected function getListQuery()
{
// Convert the associative array to a numerically indexed array.
$groups = array_values($this->searchquery->filters);
$taxonomies = call_user_func_array('array_merge', array_values($this->searchquery->filters));

// Iterate through each taxonomy group and add the join and where.
$query->join('INNER', $db->quoteName('#__finder_taxonomy_map') . ' AS t ON t.link_id = l.link_id')
->where('t.node_id IN (' . implode(',', array_unique($taxonomies)) . ')');

// Iterate through each taxonomy group.
for ($i = 0, $c = count($groups); $i < $c; $i++)
{
// We use the offset because each join needs a unique alias.
$query->join('INNER', $db->quoteName('#__finder_taxonomy_map') . ' AS t' . $i . ' ON t' . $i . '.link_id = l.link_id')
->where('t' . $i . '.node_id IN (' . implode(',', $groups[$i]) . ')');
$query->having('SUM(t.node_id IN (' . implode(',', $groups[$i]) . ')) > 0');
}
}

Expand Down Expand Up @@ -283,6 +285,7 @@ protected function getListQuery()
// Since we need to return a query, we simplify this one.
$query->clear('join')
->clear('where')
->clear('having')
->clear('group')
->where('false');

Expand All @@ -308,13 +311,16 @@ protected function getListQuery()
*/
if (count($this->requiredTerms))
{
$i = 0;

foreach ($this->requiredTerms as $terms)
{
$query->join('INNER', $this->_db->quoteName('#__finder_links_terms') . ' AS r' . $i . ' ON r' . $i . '.link_id = l.link_id')
->where('r' . $i . '.term_id IN (' . implode(',', $terms) . ')');
$i++;
if (count($terms))
{
$query->having('SUM(m.term_id IN (' . implode(',', $terms) . ')) > 0');
}
else
{
$query->where('false');
}
}
}

Expand Down

0 comments on commit 830f12c

Please sign in to comment.