From: Seamus Lee Date: Fri, 14 Oct 2016 23:57:26 +0000 (+1100) Subject: Allow for nonnumerical event types in custom groups X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=2072f97dbc56fdd29db295f44a8163c4b0fc729c;p=civicrm-core.git Allow for nonnumerical event types in custom groups --- diff --git a/CRM/Core/BAO/CustomGroup.php b/CRM/Core/BAO/CustomGroup.php index b2f402218d..c972d7d5d6 100644 --- a/CRM/Core/BAO/CustomGroup.php +++ b/CRM/Core/BAO/CustomGroup.php @@ -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'); } diff --git a/tests/phpunit/CRM/Core/BAO/CustomGroupTest.php b/tests/phpunit/CRM/Core/BAO/CustomGroupTest.php index 915ecbb019..a85c53cf58 100644 --- a/tests/phpunit/CRM/Core/BAO/CustomGroupTest.php +++ b/tests/phpunit/CRM/Core/BAO/CustomGroupTest.php @@ -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']);