private function wf_crm_webform_preprocess::populateExistingEntity in Webform CiviCRM Integration 7.4
Same name and namespace in other branches
- 7.5 includes/wf_crm_webform_preprocess.inc \wf_crm_webform_preprocess::populateExistingEntity()
Populate existing entity data
Parameters
string $type entity type (activity, case, grant):
1 call to wf_crm_webform_preprocess::populateExistingEntity()
- wf_crm_webform_preprocess::alterForm in includes/
wf_crm_webform_preprocess.inc - Alter front-end of webforms: Called by hook_form_alter() when rendering a civicrm-enabled webform Add custom prefix. Display messages. Block users who should not have access. Set webform default values.
File
- includes/
wf_crm_webform_preprocess.inc, line 781
Class
Code
private function populateExistingEntity($type) {
$items = array();
foreach ($this->ent[$type] as $key => $item) {
if (!empty($item['id'])) {
$items[$key] = $item['id'];
}
}
if ($items) {
// Todo: Remove when we drop support for 4.4 - https://www.drupal.org/node/2832331
if (version_compare($this->civicrm_version, '4.6.0', '<')) {
$values = array();
foreach ($items as $id) {
$value = wf_crm_apivalues($type, 'get', array(
'id' => $id,
));
$values[$id] = $value[$id];
}
}
else {
$values = wf_crm_apivalues($type, 'get', array(
'id' => array(
'IN' => array_values($items),
),
));
}
foreach ($items as $n => $id) {
if (isset($values[$id])) {
// Load core + custom data
$this->info[$type][$n] = array(
$type => array(
1 => $values[$id],
),
) + $this
->getCustomData($id, $type);
// Load file attachments
if (!empty($this->all_sets["{$type}upload"])) {
foreach ($this
->getAttachments($type, $id) as $f => $file) {
$this->info[$type][$n]["{$type}upload"][1]["file_{$f}"] = $file['file_id'];
}
}
}
}
}
}