diff --git a/README.txt b/README.txt index ca839b5..25a0215 100644 --- a/README.txt +++ b/README.txt @@ -5,57 +5,32 @@ a subscription with eloqua.com at this point, please go to eloqua.com and review purchasing options if you wish to continue using this module. This module will allow you to create webforms and link them to your existing -eloqua forms. At present, this module requires you to still set up the form -in both eloqua (using their form builder) and in Drupal (using webform). This +Eloqua forms. At present, this module requires you to still set up the form +in both Eloqua (using their form builder) and in Drupal (using webform). This may change at a later date, but will at least provide a more Drupal-esque way -to create forms for use with eloqua. +to create forms for use with Eloqua. Requirements: ------------- -Webform module (6.x-3.x) must installed and enabled. - -You will also need to have generated and downloaded the tracking scripts from -eloqua for this module to behave as expected. - -The quick version of generating the scripts is: -1. Go to Automate > Web Profiling and click on the Web Integration tab -2. Expand Visitor Tracking Scripts and click Generata Vistor Tracking Scripts -3. Generate the scripts and download them. - -For additional information and a step by step walkthrough, view eloqua's support -for information on how to generate and download those scripts: -https://support.eloqua.com/View.jsp?procId=8a7e8d4c2003c998012038a33936546d - -Installation: -------------- -Assuming you have generated and downloaded the eloqua tracking scripts as -outlined in "Requirements", copy the "elqNow" directory into -sites/all/libraries. Once you have done this, the elqCfg.js, for instance, -should reside at sites/all/libraries/elqNow/elqCfg.js. If that is not the case, -this module will not integrate with eloqua as expected. - -Move the contents of the eloqua/elqNow folder to reside in the above library directory. -In total, the three files this script requires are - elqScr.js - elqImg.js - elqCfg.js +Webform module must installed and enabled. Use: ---- Form: -When creating a webform, a new checkbox should exist on the node add page -allowing you to make the particular webform node Eloqua enabled. After checking -the box, there is an "Eloqua Form Name" field that should map exactly to the -form name on Eloqua. +When creating a webform, a new checkbox should exist on the webform tab form +settings allowing you to make the particular webform node Eloqua enabled. After +checking the box, there is an "Eloqua Form Name" field that should map exactly +to the form name on Eloqua. + Fields: -After you have created the webform and made it eloqua enabled, when creating new +After you have created the webform and made it Eloqua enabled, when creating new form components (fields), a new field exists for identifying the Eloqua name of that field ("Eloqua Field Name"). An example of use: your form might have a First Name field. When you create the textfield for First Name, Drupal assigns it the name of first_name (webform only allows lowercase alphanumeric + underscores), but your field in Eloqua might be First-Name. Drupal/Webform will have first_name as the "Field Key", but you can set the "Eloqua Form Name" to -First-Name so that, when submitted to eloqua, this field maps over exactly as +First-Name so that, when submitted to Eloqua, this field maps over exactly as expected URL Parameters @@ -64,7 +39,7 @@ Using URL Parameters instead of relying on Token values for the default value provide a better experience when dealing with compound values that cannot be expressed simply. -This functionality can be extended by implementnig the function +This functionality can be extended by implementing the function _eloqua_form_url_map_{type}($value, &$element) where type is the webform component type. diff --git a/eloqua.admin.inc b/eloqua.admin.inc index b8159cf..d949348 100644 --- a/eloqua.admin.inc +++ b/eloqua.admin.inc @@ -6,13 +6,12 @@ * @return array * A form array. */ -function eloqua_admin_form () { +function eloqua_admin_form() { $form = array(); $form['general'] = array( '#type' => 'fieldset', '#title' => t('General Settings'), '#description' => t('General settings applicable to all Eloqua functionality.'), - // Site id. ELOQUA_VARIABLE_SITE_ID => array( '#type' => 'textfield', @@ -23,18 +22,6 @@ function eloqua_admin_form () { '#default_value' => eloqua_get_site_id(), '#required' => TRUE, ), - - // Scripts directory. - ELOQUA_VARIABLE_SCRIPTS_DIRECTORY => array( - '#type' => 'textfield', - '#title' => t('Scripts Directory'), - '#description' => t('The directory where the Eloqua scripts will be located.'), - '#size' => 20, - '#maxlength' => 64, - '#default_value' => eloqua_get_scripts_directory(), - '#required' => TRUE, - ), - ELOQUA_SETTINGS_BATCH_SIZE => array( '#type' => 'textfield', '#title' => t('Batch Size'), diff --git a/eloqua.cron.inc b/eloqua.cron.inc index a6e5daf..e7efb79 100644 --- a/eloqua.cron.inc +++ b/eloqua.cron.inc @@ -1,4 +1,5 @@ data['user_headers']; $headers = array( - 'Accept-Language' => array_key_exists('accept-language', $original_headers) - ? $original_headers['accept-language'] : 'en', + 'Accept-Language' => array_key_exists('accept-language', $original_headers) ? $original_headers['accept-language'] : 'en', ); // Fetch the post fields to send to Eloqua @@ -111,12 +110,11 @@ function _eloqua_cron() { } } - /** * Returns a configured Curl Resource for use * @return resource */ -function _eloqua_cron_get_curl_resource($options = array()){ +function _eloqua_cron_get_curl_resource($options = array()) { $ch = _eloqua_cron_get_curl_handle(); if ($ch == NULL) { return NULL; @@ -128,7 +126,7 @@ function _eloqua_cron_get_curl_resource($options = array()){ CURLOPT_POST => 1, CURLOPT_RETURNTRANSFER => 1, CURLOPT_CONNECTTIMEOUT => 5, // TODO: TIMEOUT ADMIN SETTING - CURLOPT_TIMEOUT => 5, // TODO: TIMEOUT ADMIN SETTING + CURLOPT_TIMEOUT => 5, // TODO: TIMEOUT ADMIN SETTING CURLOPT_URL => 'http://now.eloqua.com/e/f2.aspx', ); @@ -137,7 +135,7 @@ function _eloqua_cron_get_curl_resource($options = array()){ 'user_agent' => CURLOPT_USERAGENT, 'http_headers' => CURLOPT_HTTPHEADER, ); - foreach($option_map as $key => $curl_key) { + foreach ($option_map as $key => $curl_key) { if (array_key_exists($key, $options)) { $curl_opts[$curl_key] = $options[$key]; } @@ -151,14 +149,13 @@ function _eloqua_cron_get_curl_resource($options = array()){ $params = array( '!options' => '
' . $error_msg . '
', ); - watchdog ('eloqua', $message, $params, WATCHDOG_ERROR); + watchdog('eloqua', $message, $params, WATCHDOG_ERROR); curl_close($ch); $ch = NULL; } return $ch; } - /** * Handle translating our post values into what eloqua wants in terms of structure. * @@ -187,7 +184,6 @@ function _eloqua_get_submission_data($tree, $posted_values, &$result) { } } - /** * Remaps the post fields to be used within Eloqua * @param $post_fields array @@ -211,7 +207,7 @@ function _eloqua_cron_remap_post_fields($post_fields, $post) { 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']; + $map[$component['form_key']] = $component['extra']['eloqua']['key']; } } } @@ -227,7 +223,6 @@ function _eloqua_cron_remap_post_fields($post_fields, $post) { return $result; } - /** * Returns the cURL error for a status returned from eloqua_curl_set_opts * @TODO: Theme @@ -254,7 +249,6 @@ function _eloqua_set_curl_get_error($status) { return $message; } - /** * Sets curl options en mass, checking for errors * @param $ch resource @@ -285,7 +279,6 @@ function _eloqua_set_curl_opts(&$ch, $options = array()) { return $result; } - /** * Returns the post fields for the request, modified for eloqua * @param $post @@ -293,9 +286,7 @@ function _eloqua_set_curl_opts(&$ch, $options = array()) { */ function _eloqua_cron_get_post_fields($post) { // TODO: Review newest webform for exact behaviour on whether submitted_tree exists. - $form_data = !empty($post->data['form_post']['submitted_tree']) - ? $post->data['form_post']['submitted_tree'] - : $post->data['form_post']['submitted']; + $form_data = !empty($post->data['form_post']['submitted_tree']) ? $post->data['form_post']['submitted_tree'] : $post->data['form_post']['submitted']; $post_fields = array(); // Merge any elq values into the post to be submitted diff --git a/eloqua.inc b/eloqua.inc index 2e6b2c1..bc60e13 100644 --- a/eloqua.inc +++ b/eloqua.inc @@ -1,6 +1,5 @@ '
' . var_export ($value, TRUE) . '
', + '!value' => '
' . var_export($value, TRUE) . '
', ); watchdog(ELOQUA_WATCHDOG_CATEGORY, $message, $variables, WATCHDOG_NOTICE); return FALSE; @@ -120,7 +105,6 @@ function eloqua_set_last_post_time($value) { return TRUE; } - /** * Returns the Eloqua Site ID * @return int @@ -130,17 +114,15 @@ function eloqua_get_site_id() { return $site_id; } - /** * Gets the update interval * @return int * Seconds */ -function eloqua_get_update_time_interval () { +function eloqua_get_update_time_interval() { return variable_get(ELOQUA_VARIABLE_POST_INTERVAL, ELOQUA_VARIABLE_POST_INTERVAL_DEFAULT); } - /** * Sets the update interval * @param $seconds int @@ -148,13 +130,13 @@ function eloqua_get_update_time_interval () { * @return boolean * Successful Update */ -function eloqua_set_update_time_interval ($seconds) { +function eloqua_set_update_time_interval($seconds) { if (!is_numeric($seconds) - || $seconds < 0) { + || $seconds < 0) { $message = t('!method: Invalid value set for post time: !value'); $variables = array( '!method' => __METHOD__, - '!value' => '
' . var_export ($seconds, TRUE) . '
', + '!value' => '
' . var_export($seconds, TRUE) . '
', ); watchdog(ELOQUA_WATCHDOG_CATEGORY, $message, $variables, WATCHDOG_NOTICE); return FALSE; @@ -167,19 +149,17 @@ function eloqua_set_update_time_interval ($seconds) { //////////////////////////////////////////////////////////////////////////////// // Webform Setting Database Access Functions - /** * Loads a webform settings from the database * @hook eloqua_form_load ($webform) * @param $nid int * @return object */ -function eloqua_webform_load ($nid) { +function eloqua_webform_load($nid) { // Get the raw result from the db if (!is_numeric($nid)) { $type = gettype($nid); - watchdog(ELOQUA_WATCHDOG_CATEGORY, t('Invalid argument sent to !module_name (!type).', - array('!module_name' => __FUNCTION__, '!type' => $type)), array(), WATCHDOG_DEBUG); + watchdog(ELOQUA_WATCHDOG_CATEGORY, t('Invalid argument sent to !module_name (!type).', array('!module_name' => __FUNCTION__, '!type' => $type)), array(), WATCHDOG_DEBUG); return NULL; } @@ -197,18 +177,16 @@ function eloqua_webform_load ($nid) { return $webform; } - /** * Creates a webform settings from the database * @hook eloqua_form_create * @param $webform object * @return boolean */ -function eloqua_webform_create ($webform) { +function eloqua_webform_create($webform) { if (!is_object($webform)) { $type = gettype($webform); - watchdog(ELOQUA_WATCHDOG_CATEGORY, t('Invalid argument sent to !module_name (!type).', - array('!module_name' => __FUNCTION__, '!type' => $type))); + watchdog(ELOQUA_WATCHDOG_CATEGORY, t('Invalid argument sent to !module_name (!type).', array('!module_name' => __FUNCTION__, '!type' => $type))); return FALSE; } @@ -227,18 +205,16 @@ function eloqua_webform_create ($webform) { return $result; } - /** * Updates a webform settings from the database * @hook eloqua_form_update * @param $webform object * @return boolean */ -function eloqua_webform_update ($webform) { +function eloqua_webform_update($webform) { if (!is_object($webform)) { $type = gettype($webform); - watchdog(ELOQUA_WATCHDOG_CATEGORY, t('Invalid argument sent to !module_name (!type).', - array('!module_name' => __FUNCTION__, '!type' => $type)), array(), WATCHDOG_DEBUG); + watchdog(ELOQUA_WATCHDOG_CATEGORY, t('Invalid argument sent to !module_name (!type).', array('!module_name' => __FUNCTION__, '!type' => $type)), array(), WATCHDOG_DEBUG); return FALSE; } @@ -257,17 +233,15 @@ function eloqua_webform_update ($webform) { return $result; } - /** * Deletes a webform settings object from the database * @param $nid integer * @return boolean */ -function eloqua_webform_delete ($nid) { - if (!is_numeric($nid)) { +function eloqua_webform_delete($nid) { + if (!is_numeric($nid)) { $type = gettype($nid); - watchdog(ELOQUA_WATCHDOG_CATEGORY, t('Invalid argument sent to !module_name (!type).', - array('!module_name' => __FUNCTION__, '!type' => $type)), array(), WATCHDOG_DEBUG); + watchdog(ELOQUA_WATCHDOG_CATEGORY, t('Invalid argument sent to !module_name (!type).', array('!module_name' => __FUNCTION__, '!type' => $type)), array(), WATCHDOG_DEBUG); return FALSE; } @@ -285,13 +259,12 @@ function eloqua_webform_delete ($nid) { return $result; } - /** * Loads the webform object from the database * @param $nid int * @return object */ -function _eloqua_webform_load ($nid) { +function _eloqua_webform_load($nid) { $result = db_select(ELOQUA_SCHEMA_WEBFORM) ->fields(ELOQUA_SCHEMA_WEBFORM) ->condition(ELOQUA_WEBFORM_FIELD_NODE_ID, $nid) @@ -302,14 +275,12 @@ function _eloqua_webform_load ($nid) { return $result; } - - /** * Creates the webform object from the database * @param $webform * @return boolean */ -function _eloqua_webform_create ($webform) { +function _eloqua_webform_create($webform) { $index = array( ELOQUA_WEBFORM_FIELD_NODE_ID => $webform->{ELOQUA_WEBFORM_FIELD_NODE_ID}, ); @@ -323,13 +294,12 @@ function _eloqua_webform_create ($webform) { return $result; } - /** * Updates the webform object from the database * @param $webform object * @return boolean */ -function _eloqua_webform_update ($webform) { +function _eloqua_webform_update($webform) { $fields = array( ELOQUA_WEBFORM_FIELD_FORM_NAME => $webform->{ELOQUA_WEBFORM_FIELD_FORM_NAME}, ELOQUA_WEBFORM_FIELD_ACTIVE => $webform->{ELOQUA_WEBFORM_FIELD_ACTIVE}, @@ -344,13 +314,12 @@ function _eloqua_webform_update ($webform) { return $result; } - /** * Deletes a webform object from the database * @param $nid int * @return boolean */ -function _eloqua_webform_delete ($nid) { +function _eloqua_webform_delete($nid) { $result = db_delete(ELOQUA_SCHEMA_WEBFORM) ->condition(ELOQUA_WEBFORM_FIELD_NODE_ID, $nid) ->execute(); @@ -358,18 +327,6 @@ function _eloqua_webform_delete ($nid) { return $result; } - - -/** - * Returns the defined scripts directory - * @return int - */ -function eloqua_get_scripts_directory() { - $value = variable_get(ELOQUA_VARIABLE_SCRIPTS_DIRECTORY, ELOQUA_VARIABLE_SCRIPTS_DIRECTORY_DEFAULT); - return $value; -} - - /** * Returns the cron processing batch size * @return int @@ -379,12 +336,11 @@ function eloqua_get_batch_size() { return $batch_size; } - //////////////////////////////////////////////////////////////////////////////// // Completed Post Handling -function eloqua_post_get_batch () { +function eloqua_post_get_batch() { $result_set = db_select(ELOQUA_SCHEMA_SAVED_POSTS) ->fields(ELOQUA_SCHEMA_SAVED_POSTS) ->condition(ELOQUA_POST_FIELD_STATUS, ELOQUA_STATUS_NEW) @@ -401,12 +357,11 @@ function eloqua_post_get_batch () { * @param $post_id int * @return object */ -function eloqua_post_load ($post_id) { +function eloqua_post_load($post_id) { // Get the raw result from the db if (!is_numeric($post_id)) { $type = gettype($post_id); - watchdog(ELOQUA_WATCHDOG_CATEGORY, t('Invalid argument sent to !module_name (!type).', - array('!module_name' => __FUNCTION__, '!type' => $type)), array(), WATCHDOG_DEBUG); + watchdog(ELOQUA_WATCHDOG_CATEGORY, t('Invalid argument sent to !module_name (!type).', array('!module_name' => __FUNCTION__, '!type' => $type)), array(), WATCHDOG_DEBUG); return NULL; } @@ -424,7 +379,6 @@ function eloqua_post_load ($post_id) { return $post; } - /** * Creates a post into the database * @hook eloqua_post_create @@ -432,11 +386,10 @@ function eloqua_post_load ($post_id) { * @return int * Post ID */ -function eloqua_post_create ($post) { +function eloqua_post_create($post) { if (!is_object($post)) { $type = gettype($post); - watchdog(ELOQUA_WATCHDOG_CATEGORY, t('Invalid argument sent to !module_name (!type).', - array('!module_name' => __FUNCTION__, '!type' => $type))); + watchdog(ELOQUA_WATCHDOG_CATEGORY, t('Invalid argument sent to !module_name (!type).', array('!module_name' => __FUNCTION__, '!type' => $type))); return FALSE; } @@ -457,18 +410,16 @@ function eloqua_post_create ($post) { return $result; } - /** * Updates a post from the database * @hook eloqua_post_update * @param $post object * @return boolean */ -function eloqua_post_update ($post) { +function eloqua_post_update($post) { if (!is_object($post)) { $type = gettype($post); - watchdog(ELOQUA_WATCHDOG_CATEGORY, t('Invalid argument sent to !module_name (!type).', - array('!module_name' => __FUNCTION__, '!type' => $type)), array(), WATCHDOG_DEBUG); + watchdog(ELOQUA_WATCHDOG_CATEGORY, t('Invalid argument sent to !module_name (!type).', array('!module_name' => __FUNCTION__, '!type' => $type)), array(), WATCHDOG_DEBUG); return FALSE; } @@ -487,17 +438,15 @@ function eloqua_post_update ($post) { return $result; } - /** * Deletes a post object from the database * @param $post_id integer * @return boolean */ -function eloqua_post_delete ($post_id) { - if (!is_numeric($post_id)) { +function eloqua_post_delete($post_id) { + if (!is_numeric($post_id)) { $type = gettype($post_id); - watchdog(ELOQUA_WATCHDOG_CATEGORY, t('Invalid argument sent to !module_name (!type).', - array('!module_name' => __FUNCTION__, '!type' => $type)), array(), WATCHDOG_DEBUG); + watchdog(ELOQUA_WATCHDOG_CATEGORY, t('Invalid argument sent to !module_name (!type).', array('!module_name' => __FUNCTION__, '!type' => $type)), array(), WATCHDOG_DEBUG); return FALSE; } @@ -515,13 +464,12 @@ function eloqua_post_delete ($post_id) { return $result; } - /** * Loads the post object from the database * @param $post_id int * @return object */ -function _eloqua_post_load ($post_id) { +function _eloqua_post_load($post_id) { $result_set = db_select(ELOQUA_SCHEMA_SAVED_POSTS) ->condition(ELOQUA_POST_FIELD_POST_ID, $post_id) ->execute() @@ -531,14 +479,13 @@ function _eloqua_post_load ($post_id) { return $result; } - /** * Creates the post object from the database * @param $post * @return int * Newly created Post_id */ -function _eloqua_post_create ($post) { +function _eloqua_post_create($post) { $fields = array( ELOQUA_POST_FIELD_FORM_ID => $post->{ELOQUA_POST_FIELD_FORM_ID}, ELOQUA_POST_FIELD_POST_TIME => $post->{ELOQUA_POST_FIELD_POST_TIME}, @@ -556,13 +503,12 @@ function _eloqua_post_create ($post) { return $result; } - /** * Updates the post object from the database * @param $post object * @return boolean */ -function _eloqua_post_update ($post) { +function _eloqua_post_update($post) { $fields = array( ELOQUA_POST_FIELD_FORM_ID => $post->{ELOQUA_POST_FIELD_FORM_ID}, ELOQUA_POST_FIELD_POST_TIME => $post->{ELOQUA_POST_FIELD_POST_TIME}, @@ -577,13 +523,12 @@ function _eloqua_post_update ($post) { return $result; } - /** * Deletes a post object from the database * @param $post_id int * @return boolean */ -function _eloqua_post_delete ($post_id) { +function _eloqua_post_delete($post_id) { $result = db_delete(ELOQUA_SCHEMA_SAVED_POSTS) ->condition(ELOQUA_POST_FIELD_POST_ID, $post_id) ->execute(); @@ -591,7 +536,6 @@ function _eloqua_post_delete ($post_id) { return $result; } - /** * Goes through the result set and unserialises any 'data' columns * @param $result_set @@ -611,7 +555,6 @@ function _eloqua_unserialize_data_column($result_set) { return $result; } - /** * Query the Database and mimic a INSERT ... ON DUPLICATE KEY UPDATE * @@ -654,16 +597,14 @@ function _eloqua_db_insert_update($index, $fields) { try { $result = $query->execute(); - } - catch (PDOException $e) { + } catch (PDOException $e) { return FALSE; } // Rows Updated if (is_numeric($result)) { $result = (bool) $result; - } - else { + } else { // Probably failed. $result = FALSE; } diff --git a/eloqua.info b/eloqua.info index be4fc28..fd0a461 100644 --- a/eloqua.info +++ b/eloqua.info @@ -1,5 +1,5 @@ name = Eloqua Integration -description = Module to allow eloqua integration for drupal websites +description = Module to allow Eloqua integration for Drupal websites package = "Eloqua" core = 7.x diff --git a/eloqua.install b/eloqua.install index 5bea674..ec183a2 100644 --- a/eloqua.install +++ b/eloqua.install @@ -1,7 +1,8 @@ t('Webform Settings'), @@ -45,7 +46,6 @@ function eloqua_schema () { 'not null' => TRUE, 'default' => 0, ), - ELOQUA_POST_FIELD_DATA => array( // Form Contents 'description' => 'Extra data to be stored with the field', @@ -91,7 +91,7 @@ function eloqua_schema () { 'default' => 0, 'unsigned' => TRUE, ), - ELOQUA_WEBFORM_FIELD_DATA => array( + ELOQUA_WEBFORM_FIELD_DATA => array( 'description' => 'Extra data to be stored with the field', 'type' => 'text', 'size' => 'normal', /* 16KB in mySql */ @@ -102,15 +102,27 @@ function eloqua_schema () { return $schema; } - /** * Implementation of hook_install(). */ function eloqua_install() { + } /** * Implementation of hook_uninstall(). */ function eloqua_uninstall() { + } + +/** + * Remove variable eloqua_scripts_directory used to indicate the path to the + * Eloqua JavaScript library. This library is no longer required with this + * module. + */ +function eloqua_install_update_7000(&$sandbox) { + drupal_set_message('You may remove the elqNow library from your sites folder. Libraries are no longer required to use this module.'); + + variable_del('eloqua_scripts_directory'); +} \ No newline at end of file diff --git a/eloqua.js b/eloqua.js new file mode 100644 index 0000000..6ae25b2 --- /dev/null +++ b/eloqua.js @@ -0,0 +1,29 @@ +/** + * @file + * Initialize Eloqua tracking. + */ + +var _elqQ = _elqQ || []; + +(function ($) { + + Drupal.behaviors.eloquaTracking = { + attach: function (context, settings) { + + _elqQ.push(['elqSetSiteId', Drupal.settings.eloqua.siteId]); + _elqQ.push(['elqTrackPageView']); + + function async_load() { + var s = document.createElement('script'); + s.type = 'text/javascript'; + s.async = true; + s.src = '//img.en25.com/i/elqCfg.min.js'; + var x = document.getElementsByTagName('script')[0]; + x.parentNode.insertBefore(s, x); + } + if (window.addEventListener) window.addEventListener('DOMContentLoaded', + async_load, false); + else if (window.attachEvent) window.attachEvent('onload', async_load); + } + }; +})(jQuery); \ No newline at end of file diff --git a/eloqua.module b/eloqua.module index 59e4ec2..876633f 100644 --- a/eloqua.module +++ b/eloqua.module @@ -1,4 +1,5 @@ $file, '!directory' => $directory)), 'error'); - } - else { - drupal_add_js($directory . '/' . $file . '.js'); - } - } + drupal_add_js(array('eloqua' => array('siteId' => check_plain(eloqua_get_site_id()))), 'setting'); + drupal_add_js(drupal_get_path('module', 'eloqua') . '/eloqua.js'); } - /** * Implementation of hook_menu(). */ @@ -54,16 +41,12 @@ function eloqua_menu() { return $items; } - - function eloqua_cron() { // Load the cron functionality module_load_include('inc', 'eloqua', 'eloqua.cron'); _eloqua_cron(); } - - /** * Returns the list of exempt component types * @return array @@ -75,7 +58,6 @@ function _eloqua_webform_component_get_exempt_types() { ); } - /** * Tests whether the given component type is valid for Eloqua Integration * @param $test_type @@ -88,17 +70,15 @@ function _eloqua_is_valid_component_type($test_type) { return $result; } - /** * Implementatation of hook_form_FORM_ID_alter(). * This function is reponsible for adding the form-id mapping values to the Component add/edit page * Note: this isn't used for the fieldset type. */ -function eloqua_form_webform_component_edit_form_alter (&$form, $form_state) { +function eloqua_form_webform_component_edit_form_alter(&$form, $form_state) { if (!array_key_exists('build_info', $form_state) || !array_key_exists('args', $form_state['build_info']) - || !array_key_exists(1, $form_state['build_info']['args'])) - { + || !array_key_exists(1, $form_state['build_info']['args'])) { return; } @@ -140,7 +120,6 @@ function eloqua_form_webform_component_edit_form_alter (&$form, $form_state) { $form['#validate'][] = 'eloqua_form_webform_component_edit_form_validate'; } - /** * Presave handler * @param $component @@ -152,7 +131,6 @@ function eloqua_webform_component_presave(&$component) { } } - /** * Validates the eloqua field * @todo Make this less Western Centric. Get parameters should be able to accept all Unicode code-points @@ -175,7 +153,7 @@ function eloqua_form_webform_component_edit_form_validate($form, $form_state) { /** * Implementation of hook_form_FORM_ID_alter(). */ -function eloqua_form_webform_configure_form_alter (&$form, $form_state) { +function eloqua_form_webform_configure_form_alter(&$form, $form_state) { $form['#submit'][] = 'eloqua_form_webform_configure_form_submit'; $form['#validate'][] = 'eloqua_form_webform_configure_form_validate'; // Load the form options from the database if available @@ -232,17 +210,16 @@ function eloqua_form_webform_configure_form_alter (&$form, $form_state) { * @param $form_state * @return unknown_type */ -function eloqua_form_webform_configure_form_validate ($form, $form_state) { +function eloqua_form_webform_configure_form_validate($form, $form_state) { $values = $form_state['values']; if ($values['elq_enabled']) { if (empty($values['elq_form_name'])) { form_set_error('elq_form_name', t('The Eloqua Form Name must be set if the form is to be eloqua-enabled.' - . ' This can only contain the characters a-zA-Z and _')); + . ' This can only contain the characters a-zA-Z and _')); } } } - /** * Submit handler for webform_configure_form * @param $form array @@ -257,17 +234,16 @@ function eloqua_form_webform_configure_form_submit ($form, &$form_state) { $webform->{ELOQUA_WEBFORM_FIELD_ACTIVE} = $values['elq_enabled']; $webform->{ELOQUA_WEBFORM_FIELD_FORM_NAME} = $values['elq_form_name']; $webform->{ELOQUA_WEBFORM_FIELD_DATA} = (object) array( - 'process_every_page' => $values['elq_process_every_page'], + 'process_every_page' => $values['elq_process_every_page'], ); eloqua_webform_create($webform); } - /** * Implementation of hook_form_alter(). */ -function eloqua_form_alter (&$form, $form_state, $form_id) { +function eloqua_form_alter(&$form, $form_state, $form_id) { // We only want to edit client versions of the webform. If it's anything else // simply return. if (strpos($form_id, 'webform_client_form') !== 0) { @@ -293,9 +269,7 @@ function eloqua_form_alter (&$form, $form_state, $form_id) { $form['#submit'][] = 'eloqua_webform_submit'; $form['eloqua'] = array(); $process_every_page = - (is_object($form_settings[ELOQUA_SETTINGS_FIELD_DATA]) && isset($form_settings[ELOQUA_SETTINGS_FIELD_DATA]->process_every_page)) - ? $form_settings[ELOQUA_SETTINGS_FIELD_DATA]->process_every_page - : FALSE; + (is_object($form_settings[ELOQUA_SETTINGS_FIELD_DATA]) && isset($form_settings[ELOQUA_SETTINGS_FIELD_DATA]->process_every_page)) ? $form_settings[ELOQUA_SETTINGS_FIELD_DATA]->process_every_page : FALSE; $form['eloqua']['process_every_page'] = array( '#type' => 'value', '#value' => $process_every_page, @@ -309,17 +283,27 @@ function eloqua_form_alter (&$form, $form_state, $form_id) { $form['eloqua']['elqCustomerGUID']['#attributes']['id'] = 'edit-elqCustomerGUID'; $form['eloqua']['elqCookieWrite'] = _eloqua_form_hidden('0'); - drupal_add_js('var elqPPS="70";', 'inline'); - $directory = variable_get(ELOQUA_VARIABLE_SCRIPTS_DIRECTORY, ELOQUA_VARIABLE_SCRIPTS_DIRECTORY_DEFAULT); - $js_file = $directory . '/elqScr.js'; - drupal_add_js($js_file, 'file'); - $initScript = <<