function wf_crm_get_contact_relationship_types in Webform CiviCRM Integration 7.4
Same name and namespace in other branches
- 7.5 includes/utils.inc \wf_crm_get_contact_relationship_types()
- 7.3 webform_civicrm_utils.inc \wf_crm_get_contact_relationship_types()
Get valid relationship types for a given pair of contacts
Parameters
$type_a: Contact type
$type_b: Contact type
$sub_type_a: Contact sub-type
$sub_type_b: Contact sub-type
Return value
array
2 calls to wf_crm_get_contact_relationship_types()
- wf_crm_field_options in includes/
utils.inc - Get options for a specific field
- _webform_edit_civicrm_contact in includes/
contact_component.inc - Implements _webform_edit_component().
File
- includes/
utils.inc, line 362 - Webform CiviCRM module's common utility functions.
Code
function wf_crm_get_contact_relationship_types($type_a, $type_b, $sub_type_a, $sub_type_b) {
$ret = array();
foreach (wf_crm_get_relationship_types() as $t) {
$reciprocal = $t['label_a_b'] != $t['label_b_a'] && $t['label_b_a'] || $t['type_a'] != $t['type_b'];
if (($t['type_a'] == $type_a || !$t['type_a']) && ($t['type_b'] == $type_b || !$t['type_b']) && (in_array($t['sub_type_a'], $sub_type_a) || !$t['sub_type_a']) && (in_array($t['sub_type_b'], $sub_type_b) || !$t['sub_type_b'])) {
$ret[$t['id'] . ($reciprocal ? '_a' : '_r')] = $t['label_a_b'];
}
// Reciprocal form - only show if different from above
if ($reciprocal && ($t['type_a'] == $type_b || !$t['type_a']) && ($t['type_b'] == $type_a || !$t['type_b']) && (in_array($t['sub_type_a'], $sub_type_b) || !$t['sub_type_a']) && (in_array($t['sub_type_b'], $sub_type_a) || !$t['sub_type_b'])) {
$ret[$t['id'] . '_b'] = $t['label_b_a'];
}
}
return $ret;
}