CRM-18591: group_type parameter ignored when using API to create group
authoryashodha <yashodha.chaku@webaccessglobal.com>
Wed, 20 Jul 2016 09:04:47 +0000 (14:34 +0530)
committeryashodha <yashodha.chaku@webaccessglobal.com>
Fri, 22 Jul 2016 07:23:15 +0000 (12:53 +0530)
----------------------------------------
* CRM-18591: group_type parameter ignored when using API to create group
  https://issues.civicrm.org/jira/browse/CRM-18591

CRM/Contact/BAO/Group.php
CRM/Group/Form/Edit.php
xml/schema/Contact/Group.xml

index 743ab94ccd179065b8b4354fec114f821adaa852..58a68060efb85331862773c6e023aa0e8cbdfafd 100644 (file)
@@ -365,7 +365,7 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group {
     if (isset($params['group_type'])) {
       if (is_array($params['group_type'])) {
         $params['group_type'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR,
-            array_keys($params['group_type'])
+            $params['group_type']
           ) . CRM_Core_DAO::VALUE_SEPARATOR;
       }
     }
index ab615f9958986c8530dfc9a218238965922b5721..1f09110cf54b15336a495f656b217d839632f330 100644 (file)
@@ -384,7 +384,17 @@ WHERE  title = %1
       }
 
       $params['is_reserved'] = CRM_Utils_Array::value('is_reserved', $params, FALSE);
-      $params['group_type'] = CRM_Utils_Array::value('group_type', $params, array());
+
+      $groupTypeIds = array();
+      $groupType = CRM_Utils_Array::value('group_type', $params);
+      if (is_array($groupType)) {
+        foreach ($groupType as $type => $selected) {
+          if ($selected) {
+            $groupTypeIds[] = $type;
+          }
+        }
+      }
+      $params['group_type'] = $groupTypeIds;
 
       $customFields = CRM_Core_BAO_CustomField::getFields('Group');
       $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params,
index 5f09e4147e1184e0dbcc46fde089f630c1fbdb69..fb9c1bd67125de95bb36ce95a47d1919cb3ad444 100644 (file)
     <title>Group Type</title>
     <length>128</length>
     <comment>FK to group type</comment>
+    <pseudoconstant>
+      <optionGroupName>group_type</optionGroupName>
+    </pseudoconstant>
     <add>1.9</add>
   </field>
   <field>