function wf_crm_get_contact_types in Webform CiviCRM Integration 7.3
Same name and namespace in other branches
- 7.5 includes/utils.inc \wf_crm_get_contact_types()
- 7.4 includes/utils.inc \wf_crm_get_contact_types()
Get contact types and sub-types
Return value
array
5 calls to wf_crm_get_contact_types()
- wf_crm_component_insert in ./
webform_civicrm_admin.inc - Add a CiviCRM field to a webform
- wf_crm_configure_form in ./
webform_civicrm_admin.inc - Drupal form builder callback Form to configure CiviCRM options for a Webform
- wf_crm_field_options in ./
webform_civicrm_utils.inc - Get options for a specific field
- wf_crm_process_form_settings in ./
webform_civicrm_admin.inc - Build the $data array for webform settings; called while rebuilding or post-processing the configure form.
- _webform_edit_civicrm_contact in ./
contact_component.inc - Implements _webform_edit_component().
File
- ./
webform_civicrm_utils.inc, line 273 - Webform CiviCRM module's common utility functions.
Code
function wf_crm_get_contact_types() {
static $contact_types = array();
static $sub_types = array();
if (!$contact_types) {
$sql = '
SELECT c1.name, c1.label, LOWER(c2.name) AS parent_type
FROM civicrm_contact_type c1
LEFT JOIN civicrm_contact_type c2 ON c1.parent_id = c2.id
WHERE c1.is_active = 1
ORDER BY c1.parent_id ASC';
$dao =& CRM_Core_DAO::executeQuery($sql);
while ($dao
->fetch()) {
if ($dao->parent_type) {
$sub_types[$dao->parent_type][$dao->name] = $dao->label;
}
else {
$contact_types[strtolower($dao->name)] = $dao->label;
$sub_types[strtolower($dao->name)] = array();
}
}
$dao
->free();
}
return array(
$contact_types,
$sub_types,
);
}