You are here

function _eloqua_cron_remap_post_fields in Eloqua 6

Same name and namespace in other branches
  1. 7 eloqua_webform/eloqua_webform.cron.inc \_eloqua_cron_remap_post_fields()

Remaps the post fields to be used within Eloqua

Parameters

$post_fields array: Data to post

$post array: Post data

Return value

array $post_fields modified to have remapped keys where defined

1 call to _eloqua_cron_remap_post_fields()
_eloqua_cron_get_post_fields in ./eloqua.cron.inc
Returns the post fields for the request, modified for eloqua

File

./eloqua.cron.inc, line 200

Code

function _eloqua_cron_remap_post_fields($post_fields, $post) {
  $result = array();
  $nid = $post->data['form_post']['details']['nid'];
  if (empty($nid) || !is_numeric($nid)) {

    // Something is wrong with this
    return $post_fields;
  }
  $node = new stdClass();
  $node->nid = $nid;
  $webform_additions = webform_node_load($node);
  $components = $webform_additions['webform']['components'];
  $map = array();
  if (is_array($components)) {
    foreach ($components as $component) {
      if (!empty($component['extra']['eloqua']['key']) && $component['extra']['eloqua']['key'] !== $component['form_key']) {
        $map[$component['form_key']] = $component['extra']['eloqua']['key'];
      }
    }
  }
  foreach ($post_fields as $key => $value) {
    if (isset($map[$key])) {
      $result[$map[$key]] = $value;
    }
    else {
      $result[$key] = $value;
    }
  }
  return $result;
}