if (!empty($base_group_ids)) {
$baseGroupClause = "OR $group.id IN(" . implode(', ', $base_group_ids) . ")";
}
+ $groupIdClause = '';
+ if ($group_ids || $base_group_ids) {
+ $groupIdClause = "AND $group.id IN (" . implode(', ', array_merge($group_ids, $base_group_ids)) . ")";
+ }
$do->query("
SELECT $group.id as group_id,
$group.title as title,
FROM $group
LEFT JOIN $gc
ON $gc.group_id = $group.id
- WHERE $group.id IN (" . implode(', ', array_merge($group_ids, $base_group_ids)) . ")
- AND $group.is_hidden = 0
+ WHERE $group.is_hidden = 0
+ $groupIdClause
AND ($group.saved_search_id is not null
OR ($gc.contact_id = $contact_id
AND $gc.status = 'Added')