$statii[] = '"Added"';
}
- $ssClause = $this->addGroupContactCache($value, NULL, "contact_a", $op);
+ //CRM-19589: contact(s) removed from a Smart Group, resides in civicrm_group_contact table
+ $ssClause = NULL;
+ if (in_array("'Added'", $statii) || // if both Added and Removed statuses are selected
+ (count($statii) == 1 && $statii[0] == 'Removed') // if only Removed status is selected
+ ) {
+ $ssClause = $this->addGroupContactCache($value, NULL, "contact_a", $op);
+ }
+
$isSmart = (!$ssClause) ? FALSE : TRUE;
if (!is_array($value) &&
count($statii) == 1 &&
}
$groupClause = NULL;
- if (!$isSmart) {
+ if (!$isSmart || in_array("'Added'", $statii)) {
$groupIds = implode(',', (array) $value);
$gcTable = "`civicrm_group_contact-{$groupIds}`";
$joinClause = array("contact_a.id = {$gcTable}.contact_id");
if (strpos($op, 'NULL') === FALSE) {
$this->_qill[$grouping][] = ts("Group Status %1", array(1 => implode(' ' . ts('or') . ' ', $statii)));
}
+
if ($groupClause) {
$this->_where[$grouping][] = $groupClause;
}