private function wf_crm_webform_preprocess::loadParticipants 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::loadParticipants()
Load participant data for a contact
Parameters
int $c:
1 call to wf_crm_webform_preprocess::loadParticipants()
- 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 316
Class
Code
private function loadParticipants($c) {
$select = array(
'id',
'event_id',
'role_id',
'status_id',
);
if (array_key_exists('participant_campaign_id', $this->all_fields)) {
$select[] = 'campaign_id';
}
$status_types = wf_crm_apivalues('participant_status_type', 'get');
$dao = CRM_Core_DAO::executeQuery('SELECT ' . implode(',', $select) . '
FROM civicrm_participant
WHERE contact_id = ' . $this->ent['contact'][$c]['id'] . ' AND event_id IN (' . implode(',', array_keys($this->events)) . ")");
while ($dao
->fetch()) {
$par = array();
foreach ($select as $sel) {
$par['participant'][1][$sel] = $dao->{$sel};
}
$par += $this
->getCustomData($dao->id, 'Participant');
$status = $status_types[$dao->status_id];
foreach ($this->events[$dao->event_id]['form'] as $event) {
if ($event['contact'] == $c) {
// If status has been set by admin or exposed to the form, use it as a filter
if (in_array($status['id'], $event['status_id']) || empty($event['status_id']) && $status['class'] != 'Negative') {
$n = $event['contact'];
$i = $event['num'];
// Support multi-valued form elements as best we can
$event_ids = wf_crm_aval($this->info, "participant:{$n}:participant:{$i}:event_id", array());
if ($event['eid']) {
$event_ids[] = $event['eid'];
}
foreach ($par as $k => $v) {
$this->info['participant'][$n][$k][$i] = $v[1];
}
$this->info['participant'][$n]['participant'][$i]['event_id'] = $event_ids;
}
}
}
}
$dao
->free();
}