diff --git a/Integration/AlcazarIntegration.php b/Integration/AlcazarIntegration.php index 0ef0509..ea98e43 100644 --- a/Integration/AlcazarIntegration.php +++ b/Integration/AlcazarIntegration.php @@ -145,7 +145,7 @@ protected function getEnhancerFieldArray() { $field_list = [ 'alcazar_lrn' => [ - 'label' => 'LRN', + 'label' => 'LRN', ], ]; @@ -165,31 +165,31 @@ private function getAlcazarExtendedFields() { return [ 'alcazar_spid' => [ - 'label' => 'Alcazar SPID', + 'label' => 'Alcazar SPID', ], 'alcazar_ocn' => [ - 'label' => 'Alcazar OCN', + 'label' => 'Alcazar OCN', ], 'alcazar_lata' => [ - 'label' => 'Alcazar LATA', + 'label' => 'Alcazar LATA', ], 'alcazar_city' => [ - 'label' => 'Alcazar City', + 'label' => 'Alcazar City', ], 'alcazar_state' => [ - 'label' => 'Alcazar State', + 'label' => 'Alcazar State', ], 'alcazar_lec' => [ - 'label' => 'Alcazar LEC', + 'label' => 'Alcazar LEC', ], 'alcazar_linetype' => [ - 'label' => 'Alcazar Line Type', + 'label' => 'Alcazar Line Type', ], 'alcazar_dnc' => [ - 'label' => 'Alcazar DNC', + 'label' => 'Alcazar DNC', ], 'alcazar_jurisdiction' => [ - 'label' => 'Alcazar Jurisdiction', + 'label' => 'Alcazar Jurisdiction', ], ]; } @@ -207,11 +207,12 @@ public function doEnhancement(Lead &$lead) } $phone = $lead->getPhone(); + $phone = preg_replace('/[^0-9]/', '', $phone); if (10 === strlen($phone)) { $phone = '1'.$phone; } if (11 !== strlen($phone)) { - return false; + return; } $keys = $this->getKeys(); diff --git a/Integration/FourleafIntegration.php b/Integration/FourleafIntegration.php index 323e3df..7e68527 100644 --- a/Integration/FourleafIntegration.php +++ b/Integration/FourleafIntegration.php @@ -126,13 +126,13 @@ public function doEnhancement(Lead &$lead) $this->applyCost($lead); + $allowedAliases = $this->getEnhancerFieldArray(); foreach ($response as $key => $value) { - if ('md5' === $key) { - continue; - } $alias = 'fourleaf_'.str_replace('user_', '', $key); - $default = $lead->getFieldValue($alias); - $lead->addUpdatedField($alias, $value, $default); + if (isset($allowedAliases[$alias])) { + $default = $lead->getFieldValue($alias); + $lead->addUpdatedField($alias, $value, $default); + } } $this->saveLead($lead); } diff --git a/Integration/RandomIntegration.php b/Integration/RandomIntegration.php index 9b5cc13..08b3381 100644 --- a/Integration/RandomIntegration.php +++ b/Integration/RandomIntegration.php @@ -98,7 +98,7 @@ public function doEnhancement(Lead &$lead) $settings = $this->getIntegrationSettings()->getFeatureSettings(); if (!$lead->getFieldValue($settings['random_field_name'])) { - $lead->{$settings['random_field_name']} = rand(1, 101); + $lead->addUpdatedField($settings['random_field_name'], rand(1, 100)); } } } diff --git a/Integration/XverifyIntegration.php b/Integration/XverifyIntegration.php index 3416a94..3f8d5e0 100644 --- a/Integration/XverifyIntegration.php +++ b/Integration/XverifyIntegration.php @@ -148,7 +148,7 @@ public function doEnhancement(Lead &$lead) $response = $status = $service = $fieldKey = null; $fieldToUpdate = $integrationFieldName.'_valid'; //which validation field will we update? try { - $fieldValue = $lead->$mauticFieldName; + $fieldValue = $lead->getFieldValue($mauticFieldName); if (!empty($fieldValue)) { switch ($integrationFieldName) { case 'cellphone': @@ -157,7 +157,7 @@ public function doEnhancement(Lead &$lead) // phone API call $service = 'phone'; $fieldKey = 'phone'; - if (is_null($lead->$fieldToUpdate)) { // only if we havent checked already + if (is_null($lead->getFieldValue($fieldToUpdate))) { // only if we havent checked already $response = $this->makeCall($service, $params, $fieldKey, $fieldValue); $this->applyCost($lead); $persist = true; @@ -175,7 +175,7 @@ public function doEnhancement(Lead &$lead) // email API call $service = 'emails'; $fieldKey = 'email'; - if (is_null($lead->$fieldToUpdate)) { // only if we havent checked already + if (is_null($lead->getFieldValue($fieldToUpdate))) { // only if we havent checked already $response = $this->makeCall($service, $params, $fieldKey, $fieldValue); $this->applyCost($lead); $persist = true; @@ -206,14 +206,7 @@ public function doEnhancement(Lead &$lead) if ($persist) { $this->saveLead($lead); - } // TODO why wont custom fields persist to DB? - - // This would be a duplicate event now. - // if ($this->dispatcher->hasListeners(MauticEnhancerEvents::ENHANCER_COMPLETED)) { - // $isNew = !$lead->getId(); - // $complete = new MauticEnhancerEvent($this, $lead, $isNew); - // $this->dispatcher->dispatch(MauticEnhancerEvents::ENHANCER_COMPLETED, $complete); - // } + } } }