* @return array
* Array of basic contact types information.
*/
- public static function &basicTypeInfo($all = FALSE) {
+ public static function basicTypeInfo($all = FALSE) {
static $_cache = NULL;
if ($_cache === NULL) {
* @return array
* Array of sub type information
*/
- public static function &subTypeInfo($contactType = NULL, $all = FALSE, $ignoreCache = FALSE, $reset = FALSE) {
+ public static function subTypeInfo($contactType = NULL, $all = FALSE, $ignoreCache = FALSE, $reset = FALSE) {
static $_cache = NULL;
if ($reset === TRUE) {
if (is_numeric($subType)) {
return $subType;
}
- $contactTypes = civicrm_api3('Contact', 'getoptions', array('field' => 'contact_type'));
- if ($entityType != 'Contact' && !array_key_exists($entityType, $contactTypes['values'])) {
- // Not quite sure if we want to fail this hard. But quiet ignore would be pretty bad too.
- // Am inclined to go with this for RC release & considering softening.
+
+ $contactTypes = CRM_Contact_BAO_ContactType::basicTypeInfo(TRUE);
+ if ($entityType != 'Contact' && !array_key_exists($entityType, $contactTypes)) {
throw new CRM_Core_Exception('Invalid Entity Filter');
}
- $subTypes = civicrm_api3('Contact', 'getoptions', array('field' => 'contact_sub_type'));
- if (!isset($subTypes['values'][$subType])) {
- // Same comments about fail hard as above.
+ $subTypes = CRM_Contact_BAO_ContactType::subTypeInfo($entityType, TRUE);
+ if (!array_key_exists($subType, $subTypes)) {
throw new CRM_Core_Exception('Invalid Filter');
}
return $subType;
$this->callAPISuccess('ContactType', 'delete', array('id' => $contactType['id']));
}
+ /**
+ * Test calling getTree for a custom field extending a disabled contact type.
+ */
+ public function testGetTreeContactSubTypeForDisabledChangedContactType() {
+ $contactType = $this->callAPISuccess('ContactType', 'create', array('name' => 'Big Bank', 'label' => 'biggee', 'parent_id' => 'Organization'));
+ $customGroup = $this->CustomGroupCreate(array('extends' => 'Organization', 'extends_entity_column_value' => array('Big_Bank')));
+ $customField = $this->customFieldCreate(array('custom_group_id' => $customGroup['id']));
+ $this->callAPISuccess('ContactType', 'create', array('id' => $contactType['id'], 'is_active' => 0));
+ $result1 = CRM_Core_BAO_CustomGroup::getTree('Organization', NULL, NULL, NULL, array('Big_Bank'));
+ $this->assertEquals('Custom Field', $result1[$customGroup['id']]['fields'][$customField['id']]['label']);
+ $this->customGroupDelete($customGroup['id']);
+ $this->callAPISuccess('ContactType', 'delete', array('id' => $contactType['id']));
+ }
+
/**
* Test calling getTree with contact subtype data.
*