CRM-15107 - Fix count from static groups to only count 'Added' status
authorColeman Watts <coleman@civicrm.org>
Thu, 13 Nov 2014 01:33:10 +0000 (20:33 -0500)
committerColeman Watts <coleman@civicrm.org>
Thu, 13 Nov 2014 01:33:10 +0000 (20:33 -0500)
CRM/Contact/BAO/Group.php

index 8743a3131e0f92a1a367c68417678af74e06c675..c33a9319a24f5358a70531b9de9bfe3cf2ed4ab2 100644 (file)
@@ -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;
       }