function _webform_civicrm_replaceCaseIdTokens in Webform CiviCRM Integration 7.4
Same name and namespace in other branches
- 8.5 webform_civicrm.module \_webform_civicrm_replaceCaseIdTokens()
 - 7.5 webform_civicrm.module \_webform_civicrm_replaceCaseIdTokens()
 
Replaces case-id tokens with civicrm case IDs
Parameters
array $tokens: Tokens to process
array $webformSubmissionData: Data submitted by the webform
Return value
array List of replaced case-id tokens replaced with actual case IDs
1 call to _webform_civicrm_replaceCaseIdTokens()
- webform_civicrm_tokens in ./
webform_civicrm.module  - Implements hook_tokens().
 
File
- ./
webform_civicrm.module, line 935  - Webform CiviCRM Integration Module: Links webform submissions to contacts in a CiviCRM database. @author Coleman Watts
 
Code
function _webform_civicrm_replaceCaseIdTokens($tokens, $webformSubmissionData) {
  $replacedTokens = array();
  $tokenValues = token_find_with_prefix($tokens, 'case-id');
  if (!$tokenValues) {
    return $replacedTokens;
  }
  foreach ($tokenValues as $entityID => $tokenName) {
    $tokenNewValue = '';
    if (!empty($webformSubmissionData->civicrm['case'][$entityID]['id'])) {
      $tokenNewValue = $webformSubmissionData->civicrm['case'][$entityID]['id'];
    }
    $replacedTokens[$tokenName] = $tokenNewValue;
  }
  return $replacedTokens;
}