Allow for nonnumerical event types in custom groups
authorSeamus Lee <seamuslee001@gmail.com>
Fri, 14 Oct 2016 23:57:26 +0000 (10:57 +1100)
committerSeamus Lee <seamuslee001@gmail.com>
Fri, 14 Oct 2016 23:57:26 +0000 (10:57 +1100)
CRM/Core/BAO/CustomGroup.php
tests/phpunit/CRM/Core/BAO/CustomGroupTest.php

index b2f402218d1901e7569acbca0b254c7f8550638f..c972d7d5d68a5a86c085d9a2cf6137f2b67d5174 100644 (file)
@@ -657,10 +657,13 @@ ORDER BY civicrm_custom_group.weight,
     }
 
     $contactTypes = CRM_Contact_BAO_ContactType::basicTypeInfo(TRUE);
+    $contactTypes = array_merge($contactTypes, array('Event' => 1));
+
     if ($entityType != 'Contact' && !array_key_exists($entityType, $contactTypes)) {
       throw new CRM_Core_Exception('Invalid Entity Filter');
     }
     $subTypes = CRM_Contact_BAO_ContactType::subTypeInfo($entityType, TRUE);
+    $subTypes = array_merge($subTypes, CRM_Event_PseudoConstant::eventType());
     if (!array_key_exists($subType, $subTypes)) {
       throw new CRM_Core_Exception('Invalid Filter');
     }
index 915ecbb01957814b43155be2e8afd6f4089f9772..a85c53cf588c9a5aaef3feb99c514d65f23a6b7c 100644 (file)
@@ -121,7 +121,7 @@ class CRM_Core_BAO_CustomGroupTest extends CiviUnitTestCase {
    */
   public function testGetTreeEventSubTypeAlphabetical() {
     $eventType = $this->callAPISuccess('OptionValue', 'Create', array('option_group_id' => 'event_type', 'value' => 'meeting', 'label' => 'Meeting'));
-    $customGroup = $this->CustomGroupCreate(array('extends' => 'Event', 'extends_entity_column_value' => array('meeting')));
+    $customGroup = $this->CustomGroupCreate(array('extends' => 'Event', 'extends_entity_column_value' => array('Meeting')));
     $customField = $this->customFieldCreate(array('custom_group_id' => $customGroup['id']));
     $result1 = CRM_Core_BAO_CustomGroup::getTree('Event', NULL, NULL, NULL, CRM_Core_DAO::VALUE_SEPARATOR . 'meeting' . CRM_Core_DAO::VALUE_SEPARATOR);
     $this->assertEquals('Custom Field', $result1[$customGroup['id']]['fields'][$customField['id']]['label']);