| @@ -9,9 +9,8 @@ | ||
| 9 | 9 | |
| 10 | 10 | use BitCode\BitForm\Core\Database\FormEntryModel; |
| 11 | 11 | use BitCode\BitForm\Core\Database\FormModel; |
| 12 | 12 | use BitCode\BitForm\Core\Util\ApiResponse; |
| 13 | -use BitCode\BitForm\Core\Util\Log; | |
| 14 | 13 | use BitCode\BitForm\Core\Util\SmartTags; |
| 15 | 14 | use BitCode\BitForm\Core\Util\Utilities; |
| 16 | 15 | /** |
| 17 | 16 | * Provides details of available integration and helps to |
| @@ -22,23 +21,11 @@ | ||
| 22 | 21 | |
| 23 | 22 | final class Integrations |
| 24 | 23 | { |
| 25 | 24 | public $integrations = []; |
| 26 | - private static $_instance = null; | |
| 27 | 25 | |
| 28 | 26 | /** |
| 29 | 27 | * Undocumented function |
| 30 | - */ | |
| 31 | - public static function getInstance() | |
| 32 | - { | |
| 33 | - if (null === self::$_instance) { | |
| 34 | - self::$_instance = new Integrations(); | |
| 35 | - } | |
| 36 | - return self::$_instance; | |
| 37 | - } | |
| 38 | - | |
| 39 | - /** | |
| 40 | - * Undocumented function | |
| 41 | 28 | * |
| 42 | 29 | * @return array |
| 43 | 30 | */ |
| 44 | 31 | public function getAllIntegrations() |
| @@ -181,21 +168,13 @@ | ||
| 181 | 168 | public static function executeIntegrations($integrations, $fieldValues, $formID, $logID = null, $entryID = 0) |
| 182 | 169 | { |
| 183 | 170 | $integrationHandler = new IntegrationHandler($formID); |
| 184 | 171 | $logResponse = new ApiResponse(); |
| 185 | - $intThatNeedNoFileHandling = ['ACF', 'MetaBox', 'Pods']; //these takes raw file and upload it | |
| 186 | - $baseFieldValues = $fieldValues; | |
| 187 | - $entryDetails = [ | |
| 188 | - 'formId' => $formID, | |
| 189 | - 'entryId' => $entryID, | |
| 190 | - 'fieldValues' => $fieldValues | |
| 191 | - ]; | |
| 192 | 172 | if (is_array($integrations)) { |
| 193 | 173 | foreach ($integrations as $integrationIDStr) { |
| 194 | 174 | if (!is_string($integrationIDStr)) { |
| 195 | 175 | return; |
| 196 | 176 | } |
| 197 | - $currentFieldValues = $baseFieldValues; | |
| 198 | 177 | $integrationID = intval(json_decode($integrationIDStr)->id, 10); |
| 199 | 178 | if (!empty($integrationID) && is_int($integrationID)) { |
| 200 | 179 | $integrationResult |
| 201 | 180 | = $integrationHandler->getAIntegration($integrationID); |
| @@ -204,25 +183,22 @@ | ||
| 204 | 183 | if ('Brevo(SendinBlue)' === $integrationName) { |
| 205 | 184 | $integrationName = 'SendinBlue'; |
| 206 | 185 | } |
| 207 | 186 | if (!is_null($integrationName) && static::isExists($integrationName)) { |
| 208 | - if (!in_array($integrationName, $intThatNeedNoFileHandling)) { | |
| 209 | - $currentFieldValues = IntegrationHandler::handleFileUrl($currentFieldValues, $formID, $entryID); | |
| 210 | - } | |
| 211 | 187 | $integration = static::isExists($integrationName); |
| 212 | 188 | $handler = new $integration($integrationID, $formID); |
| 213 | 189 | $integDetails = is_string($integrationDetails->integration_details) ? json_decode($integrationDetails->integration_details) : $integrationDetails->integration_details; |
| 214 | 190 | if (isset($integDetails->field_map)) { |
| 215 | 191 | $sptagData = self::specialTagFields($integDetails->field_map); |
| 216 | - $currentFieldValues = $currentFieldValues + $sptagData; | |
| 192 | + $fieldValues = $fieldValues + $sptagData; | |
| 217 | 193 | } |
| 218 | - $handler->execute($integrationHandler, $integrationDetails, $currentFieldValues, $entryID, $logID); | |
| 194 | + $handler->execute($integrationHandler, $integrationDetails, $fieldValues, $entryID, $logID); | |
| 219 | 195 | } else { |
| 220 | 196 | do_action('bitform_integration_run_failure', $integrationID, $formID); |
| 221 | 197 | |
| 222 | 198 | $errorMsg = apply_filters('bitform_filter_integration_run_failure_message', __('Integration execution failed', 'bit-form'), $integrationID, $formID); |
| 223 | 199 | |
| 224 | - Log::debug_log('[+] Integration execution failed: ' . $errorMsg); | |
| 200 | + error_log('[+] Integration execution failed: ' . print_r($errorMsg, true)); | |
| 225 | 201 | |
| 226 | 202 | $logResponse->apiResponse( |
| 227 | 203 | $logID, |
| 228 | 204 | $integrationID, |
| @@ -227,10 +203,9 @@ | ||
| 227 | 203 | $logID, |
| 228 | 204 | $integrationID, |
| 229 | 205 | ['type' => 'record', 'type_name' => $integrationName || 'Integration'], |
| 230 | 206 | 'errors', |
| 231 | - $errorMsg, | |
| 232 | - $entryDetails | |
| 207 | + $errorMsg | |
| 233 | 208 | ); |
| 234 | 209 | } |
| 235 | 210 | } |
| 236 | 211 | } |
| @@ -250,67 +225,6 @@ | ||
| 250 | 225 | foreach ($integrations as $key => $value) { |
| 251 | 226 | self::executeIntegrations($value, $fieldValue, $formID, $logID, $entryID); |
| 252 | 227 | } |
| 253 | 228 | self::entryDeleted($formID, $entryID); |
| 254 | - } | |
| 255 | - | |
| 256 | - /** | |
| 257 | - * This function helps to save connected integration app | |
| 258 | - * | |
| 259 | - * @return wp_error | mixed | |
| 260 | - */ | |
| 261 | - public function saveConnectedIntegrationApp($appConfig) | |
| 262 | - { | |
| 263 | - // error_log('[+] saveConnectedIntegrationApp: ' . print_r($appConfig, true)); | |
| 264 | - $connectionName = $appConfig->name; | |
| 265 | - $connectionType = $appConfig->type; | |
| 266 | - // $connectionDetails = wp_json_encode($appConfig); | |
| 267 | - | |
| 268 | - if (empty($appConfig->details)) { | |
| 269 | - unset($appConfig->name, $appConfig->id); | |
| 270 | - | |
| 271 | - $connectionDetails = !is_string($appConfig) ? | |
| 272 | - wp_json_encode($appConfig) : $appConfig; | |
| 273 | - } else { | |
| 274 | - $connectionDetails = !is_string($appConfig->details) ? | |
| 275 | - wp_json_encode($appConfig->details) : $appConfig->details; | |
| 276 | - } | |
| 277 | - $connectionCategory = 'connected_integration_apps'; | |
| 278 | - | |
| 279 | - $integrationHandler = new IntegrationHandler(0); | |
| 280 | - | |
| 281 | - return $integrationHandler->saveIntegration($connectionName, $connectionType, $connectionDetails, $connectionCategory); | |
| 282 | - } | |
| 283 | - | |
| 284 | - // get connectd integration app | |
| 285 | - public function getConnectedIntegrationApp($integration_type = null) | |
| 286 | - { | |
| 287 | - $connectionCategory = 'connected_integration_apps'; | |
| 288 | - | |
| 289 | - $integrationHandler = new IntegrationHandler(0); | |
| 290 | - $allConnectedIntegApps = $integrationHandler->getAllIntegration($connectionCategory, $integration_type); | |
| 291 | - | |
| 292 | - if (!is_wp_error($allConnectedIntegApps)) { | |
| 293 | - foreach ($allConnectedIntegApps as $integrationkey => $integrationValue) { | |
| 294 | - $integrationData = [ | |
| 295 | - 'id' => $integrationValue->id, | |
| 296 | - 'name' => $integrationValue->integration_name, | |
| 297 | - 'type' => $integrationValue->integration_type, | |
| 298 | - ]; | |
| 299 | - $allConnectedIntegApps[$integrationkey]->integration_details = wp_json_encode(array_merge( | |
| 300 | - $integrationData, | |
| 301 | - is_string($integrationValue->integration_details) ? | |
| 302 | - (array) json_decode($integrationValue->integration_details) : | |
| 303 | - $integrationValue->integration_details | |
| 304 | - )); | |
| 305 | - } | |
| 306 | - } | |
| 307 | - return $allConnectedIntegApps; | |
| 308 | - } | |
| 309 | - | |
| 310 | - public function deleteConnectedApp($appId) | |
| 311 | - { | |
| 312 | - $integrationHandler = new IntegrationHandler(0); | |
| 313 | - | |
| 314 | - return $integrationHandler->deleteIntegration($appId); | |
| 315 | 229 | } |
| 316 | 230 | } |