function crm_core_relationship_load_contact_types in CRM Core 8.2
Same name and namespace in other branches
- 8.3 modules/crm_core_relationship/crm_core_relationship.module \crm_core_relationship_load_contact_types()
- 8 modules/crm_core_relationship/crm_core_relationship.module \crm_core_relationship_load_contact_types()
- 7 modules/crm_core_relationship/crm_core_relationship.module \crm_core_relationship_load_contact_types()
Return contact types available for specific relationship type.
Parameters
$relation_type: Relation type object.
$reverse: Whether relationship is reversed.
3 calls to crm_core_relationship_load_contact_types()
- crm_core_relationship_form in modules/
crm_core_relationship_ui/ crm_core_relationship_ui.pages.inc - Form builder for CRM Activity forms.
- crm_core_relationship_ui_add_relationship_autocomplete in modules/
crm_core_relationship_ui/ crm_core_relationship_ui.pages.inc - Autocomplete function for add relationship form. Lookup for contacts.
- crm_core_relationship_ui_add_relationship_form_validate in modules/
crm_core_relationship_ui/ crm_core_relationship_ui.pages.inc - Perform validation for add relationship form.
File
- modules/
crm_core_relationship/ crm_core_relationship.module, line 138 - CRM Core Relationship, handles relationship logic and API.
Code
function crm_core_relationship_load_contact_types($relation_type, $reverse = 0) {
// Check if it is a relationship type
if (!crm_core_relationship_is_relationship_type($relation_type->relation_type)) {
return array();
}
$contact_types = ContactType::loadMultiple();
$bundles = $relation_type->directional && $reverse ? $relation_type->target_bundles : $relation_type->source_bundles;
if (in_array('crm_core_contact:*', $bundles)) {
return $contact_types;
}
$available_contact_types = array();
foreach ($bundles as $bundle) {
list($entity, $type) = explode(':', $bundle);
$available_contact_types[$type] = $contact_types[$type];
}
return $available_contact_types;
}