function wf_crm_webform_preprocess::findCaseClientForDefaultContact in Webform CiviCRM Integration 7.4
Function to load default contact (cid1) if default loading is set to case_roles
File
- includes/
wf_crm_webform_preprocess.inc, line 628
Class
Code
function findCaseClientForDefaultContact($c) {
// Support legacy url param
if (empty($_GET["case1"]) && !empty($_GET["caseid"])) {
$_GET["case1"] = $_GET["caseid"];
}
for ($n = 1; $n <= $this->data['case']['number_of_case']; ++$n) {
if (isset($_GET["case{$n}"]) && wf_crm_is_positive($_GET["case{$n}"])) {
$id = $_GET["case{$n}"];
$item = wf_civicrm_api('case', 'getsingle', array(
'id' => $id,
));
$clients = (array) wf_crm_aval($item, 'client_id');
if (count($clients) > 0) {
$caseClient = reset($clients);
$this->ent['contact'][$c]['id'] = $caseClient;
return;
}
}
}
}