function _webform_civicrm_getCaseContactID in Webform CiviCRM Integration 7.5
Same name and namespace in other branches
- 8.5 webform_civicrm.module \_webform_civicrm_getCaseContactID()
- 7.4 webform_civicrm.module \_webform_civicrm_getCaseContactID()
Gets specified case contact ID or the default contact ID if the case contact ID is not found
Parameters
int $caseID:
Return value
int
1 call to _webform_civicrm_getCaseContactID()
- _webform_civicrm_replaceCaseLinkTokens in ./
webform_civicrm.module - Replaces case-link tokens with civicrm case page links
File
- ./
webform_civicrm.module, line 1017 - Webform CiviCRM Integration Module: Links webform submissions to contacts in a CiviCRM database. @author Coleman Watts
Code
function _webform_civicrm_getCaseContactID($caseID) {
civicrm_initialize();
$caseEntity = civicrm_api3('Case', 'get', [
'return' => [
'contact_id',
],
'id' => $caseID,
]);
$caseContactID = WEBFORM_CIVICRM_DEFAULT_CONTACT_ID;
// Check that contact_id: Is an array, Has at least one value, The first value is not falsey
if (!empty($caseEntity['values'][$caseID]['contact_id']) && is_array($caseEntity['values'][$caseID]['contact_id']) && reset($caseEntity['values'][$caseID]['contact_id'])) {
$caseContactID = reset($caseEntity['values'][$caseID]['contact_id']);
}
return $caseContactID;
}