function _crm_core_relationship_ui_get_contact_from_autocomplete_field_value in CRM Core 8.3
Same name and namespace in other branches
- 8 modules/crm_core_relationship_ui/crm_core_relationship_ui.pages.inc \_crm_core_relationship_ui_get_contact_from_autocomplete_field_value()
- 8.2 modules/crm_core_relationship_ui/crm_core_relationship_ui.pages.inc \_crm_core_relationship_ui_get_contact_from_autocomplete_field_value()
- 7 modules/crm_core_relationship_ui/crm_core_relationship_ui.pages.inc \_crm_core_relationship_ui_get_contact_from_autocomplete_field_value()
Extract contact id from the value of autocomplete contact field.
Parameters
$string: String that is processed.
2 calls to _crm_core_relationship_ui_get_contact_from_autocomplete_field_value()
- crm_core_relationship_ui_add_relationship_form_submit in modules/
crm_core_relationship_ui/ crm_core_relationship_ui.pages.inc - Perform submit for add relationship form. Save relationship.
- 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_ui/ crm_core_relationship_ui.pages.inc, line 419 - CRM Core Relationship UI Pages.
Code
function _crm_core_relationship_ui_get_contact_from_autocomplete_field_value($string) {
$matches = [];
preg_match('/\\[cid:([0-9]+)\\]/', $string, $matches);
if (!array_key_exists(1, $matches) || !is_numeric($matches[1])) {
return FALSE;
}
$contacts = entity_load('crm_core_contact', [
$matches[1],
]);
if (empty($contacts)) {
return FALSE;
}
return $contacts[$matches[1]];
}