You are here

function wf_crm_enabled_fields in Webform CiviCRM Integration 7.3

Same name and namespace in other branches
  1. 7.5 includes/utils.inc \wf_crm_enabled_fields()
  2. 7.4 includes/utils.inc \wf_crm_enabled_fields()

Get ids or values of enabled CiviCRM fields for a webform.

Parameters

$node: Node object

$submission: (optional) if supplied, will match field keys with submitted values

$show_all: (optional) if true, get every field even if it belongs to a contact that does not exist

Return value

array of enabled fields

11 calls to wf_crm_enabled_fields()
theme_webform_civicrm_components_form in ./webform_civicrm_admin.inc
Theme override for webform components form.
webform_civicrm_update_7300 in ./webform_civicrm.install
Note: There are differences in how contact references and relationships work in the 3.x branch. Read the upgrade instructions at http://drupal.org/node/1615380
wf_crm_ajax in ./contact_component.inc
Drupal page callback to serve AJAX requests.
wf_crm_configure_form in ./webform_civicrm_admin.inc
Drupal form builder callback Form to configure CiviCRM options for a Webform
wf_crm_configure_form_submit in ./webform_civicrm_admin.inc
Submission handler, saves CiviCRM options for a Webform node

... See full list

File

./webform_civicrm_utils.inc, line 483
Webform CiviCRM module's common utility functions.

Code

function wf_crm_enabled_fields($node, $submission = NULL, $show_all = FALSE) {
  $enabled = array();
  if (!empty($node->webform['components']) && (!empty($node->webform_civicrm) || $show_all)) {
    $fields = wf_crm_get_fields();
    foreach ($node->webform['components'] as $c) {
      $exp = explode('_', $c['form_key'], 5);
      if (count($exp) == 5) {
        list($lobo, $i, $ent, $n, $id) = $exp;
        if ((isset($fields[$id]) || $id == 'fieldset_fieldset') && $lobo == 'civicrm' && is_numeric($i) && is_numeric($n)) {
          if (!$show_all && ($ent == 'contact' || $ent == 'participant') && empty($node->webform_civicrm['data']['contact'][$i])) {
            continue;
          }
          if ($submission) {
            $enabled[$c['form_key']] = wf_crm_aval($submission, $c['cid'], NULL, TRUE);
          }
          else {
            $enabled[$c['form_key']] = $c['cid'];
          }
        }
      }
    }
  }
  return $enabled;
}