Changeset 1970668
- Timestamp:
- 11/08/2018 02:44:39 AM (7 years ago)
- Location:
- gravityforms-hubspot
- Files:
-
- 8 edited
- 1 copied
-
branches/dev/gravityforms-hubspot.php (modified) (2 diffs)
-
branches/dev/readme.txt (modified) (2 diffs)
-
branches/dev/src/Base.php (modified) (2 diffs)
-
branches/dev/src/GF_HubSpot.php (modified) (12 diffs)
-
tags/4.1.1 (copied) (copied from gravityforms-hubspot/branches/dev)
-
tags/4.1.1/gravityforms-hubspot.php (modified) (2 diffs)
-
tags/4.1.1/readme.txt (modified) (2 diffs)
-
tags/4.1.1/src/Base.php (modified) (2 diffs)
-
tags/4.1.1/src/GF_HubSpot.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
gravityforms-hubspot/branches/dev/gravityforms-hubspot.php
r1881519 r1970668 4 4 Plugin URI: http://bigsea.co/ 5 5 Description: Easily integrate your Gravity Forms with HubSpot forms! Match up field-for-field so you can harness the power of HubSpot. 6 Version: 4. 06 Version: 4.1.1 7 7 Author: Big Sea 8 8 Author URI: http://bigsea.co … … 12 12 define('GF_HUBSPOT_BASENAME', plugin_basename(__FILE__)); 13 13 define('GF_HUBSPOT_PATH', WP_PLUGIN_DIR . "/" . basename(dirname(__FILE__)) . "/"); 14 define('GF_HUBSPOT_VERSION', '4. 0');14 define('GF_HUBSPOT_VERSION', '4.1.1'); 15 15 if ( !defined('GF_HUBSPOT_DEBUG') ) define('GF_HUBSPOT_DEBUG', false); 16 16 -
gravityforms-hubspot/branches/dev/readme.txt
r1881657 r1970668 1 1 === HubSpot for Gravity Forms === 2 Contributors: Big Sea, Soben , bloqhead2 Contributors: Big Sea, Soben 3 3 Donate link: http://bigsea.co/ 4 4 Tags: hubspot, gravity, forms, submit, submission, lead, api, gravity forms 5 5 Requires at least: 3.5 6 6 Tested up to: 4.9.6 7 Stable tag: 4. 07 Stable tag: 4.1.1 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 69 69 == Changelog == 70 70 71 = 4.1.1 = 72 * [FIX] Modification of strok, via adammichaelroach 73 74 = 4.1 = 75 * [UPDATE] Improved "enumeration" field type support. Now more properly handles Radio, Boolean Checkboxes (aka 'Single Checkbox'), and Checkboxes fields from HubSpot with more accuracy. 76 * [UPDATE] HubSpot call more accurately sends the current page of the submission (thanks, Josh Allen @cirkut) 77 78 = 4.0.1 = 79 * [NEW] New Filters: `gf_hubspot_process_success` and `gf_hubspot_process_failure` actions, as well as `gf_hubspot_data_single` filter for modifying a value on a single field basis. 80 * [DEPRECATION] `gf_hubspot_data_outgoing` in favor of `gf_hubspot_data_object` ... both will remain in the code. 81 71 82 = 4.0 = 72 * [N ew] Support for "File Upload" field in Gravity Forms. Takes the resulting upload URLs and send them to HubSpot in a semi-colon delimited list.73 * [N ew] `apply_filters( 'gf_hubspot_conditional_not_met', false, $feed, $entry, $form);` Allows you to skip the feed on programmatic conditions.74 * [N ew] Conditional Logic now possible during feed management83 * [NEW] Support for "File Upload" field in Gravity Forms. Takes the resulting upload URLs and send them to HubSpot in a semi-colon delimited list. 84 * [NEW] `apply_filters( 'gf_hubspot_conditional_not_met', false, $feed, $entry, $form);` Allows you to skip the feed on programmatic conditions. 85 * [NEW] Conditional Logic now possible during feed management 75 86 * [NOTICE] Redirections set in HubSpot upon success can cause conflicts. We are trying to show a heads up now to make sure you check your forms :) 76 87 -
gravityforms-hubspot/branches/dev/src/Base.php
r1729548 r1970668 207 207 'hutk' => $hubspotutk, 208 208 'ipAddress' => $ip_addr, 209 'pageUrl' => apply_filters( 'gf_hubspot_context_url', site_url( ) ),210 'pageName' => apply_filters( 'gf_hubspot_context_name', rgars($form, 'title') ),209 'pageUrl' => apply_filters( 'gf_hubspot_context_url', site_url(strtok($_SERVER['REQUEST_URI'], '?')) ), 210 'pageName' => apply_filters( 'gf_hubspot_context_name', $this->getValue($form, 'title') ), 211 211 ); 212 if ( rgars ( $feed, 'meta/disableCookie') == 1 ) {212 if ( $this->getValue($feed, 'meta/disableCookie') == 1 ) { 213 213 unset($hs_context['hutk']); 214 214 } … … 242 242 return $formData; 243 243 } // function 244 245 /** 246 COMMON 247 */ 248 // rgars is a pain when my trying to debug with existing data, this is to override that, and it's redundant for checks 249 protected function getValue($data, $field) 250 { 251 $data = (array)$data; 252 253 if (function_exists('rgars') && rgars($feed, 'meta/formID')) { 254 return rgars($feed, 'meta/formID'); 255 } 256 257 $fieldArray = explode('/', $field); 258 if (isset($data[$fieldArray[0]])) { 259 $data = (array)$data[$fieldArray[0]]; 260 261 if (count($fieldArray) == 1) { 262 if (is_array($data)) { 263 return $data[0]; 264 } 265 266 return $data; 267 } 268 269 return $this->getValue($data, implode('/', array_slice($fieldArray, 1))); 270 } 271 272 return ''; 273 } 244 274 } // class -
gravityforms-hubspot/branches/dev/src/GF_HubSpot.php
r1881519 r1970668 107 107 108 108 // Let's get the HubSpot Form! 109 $form_id = rgars ( $feed, 'meta/formID');109 $form_id = $this->getValue($feed, 'meta/formID'); 110 110 $hubspot_form = $this->_getForm( $form_id ); 111 if (!is_object($hubspot_form) || !isset($hubspot_form->name)) { 112 Tracking::log(__METHOD__ . '(): Invalid HubSpot Form "'.$form_id.'"'); 113 $this->add_feed_error( 114 'Invalid HubSpot Form "'.$form_id.'"', 115 $feed, 116 $entry, 117 $form 118 ); 119 return; 120 } 111 121 112 122 // We are definitely in a good ground moving forward! 113 123 Tracking::log(__METHOD__ . '(): Feed Processing for Form "'.$hubspot_form->name.'" ('.$form_id.')'); 114 124 115 $f ieldMap = $this->get_field_map_fields( $feed, 'fieldMap' );125 $feedFieldMap = $this->get_field_map_fields( $feed, 'fieldMap' ); 116 126 117 127 $data_to_hubspot = array (); 118 128 foreach ( $hubspot_form->formFieldGroups as $fieldGroup ) { 119 foreach ($fieldGroup->fields as $ field) {120 if ( !isset ( $f ieldMap[$field->name] ) ) {129 foreach ($fieldGroup->fields as $hubspotField) { 130 if ( !isset ( $feedFieldMap[$hubspotField->name] ) ) { 121 131 continue; 122 132 } 123 133 124 $g f_field = \GFFormsModel::get_field( $form, $fieldMap[$field->name]);125 126 $g f_field_value = $this->get_field_value( $form, $entry, $fieldMap[$field->name] );127 if ( $ field->required && !$gf_field_value ) {128 Tracking::log(__METHOD__ . '(): Required field "'.$ field->label.'" missing.', $field, $gf_field_value);134 $gravityformsField = \GFFormsModel::get_field( $form, $feedFieldMap[$hubspotField->name]); 135 136 $gravityformsField_value = $this->get_field_value( $form, $entry, $feedFieldMap[$hubspotField->name] ); 137 if ( $hubspotField->required && !$gravityformsField_value ) { 138 Tracking::log(__METHOD__ . '(): Required field "'.$hubspotField->label.'" missing.', $hubspotField, $gravityformsField_value); 129 139 $this->add_feed_error( 130 'Required field "'.$ field->label.'" for form "'.$hubspot_form->name.'" ['.$form_id.'] missing.',140 'Required field "'.$hubspotField->label.'" for form "'.$hubspot_form->name.'" ['.$form_id.'] missing.', 131 141 $feed, 132 142 $entry, … … 136 146 } 137 147 138 $data_to_hubspot[$field->name] = $this->_get_field_formatted_for_hubspot($field->type, $gf_field_value, $gf_field); 148 $currentDataParsed = $this->_get_field_formatted_for_hubspot($hubspotField, $gravityformsField_value, $gravityformsField); 149 $data_to_hubspot[$hubspotField->name] = apply_filters('gf_hubspot_data_single', $currentDataParsed, $hubspotField, $feed, $entry, $form); 139 150 } 140 151 } 141 152 142 153 $data_to_hubspot = apply_filters( 'gf_hubspot_data_outgoing', $data_to_hubspot, $form, $feed ); 154 $data_to_hubspot = apply_filters( 'gf_hubspot_data_object', $data_to_hubspot, $form, $feed ); 143 155 144 156 // With all of the data organized now, let's get the HubSpot call ready. … … 147 159 // Try to send the form. 148 160 try { 161 do_action('gf_hubspot_process_before_send'); 162 149 163 $result = $this->hubspot->forms()->submit($this->getPortalID(), $form_id, $data_to_hubspot); 150 164 $status_code = $result->getStatusCode(); … … 157 171 158 172 Tracking::log(__METHOD__ . '(): Form Successfully submitted ['.$form_id.']', $data_to_hubspot); 173 $this->log_debug('HubSpot accepted the form submission.'); 174 do_action('gf_hubspot_process_success', $data_to_hubspot, $form, $feed); 159 175 return; 160 176 } … … 164 180 $this->add_feed_error( 165 181 'HubSpot rejected the submission with an error '.$status_code.' for "'.$hubspot_form->name.'" ['.$form_id.'].', 166 $feed, 182 $feed, 167 183 $entry, 168 184 $form … … 177 193 ); 178 194 } 195 196 do_action('gf_hubspot_process_failure', $data_to_hubspot, $form, $feed); 179 197 } // function 180 198 … … 305 323 'type' => 'checkbox', 306 324 'choices' => array( 307 array(308 'label' => 'Disable Cookie Tracking',309 'name' => 'disableCookie',310 'tooltip' => '<h6>'. __( 'Disable Cookie', 'gravityforms-hubspot' ) .'</h6>' . __( 'When disabled, every submission from the same browser creates a new contact.', 'gravityforms-hubspot' ),311 'default_value' => 0,312 313 ),314 )325 array( 326 'label' => 'Disable Cookie Tracking', 327 'name' => 'disableCookie', 328 'tooltip' => '<h6>'. __( 'Disable Cookie', 'gravityforms-hubspot' ) .'</h6>' . __( 'When disabled, every submission from the same browser creates a new contact.', 'gravityforms-hubspot' ), 329 'default_value' => 0, 330 331 ), 332 ) 315 333 ) 316 334 ) … … 407 425 */ 408 426 public function get_column_value_formID( $feed ) { 409 $form_details = $this->_getForm( rgars( $feed, 'meta/formID' ) );427 $form_details = $this->_getForm( $this->getValue( $feed, 'meta/formID' ) ); 410 428 411 429 return isset($form_details->name) ? $form_details->name : 'Form Not Found'; … … 458 476 if ( is_object($response) && is_array($response->formFieldGroups) ) { 459 477 foreach ( $response->formFieldGroups as $fieldGroup ) { 460 foreach ($fieldGroup->fields as $ field) {461 $ field_label = $field->name;462 if (trim($ field->label) != '') {463 $ field_label = $field->label;478 foreach ($fieldGroup->fields as $hubspotField) { 479 $hubspotField_label = $hubspotField->name; 480 if (trim($hubspotField->label) != '') { 481 $hubspotField_label = $hubspotField->label; 464 482 } 465 483 $output[] = array ( 466 'label' => $ field_label,467 'name' => $ field->name,468 'required' => $ field->required,469 'value' => $ field->name,484 'label' => $hubspotField_label, 485 'name' => $hubspotField->name, 486 'required' => $hubspotField->required, 487 'value' => $hubspotField->name, 470 488 ); 471 489 } … … 481 499 482 500 // Posted Settings override the Feed Setting. 483 if ( $form_id = rgars($posted_settings, 'formID') ) {501 if ( $form_id = $this->getValue($posted_settings, 'formID') ) { 484 502 // We have a POST setting 485 503 return $form_id; 486 504 } 487 505 488 if ( $form_id = rgars($feed, 'meta/formID') ) {506 if ( $form_id = $this->getValue($feed, 'meta/formID') ) { 489 507 // We have a saved setting 490 508 return $form_id; … … 495 513 496 514 497 private function _get_field_formatted_for_hubspot ( $h s_field_type, $data, $gf_field ) {498 $ data = $this->preParseGravityFormData($data, $gf_field);499 500 switch ( $h s_field_type ) {515 private function _get_field_formatted_for_hubspot ( $hubspotField, $providedInput, $gravityformsField ) { 516 $providedInput = $this->preParseGravityFormData($providedInput, $hubspotField, $gravityformsField); 517 518 switch ( $hubspotField->type ) { 501 519 case 'date' : 502 return strtotime($data) * 1000; 503 break; 520 return strtotime($providedInput) * 1000; 504 521 case 'enumeration' : 505 // We're expecting multiple pieces of data 506 if ( !is_array( $data ) ) { 507 $data = explode(', ', $data); 508 foreach ( $data as &$content ) { 509 $content = trim($content); 510 } 522 switch ($hubspotField->fieldType) { 523 case 'booleancheckbox' : 524 if ($providedInput != '') { 525 return 'true'; 526 } 527 return 'false'; 528 case 'radio' : 529 return $providedInput; 530 default : 531 // We're expecting multiple pieces of data 532 if ( !is_array( $providedInput ) ) { 533 $providedInput = explode(', ', $providedInput); 534 foreach ( $providedInput as &$content ) { 535 $content = trim($content); 536 } 537 } 538 return implode(';', $providedInput); 511 539 } 512 513 return implode(';', $data);514 break;515 540 default : 516 return $ data;541 return $providedInput; 517 542 } 518 543 } // function … … 524 549 * In this case, we're converting the Field type into a semi-colon separated string. 525 550 */ 526 private function preParseGravityFormData($data, $g f_field)551 private function preParseGravityFormData($data, $gravityformsField) 527 552 { 528 // Currently does nothing. We have no special situations to worry about .553 // Currently does nothing. We have no special situations to worry about, yet. 529 554 530 555 return $data; -
gravityforms-hubspot/tags/4.1.1/gravityforms-hubspot.php
r1881519 r1970668 4 4 Plugin URI: http://bigsea.co/ 5 5 Description: Easily integrate your Gravity Forms with HubSpot forms! Match up field-for-field so you can harness the power of HubSpot. 6 Version: 4. 06 Version: 4.1.1 7 7 Author: Big Sea 8 8 Author URI: http://bigsea.co … … 12 12 define('GF_HUBSPOT_BASENAME', plugin_basename(__FILE__)); 13 13 define('GF_HUBSPOT_PATH', WP_PLUGIN_DIR . "/" . basename(dirname(__FILE__)) . "/"); 14 define('GF_HUBSPOT_VERSION', '4. 0');14 define('GF_HUBSPOT_VERSION', '4.1.1'); 15 15 if ( !defined('GF_HUBSPOT_DEBUG') ) define('GF_HUBSPOT_DEBUG', false); 16 16 -
gravityforms-hubspot/tags/4.1.1/readme.txt
r1881657 r1970668 1 1 === HubSpot for Gravity Forms === 2 Contributors: Big Sea, Soben , bloqhead2 Contributors: Big Sea, Soben 3 3 Donate link: http://bigsea.co/ 4 4 Tags: hubspot, gravity, forms, submit, submission, lead, api, gravity forms 5 5 Requires at least: 3.5 6 6 Tested up to: 4.9.6 7 Stable tag: 4. 07 Stable tag: 4.1.1 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 69 69 == Changelog == 70 70 71 = 4.1.1 = 72 * [FIX] Modification of strok, via adammichaelroach 73 74 = 4.1 = 75 * [UPDATE] Improved "enumeration" field type support. Now more properly handles Radio, Boolean Checkboxes (aka 'Single Checkbox'), and Checkboxes fields from HubSpot with more accuracy. 76 * [UPDATE] HubSpot call more accurately sends the current page of the submission (thanks, Josh Allen @cirkut) 77 78 = 4.0.1 = 79 * [NEW] New Filters: `gf_hubspot_process_success` and `gf_hubspot_process_failure` actions, as well as `gf_hubspot_data_single` filter for modifying a value on a single field basis. 80 * [DEPRECATION] `gf_hubspot_data_outgoing` in favor of `gf_hubspot_data_object` ... both will remain in the code. 81 71 82 = 4.0 = 72 * [N ew] Support for "File Upload" field in Gravity Forms. Takes the resulting upload URLs and send them to HubSpot in a semi-colon delimited list.73 * [N ew] `apply_filters( 'gf_hubspot_conditional_not_met', false, $feed, $entry, $form);` Allows you to skip the feed on programmatic conditions.74 * [N ew] Conditional Logic now possible during feed management83 * [NEW] Support for "File Upload" field in Gravity Forms. Takes the resulting upload URLs and send them to HubSpot in a semi-colon delimited list. 84 * [NEW] `apply_filters( 'gf_hubspot_conditional_not_met', false, $feed, $entry, $form);` Allows you to skip the feed on programmatic conditions. 85 * [NEW] Conditional Logic now possible during feed management 75 86 * [NOTICE] Redirections set in HubSpot upon success can cause conflicts. We are trying to show a heads up now to make sure you check your forms :) 76 87 -
gravityforms-hubspot/tags/4.1.1/src/Base.php
r1729548 r1970668 207 207 'hutk' => $hubspotutk, 208 208 'ipAddress' => $ip_addr, 209 'pageUrl' => apply_filters( 'gf_hubspot_context_url', site_url( ) ),210 'pageName' => apply_filters( 'gf_hubspot_context_name', rgars($form, 'title') ),209 'pageUrl' => apply_filters( 'gf_hubspot_context_url', site_url(strtok($_SERVER['REQUEST_URI'], '?')) ), 210 'pageName' => apply_filters( 'gf_hubspot_context_name', $this->getValue($form, 'title') ), 211 211 ); 212 if ( rgars ( $feed, 'meta/disableCookie') == 1 ) {212 if ( $this->getValue($feed, 'meta/disableCookie') == 1 ) { 213 213 unset($hs_context['hutk']); 214 214 } … … 242 242 return $formData; 243 243 } // function 244 245 /** 246 COMMON 247 */ 248 // rgars is a pain when my trying to debug with existing data, this is to override that, and it's redundant for checks 249 protected function getValue($data, $field) 250 { 251 $data = (array)$data; 252 253 if (function_exists('rgars') && rgars($feed, 'meta/formID')) { 254 return rgars($feed, 'meta/formID'); 255 } 256 257 $fieldArray = explode('/', $field); 258 if (isset($data[$fieldArray[0]])) { 259 $data = (array)$data[$fieldArray[0]]; 260 261 if (count($fieldArray) == 1) { 262 if (is_array($data)) { 263 return $data[0]; 264 } 265 266 return $data; 267 } 268 269 return $this->getValue($data, implode('/', array_slice($fieldArray, 1))); 270 } 271 272 return ''; 273 } 244 274 } // class -
gravityforms-hubspot/tags/4.1.1/src/GF_HubSpot.php
r1881519 r1970668 107 107 108 108 // Let's get the HubSpot Form! 109 $form_id = rgars ( $feed, 'meta/formID');109 $form_id = $this->getValue($feed, 'meta/formID'); 110 110 $hubspot_form = $this->_getForm( $form_id ); 111 if (!is_object($hubspot_form) || !isset($hubspot_form->name)) { 112 Tracking::log(__METHOD__ . '(): Invalid HubSpot Form "'.$form_id.'"'); 113 $this->add_feed_error( 114 'Invalid HubSpot Form "'.$form_id.'"', 115 $feed, 116 $entry, 117 $form 118 ); 119 return; 120 } 111 121 112 122 // We are definitely in a good ground moving forward! 113 123 Tracking::log(__METHOD__ . '(): Feed Processing for Form "'.$hubspot_form->name.'" ('.$form_id.')'); 114 124 115 $f ieldMap = $this->get_field_map_fields( $feed, 'fieldMap' );125 $feedFieldMap = $this->get_field_map_fields( $feed, 'fieldMap' ); 116 126 117 127 $data_to_hubspot = array (); 118 128 foreach ( $hubspot_form->formFieldGroups as $fieldGroup ) { 119 foreach ($fieldGroup->fields as $ field) {120 if ( !isset ( $f ieldMap[$field->name] ) ) {129 foreach ($fieldGroup->fields as $hubspotField) { 130 if ( !isset ( $feedFieldMap[$hubspotField->name] ) ) { 121 131 continue; 122 132 } 123 133 124 $g f_field = \GFFormsModel::get_field( $form, $fieldMap[$field->name]);125 126 $g f_field_value = $this->get_field_value( $form, $entry, $fieldMap[$field->name] );127 if ( $ field->required && !$gf_field_value ) {128 Tracking::log(__METHOD__ . '(): Required field "'.$ field->label.'" missing.', $field, $gf_field_value);134 $gravityformsField = \GFFormsModel::get_field( $form, $feedFieldMap[$hubspotField->name]); 135 136 $gravityformsField_value = $this->get_field_value( $form, $entry, $feedFieldMap[$hubspotField->name] ); 137 if ( $hubspotField->required && !$gravityformsField_value ) { 138 Tracking::log(__METHOD__ . '(): Required field "'.$hubspotField->label.'" missing.', $hubspotField, $gravityformsField_value); 129 139 $this->add_feed_error( 130 'Required field "'.$ field->label.'" for form "'.$hubspot_form->name.'" ['.$form_id.'] missing.',140 'Required field "'.$hubspotField->label.'" for form "'.$hubspot_form->name.'" ['.$form_id.'] missing.', 131 141 $feed, 132 142 $entry, … … 136 146 } 137 147 138 $data_to_hubspot[$field->name] = $this->_get_field_formatted_for_hubspot($field->type, $gf_field_value, $gf_field); 148 $currentDataParsed = $this->_get_field_formatted_for_hubspot($hubspotField, $gravityformsField_value, $gravityformsField); 149 $data_to_hubspot[$hubspotField->name] = apply_filters('gf_hubspot_data_single', $currentDataParsed, $hubspotField, $feed, $entry, $form); 139 150 } 140 151 } 141 152 142 153 $data_to_hubspot = apply_filters( 'gf_hubspot_data_outgoing', $data_to_hubspot, $form, $feed ); 154 $data_to_hubspot = apply_filters( 'gf_hubspot_data_object', $data_to_hubspot, $form, $feed ); 143 155 144 156 // With all of the data organized now, let's get the HubSpot call ready. … … 147 159 // Try to send the form. 148 160 try { 161 do_action('gf_hubspot_process_before_send'); 162 149 163 $result = $this->hubspot->forms()->submit($this->getPortalID(), $form_id, $data_to_hubspot); 150 164 $status_code = $result->getStatusCode(); … … 157 171 158 172 Tracking::log(__METHOD__ . '(): Form Successfully submitted ['.$form_id.']', $data_to_hubspot); 173 $this->log_debug('HubSpot accepted the form submission.'); 174 do_action('gf_hubspot_process_success', $data_to_hubspot, $form, $feed); 159 175 return; 160 176 } … … 164 180 $this->add_feed_error( 165 181 'HubSpot rejected the submission with an error '.$status_code.' for "'.$hubspot_form->name.'" ['.$form_id.'].', 166 $feed, 182 $feed, 167 183 $entry, 168 184 $form … … 177 193 ); 178 194 } 195 196 do_action('gf_hubspot_process_failure', $data_to_hubspot, $form, $feed); 179 197 } // function 180 198 … … 305 323 'type' => 'checkbox', 306 324 'choices' => array( 307 array(308 'label' => 'Disable Cookie Tracking',309 'name' => 'disableCookie',310 'tooltip' => '<h6>'. __( 'Disable Cookie', 'gravityforms-hubspot' ) .'</h6>' . __( 'When disabled, every submission from the same browser creates a new contact.', 'gravityforms-hubspot' ),311 'default_value' => 0,312 313 ),314 )325 array( 326 'label' => 'Disable Cookie Tracking', 327 'name' => 'disableCookie', 328 'tooltip' => '<h6>'. __( 'Disable Cookie', 'gravityforms-hubspot' ) .'</h6>' . __( 'When disabled, every submission from the same browser creates a new contact.', 'gravityforms-hubspot' ), 329 'default_value' => 0, 330 331 ), 332 ) 315 333 ) 316 334 ) … … 407 425 */ 408 426 public function get_column_value_formID( $feed ) { 409 $form_details = $this->_getForm( rgars( $feed, 'meta/formID' ) );427 $form_details = $this->_getForm( $this->getValue( $feed, 'meta/formID' ) ); 410 428 411 429 return isset($form_details->name) ? $form_details->name : 'Form Not Found'; … … 458 476 if ( is_object($response) && is_array($response->formFieldGroups) ) { 459 477 foreach ( $response->formFieldGroups as $fieldGroup ) { 460 foreach ($fieldGroup->fields as $ field) {461 $ field_label = $field->name;462 if (trim($ field->label) != '') {463 $ field_label = $field->label;478 foreach ($fieldGroup->fields as $hubspotField) { 479 $hubspotField_label = $hubspotField->name; 480 if (trim($hubspotField->label) != '') { 481 $hubspotField_label = $hubspotField->label; 464 482 } 465 483 $output[] = array ( 466 'label' => $ field_label,467 'name' => $ field->name,468 'required' => $ field->required,469 'value' => $ field->name,484 'label' => $hubspotField_label, 485 'name' => $hubspotField->name, 486 'required' => $hubspotField->required, 487 'value' => $hubspotField->name, 470 488 ); 471 489 } … … 481 499 482 500 // Posted Settings override the Feed Setting. 483 if ( $form_id = rgars($posted_settings, 'formID') ) {501 if ( $form_id = $this->getValue($posted_settings, 'formID') ) { 484 502 // We have a POST setting 485 503 return $form_id; 486 504 } 487 505 488 if ( $form_id = rgars($feed, 'meta/formID') ) {506 if ( $form_id = $this->getValue($feed, 'meta/formID') ) { 489 507 // We have a saved setting 490 508 return $form_id; … … 495 513 496 514 497 private function _get_field_formatted_for_hubspot ( $h s_field_type, $data, $gf_field ) {498 $ data = $this->preParseGravityFormData($data, $gf_field);499 500 switch ( $h s_field_type ) {515 private function _get_field_formatted_for_hubspot ( $hubspotField, $providedInput, $gravityformsField ) { 516 $providedInput = $this->preParseGravityFormData($providedInput, $hubspotField, $gravityformsField); 517 518 switch ( $hubspotField->type ) { 501 519 case 'date' : 502 return strtotime($data) * 1000; 503 break; 520 return strtotime($providedInput) * 1000; 504 521 case 'enumeration' : 505 // We're expecting multiple pieces of data 506 if ( !is_array( $data ) ) { 507 $data = explode(', ', $data); 508 foreach ( $data as &$content ) { 509 $content = trim($content); 510 } 522 switch ($hubspotField->fieldType) { 523 case 'booleancheckbox' : 524 if ($providedInput != '') { 525 return 'true'; 526 } 527 return 'false'; 528 case 'radio' : 529 return $providedInput; 530 default : 531 // We're expecting multiple pieces of data 532 if ( !is_array( $providedInput ) ) { 533 $providedInput = explode(', ', $providedInput); 534 foreach ( $providedInput as &$content ) { 535 $content = trim($content); 536 } 537 } 538 return implode(';', $providedInput); 511 539 } 512 513 return implode(';', $data);514 break;515 540 default : 516 return $ data;541 return $providedInput; 517 542 } 518 543 } // function … … 524 549 * In this case, we're converting the Field type into a semi-colon separated string. 525 550 */ 526 private function preParseGravityFormData($data, $g f_field)551 private function preParseGravityFormData($data, $gravityformsField) 527 552 { 528 // Currently does nothing. We have no special situations to worry about .553 // Currently does nothing. We have no special situations to worry about, yet. 529 554 530 555 return $data;
Note: See TracChangeset
for help on using the changeset viewer.