← All changes
|
includes/Core/Integration/ZohoAnalytics/ZohoAnalyticsHandler.php
+17
-59
3.3.1
→
2.15.3
View file →
| @@ -6,17 +6,12 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace BitCode\BitForm\Core\Integration\ZohoAnalytics; |
| 9 | 9 | |
| 10 | -if (!defined('ABSPATH')) { | |
| 11 | - exit; | |
| 12 | -} | |
| 13 | - | |
| 14 | 10 | use BitCode\BitForm\Core\Integration\IntegrationHandler; |
| 15 | 11 | use BitCode\BitForm\Core\Util\ApiResponse as UtilApiResponse; |
| 16 | 12 | use BitCode\BitForm\Core\Util\HttpHelper; |
| 17 | 13 | use BitCode\BitForm\Core\Util\IpTool; |
| 18 | -use BitCode\BitForm\GlobalHelper; | |
| 19 | 14 | use WP_Error; |
| 20 | 15 | |
| 21 | 16 | /** |
| 22 | 17 | * Provide functionality for ZohoCrm integration |
| @@ -55,17 +50,11 @@ | ||
| 55 | 50 | * @return JSON zoho crm api response and status |
| 56 | 51 | */ |
| 57 | 52 | public static function generateTokens() |
| 58 | 53 | { |
| 59 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 60 | - GlobalHelper::requirePostMethod(); | |
| 61 | - | |
| 62 | - try { | |
| 63 | - $requestsParams = GlobalHelper::formatRequestData(); | |
| 64 | - } catch (\InvalidArgumentException $e) { | |
| 65 | - wp_send_json_error($e->getMessage(), 400); | |
| 66 | - } | |
| 67 | - | |
| 54 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 55 | + $inputJSON = file_get_contents('php://input'); | |
| 56 | + $requestsParams = json_decode($inputJSON); | |
| 68 | 57 | if ( |
| 69 | 58 | empty($requestsParams->{'accounts-server'}) |
| 70 | 59 | || empty($requestsParams->dataCenter) |
| 71 | 60 | || empty($requestsParams->clientId) |
| @@ -117,18 +106,12 @@ | ||
| 117 | 106 | * @return JSON crm module data |
| 118 | 107 | */ |
| 119 | 108 | public static function refreshWorkspacesAjaxHelper() |
| 120 | 109 | { |
| 121 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 110 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 122 | 111 | $authorizationHeader = null; |
| 123 | - | |
| 124 | - GlobalHelper::requirePostMethod(); | |
| 125 | - | |
| 126 | - try { | |
| 127 | - $queryParams = GlobalHelper::formatRequestData(); | |
| 128 | - } catch (\InvalidArgumentException $e) { | |
| 129 | - wp_send_json_error($e->getMessage(), 400); | |
| 130 | - } | |
| 112 | + $inputJSON = file_get_contents('php://input'); | |
| 113 | + $queryParams = json_decode($inputJSON); | |
| 131 | 114 | if ( |
| 132 | 115 | empty($queryParams->tokenDetails) |
| 133 | 116 | || empty($queryParams->dataCenter) |
| 134 | 117 | || empty($queryParams->clientId) |
| @@ -183,19 +166,12 @@ | ||
| 183 | 166 | } |
| 184 | 167 | |
| 185 | 168 | public static function refreshUsersAjaxHelper() |
| 186 | 169 | { |
| 187 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 170 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 188 | 171 | $authorizationHeader = null; |
| 189 | - | |
| 190 | - GlobalHelper::requirePostMethod(); | |
| 191 | - | |
| 192 | - try { | |
| 193 | - $queryParams = GlobalHelper::formatRequestData(); | |
| 194 | - } catch (\InvalidArgumentException $e) { | |
| 195 | - wp_send_json_error($e->getMessage(), 400); | |
| 196 | - } | |
| 197 | - | |
| 172 | + $inputJSON = file_get_contents('php://input'); | |
| 173 | + $queryParams = json_decode($inputJSON); | |
| 198 | 174 | if ( |
| 199 | 175 | empty($queryParams->tokenDetails) |
| 200 | 176 | || empty($queryParams->dataCenter) |
| 201 | 177 | || empty($queryParams->clientId) |
| @@ -255,18 +231,12 @@ | ||
| 255 | 231 | * @return JSON crm layout data |
| 256 | 232 | */ |
| 257 | 233 | public static function refreshTablesAjaxHelper() |
| 258 | 234 | { |
| 259 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 235 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 260 | 236 | $authorizationHeader = null; |
| 261 | - | |
| 262 | - GlobalHelper::requirePostMethod(); | |
| 263 | - | |
| 264 | - try { | |
| 265 | - $queryParams = GlobalHelper::formatRequestData(); | |
| 266 | - } catch (\InvalidArgumentException $e) { | |
| 267 | - wp_send_json_error($e->getMessage(), 400); | |
| 268 | - } | |
| 237 | + $inputJSON = file_get_contents('php://input'); | |
| 238 | + $queryParams = json_decode($inputJSON); | |
| 269 | 239 | if ( |
| 270 | 240 | empty($queryParams->workspace) |
| 271 | 241 | || empty($queryParams->tokenDetails) |
| 272 | 242 | || empty($queryParams->dataCenter) |
| @@ -329,17 +299,12 @@ | ||
| 329 | 299 | * @return JSON crm layout data |
| 330 | 300 | */ |
| 331 | 301 | public static function refreshTableHeadersAjaxHelper() |
| 332 | 302 | { |
| 333 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 303 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 334 | 304 | $authorizationHeader = null; |
| 335 | - | |
| 336 | - GlobalHelper::requirePostMethod(); | |
| 337 | - try { | |
| 338 | - $queryParams = GlobalHelper::formatRequestData(); | |
| 339 | - } catch (\InvalidArgumentException $e) { | |
| 340 | - wp_send_json_error($e->getMessage(), 400); | |
| 341 | - } | |
| 305 | + $inputJSON = file_get_contents('php://input'); | |
| 306 | + $queryParams = json_decode($inputJSON); | |
| 342 | 307 | if ( |
| 343 | 308 | empty($queryParams->workspace) |
| 344 | 309 | || empty($queryParams->table) |
| 345 | 310 | || empty($queryParams->tokenDetails) |
| @@ -479,15 +444,8 @@ | ||
| 479 | 444 | $dataCenter = $integrationDetails->dataCenter; |
| 480 | 445 | $fieldMap = $integrationDetails->field_map; |
| 481 | 446 | $actions = $integrationDetails->actions; |
| 482 | 447 | $defaultDataConf = $integrationDetails->default; |
| 483 | - | |
| 484 | - $entryDetails = [ | |
| 485 | - 'formId' => $this->_formID, | |
| 486 | - 'entryId' => $entryID, | |
| 487 | - 'fieldValues' => $fieldValues | |
| 488 | - ]; | |
| 489 | - | |
| 490 | 448 | if ( |
| 491 | 449 | empty($tokenDetails) |
| 492 | 450 | || empty($workspace) |
| 493 | 451 | || empty($table) |
| @@ -493,9 +451,9 @@ | ||
| 493 | 451 | || empty($table) |
| 494 | 452 | || empty($fieldMap) |
| 495 | 453 | ) { |
| 496 | 454 | $error = new WP_Error('REQ_FIELD_EMPTY', __('workspace, table, fields are required for zoho analytics api', 'bit-form')); |
| 497 | - $this->_logResponse->apiResponse($logID, $this->_integrationID, 'record', 'validation', $error, $entryDetails); | |
| 455 | + $this->_logResponse->apiResponse($logID, $this->_integrationID, 'record', 'validation', $error); | |
| 498 | 456 | return $error; |
| 499 | 457 | } |
| 500 | 458 | |
| 501 | 459 | $requiredParams = null; |
| @@ -511,9 +469,9 @@ | ||
| 511 | 469 | } |
| 512 | 470 | } |
| 513 | 471 | |
| 514 | 472 | // $actions = $integrationDetails->actions; |
| 515 | - $recordApiHelper = new RecordApiHelper($tokenDetails, $this->_integrationID, $logID, $this->_formID, $entryID); | |
| 473 | + $recordApiHelper = new RecordApiHelper($tokenDetails, $this->_integrationID, $logID); | |
| 516 | 474 | |
| 517 | 475 | $zanalyticsApiResponse = $recordApiHelper->executeRecordApi( |
| 518 | 476 | $workspace, |
| 519 | 477 | $table, |