private function wf_crm_webform_preprocess::findExistingGrants 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::findExistingGrants()
Find grant ids based on url input or "existing grant" settings
1 call to wf_crm_webform_preprocess::findExistingGrants()
- 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 745
Class
Code
private function findExistingGrants() {
for ($n = 1; $n <= $this->data['grant']['number_of_grant']; ++$n) {
if (!empty($this->data['grant'][$n]['grant'][1]['contact_id'])) {
$cid = $this->ent['contact'][$this->data['grant'][$n]['grant'][1]['contact_id']]['id'];
if ($cid) {
if (isset($_GET["grant{$n}"]) && wf_crm_is_positive($_GET["grant{$n}"])) {
$id = $_GET["grant{$n}"];
$item = wf_civicrm_api('grant', 'getsingle', array(
'id' => $id,
));
if ($cid == $item['contact_id']) {
$this->ent['grant'][$n] = array(
'id' => $id,
);
}
}
elseif (!empty($this->data['grant'][$n]['existing_grant_status'])) {
$params = array(
'sequential' => 1,
'contact_id' => $cid,
'status_id' => array(
'IN' => (array) $this->data['grant'][$n]['existing_grant_status'],
),
'options' => array(
'limit' => 1,
),
);
if (!empty($this->data['grant'][$n]['grant'][1]['grant_type_id'])) {
$params['grant_type_id'] = $this->data['grant'][$n]['grant'][1]['grant_type_id'];
}
$items = wf_crm_apivalues('grant', 'get', $params);
if (isset($items[0]['id'])) {
$this->ent['grant'][$n] = array(
'id' => $items[0]['id'],
);
}
}
}
}
}
}