From: Rohan Katkar Date: Tue, 23 Dec 2014 06:38:39 +0000 (+0530) Subject: Fix for CRM-10331 group_id parameter ignored in API for GroupContact X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=49fb4e06d516583d96a5dd04da30cf7aa08ecc9c;p=civicrm-core.git Fix for CRM-10331 group_id parameter ignored in API for GroupContact --- diff --git a/CRM/Contact/BAO/GroupContact.php b/CRM/Contact/BAO/GroupContact.php index 0c1425ca06..b7d75d17cf 100644 --- a/CRM/Contact/BAO/GroupContact.php +++ b/CRM/Contact/BAO/GroupContact.php @@ -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, diff --git a/api/v3/GroupContact.php b/api/v3/GroupContact.php index 83282fde0e..003baac600 100644 --- a/api/v3/GroupContact.php +++ b/api/v3/GroupContact.php @@ -62,7 +62,8 @@ function civicrm_api3_group_contact_get($params) { } $status = CRM_Utils_Array::value('status', $params, 'Added'); - $values = &CRM_Contact_BAO_GroupContact::getContactGroup($params['contact_id'], $status, NULL, FALSE, TRUE); + $groupId = CRM_Utils_Array::value('group_id', $params); + $values = &CRM_Contact_BAO_GroupContact::getContactGroup($params['contact_id'], $status, NULL, FALSE, TRUE, FALSE, TRUE, $groupId); return civicrm_api3_create_success($values, $params); }