From: Coleman Watts Date: Thu, 13 Nov 2014 01:33:10 +0000 (-0500) Subject: CRM-15107 - Fix count from static groups to only count 'Added' status X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b08455a11c3edce816c3dc7924cf3383561d6d2a;p=civicrm-core.git CRM-15107 - Fix count from static groups to only count 'Added' status --- diff --git a/CRM/Contact/BAO/Group.php b/CRM/Contact/BAO/Group.php index 8743a3131e..c33a9319a2 100644 --- a/CRM/Contact/BAO/Group.php +++ b/CRM/Contact/BAO/Group.php @@ -974,7 +974,11 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { // Get group counts foreach ($groupsToCount as $table => $groups) { - $dao = CRM_Core_DAO::executeQuery("SELECT group_id, COUNT(id) as `count` FROM $table WHERE group_id IN (" . implode(',', $groups) . ") GROUP BY group_id"); + $where = "group_id IN (" . implode(',', $groups) . ")"; + if ($table == 'civicrm_group_contact') { + $where .= " AND status = 'Added'"; + } + $dao = CRM_Core_DAO::executeQuery("SELECT group_id, COUNT(id) as `count` FROM $table WHERE $where GROUP BY group_id"); while($dao->fetch()) { $values[$dao->group_id]['count'] = $dao->count; }