From 6ce764613a3fde0e28843c2ea78b7d14879fd5e7 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 26 Jul 2013 14:17:17 -0700 Subject: [PATCH] Fix group api to work with group_type param --- CRM/Contact/BAO/Group.php | 12 +++++++++++- api/v3/Group.php | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CRM/Contact/BAO/Group.php b/CRM/Contact/BAO/Group.php index 5fd504daed..c8f37c8a09 100644 --- a/CRM/Contact/BAO/Group.php +++ b/CRM/Contact/BAO/Group.php @@ -241,13 +241,23 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { $rowCount = NULL ) { $dao = new CRM_Contact_DAO_Group(); - $dao->is_active = 1; + if (!isset($params['is_active'])) { + $dao->is_active = 1; + } if ($params) { foreach ($params as $k => $v) { if ($k == 'name' || $k == 'title') { $dao->whereAdd($k . ' LIKE "' . CRM_Core_DAO::escapeString($v) . '"'); } + elseif ($k == 'group_type') { + foreach ((array) $v as $type) { + $dao->whereAdd($k . " LIKE '%" . CRM_Core_DAO::VALUE_SEPARATOR . (int) $type . CRM_Core_DAO::VALUE_SEPARATOR . "%'"); + } + } elseif (is_array($v)) { + foreach ($v as &$num) { + $num = (int) $num; + } $dao->whereAdd($k . ' IN (' . implode(',', $v) . ')'); } else { diff --git a/api/v3/Group.php b/api/v3/Group.php index 440f040604..109d62d015 100644 --- a/api/v3/Group.php +++ b/api/v3/Group.php @@ -103,7 +103,7 @@ function civicrm_api3_group_get($params) { $returnProperties['id'] = 1; $returnProperties = array_keys($returnProperties); } - if (CRM_Utils_Array::value('group_id', $inputParams)) { + if (!empty($inputParams['group_id'])) { $inputParams['id'] = $inputParams['group_id']; } $groupObjects = CRM_Contact_BAO_Group::getGroups($inputParams, $returnProperties, $sort, $offset, $rowCount); -- 2.25.1