Merge pull request #4768 from rohankatkar/CRM-10331Fix
[civicrm-core.git] / CRM / Contact / BAO / GroupContact.php
index 0c1425ca060e353c580e69c09007cafd67373216..b7d75d17cfc8a80f6a3a2da9af9004a70f0e9ff0 100644 (file)
@@ -334,7 +334,8 @@ class CRM_Contact_BAO_GroupContact extends CRM_Contact_DAO_GroupContact {
     $count            = FALSE,
     $ignorePermission = FALSE,
     $onlyPublicGroups = FALSE,
-    $excludeHidden    = TRUE
+    $excludeHidden    = TRUE,
+    $groupId          = NULL
   ) {
     if ($count) {
       $select = 'SELECT count(DISTINCT civicrm_group_contact.id)';
@@ -362,6 +363,10 @@ class CRM_Contact_BAO_GroupContact extends CRM_Contact_DAO_GroupContact {
       $where .= ' AND civicrm_group_contact.status = %2';
       $params[2] = array($status, 'String');
     }
+    if (!empty($groupId)) {
+      $where .= " AND civicrm_group.id = %3 ";
+      $params[3] = array($groupId, 'Integer');
+    }
     $tables = array(
       'civicrm_group_contact' => 1,
       'civicrm_group' => 1,