Fix group api to work with group_type param
authorColeman Watts <coleman@civicrm.org>
Fri, 26 Jul 2013 21:17:17 +0000 (14:17 -0700)
committerColeman Watts <coleman@civicrm.org>
Fri, 26 Jul 2013 21:17:17 +0000 (14:17 -0700)
CRM/Contact/BAO/Group.php
api/v3/Group.php

index 5fd504daeda6195a7e9a6918f67950dc656a35b1..c8f37c8a093aabc6253d0537be71b8a80a988205 100644 (file)
@@ -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 {
index 440f040604a7c46eae152d6312cc89c7c89374cb..109d62d0155b5d2993370f39ca6f4e722dcf9763 100644 (file)
@@ -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);