function webform_civicrm_get_contact_types in Webform CiviCRM Integration 6.2
Same name and namespace in other branches
- 7.2 webform_civicrm_utils.inc \webform_civicrm_get_contact_types()
Get contact types and sub-types
4 calls to webform_civicrm_get_contact_types()
- webform_civicrm_configure_form_builder in ./
webform_civicrm_admin.inc - Form to configure CiviCRM options for a Webform Called indirectly from hook_menu() for D7-D6 compatibility
- webform_civicrm_configure_form_submit in ./
webform_civicrm_admin.inc - Submission handler, saves CiviCRM options for a Webform node
- webform_civicrm_field_options in ./
webform_civicrm_utils.inc - Get options for a specific field @Param $field: Webform component array @Param $context: Where is this being called from? @Param $data: CiviCRM entity data
- webform_civicrm_process_form_settings in ./
webform_civicrm_admin.inc - Build the $data array for webform settings; called while rebuilding or post-processing the configure form.
File
- ./
webform_civicrm_utils.inc, line 224 - Webform CiviCRM module's common utility functions. The code in this file is cross-compatible with D6/Civi3 and D7/Civi4 Drupal-version-specific functions belong in webform_civicrm_dx_functions.inc
Code
function webform_civicrm_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();
}
}
}
return array(
$contact_types,
$sub_types,
);
}