PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 3.3.1
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v3.3.1
3.3.1 V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 All 138 releases
← All changes | includes/Core/Integration/ZohoRecruit/ZohoRecruitHandler.php +76 -30 2.03.3.1 View file →
@@ -6,21 +6,28 @@
6 6 */
7 7
8 8 namespace BitCode\BitForm\Core\Integration\ZohoRecruit;
9 9
10 +if (!defined('ABSPATH')) {
11 + exit;
12 +}
13 +
10 14 use BitCode\BitForm\Core\Integration\IntegrationHandler;
11 15 use BitCode\BitForm\Core\Util\HttpHelper;
12 16 use BitCode\BitForm\Core\Util\IpTool;
17 +use BitCode\BitForm\GlobalHelper;
13 18 use WP_Error;
14 19
15 20 /**
16 21 * Provide functionality for ZohoCrm integration
17 22 */
18 -class ZohoRecruitHandler {
23 +class ZohoRecruitHandler
24 +{
19 25 private $_formID;
20 26 private $_integrationID;
21 27
22 - public function __construct($integrationID, $fromID) {
28 + public function __construct($integrationID, $fromID)
29 + {
23 30 $this->_formID = $fromID;
24 31 $this->_integrationID = $integrationID;
25 32 }
26 33
@@ -28,9 +35,10 @@
28 35 * Helps to register ajax function's with wp
29 36 *
30 37 * @return null
31 38 */
32 - public static function registerAjax() {
39 + public static function registerAjax()
40 + {
33 41 add_action('wp_ajax_bitforms_zrecruit_generate_token', [__CLASS__, 'generateTokens']);
34 42 add_action('wp_ajax_bitforms_zrecruit_refresh_modules', [__CLASS__, 'refreshModulesAjaxHelper']);
35 43 add_action('wp_ajax_bitforms_zrecruit_refresh_notetypes', [__CLASS__, 'refreshNoteTypesAjaxHelper']);
36 44 add_action('wp_ajax_bitforms_zrecruit_refresh_related_lists', [__CLASS__, 'refreshRelatedModulesAjaxHelper']);
@@ -39,14 +47,21 @@
39 47
40 48 /**
41 49 * Process ajax request for generate_token
42 50 *
43 - * @return JSON zoho recruit api response and status
51 + * @return string zoho recruit api response and status
44 52 */
45 - public static function generateTokens() {
46 - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) {
47 - $inputJSON = file_get_contents('php://input');
48 - $requestsParams = json_decode($inputJSON);
53 + public static function generateTokens()
54 + {
55 + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
56 + GlobalHelper::requirePostMethod();
57 +
58 + try {
59 + $requestsParams = GlobalHelper::formatRequestData();
60 + } catch (\InvalidArgumentException $e) {
61 + wp_send_json_error($e->getMessage(), 400);
62 + }
63 +
49 64 if (
50 65 empty($requestsParams->{'accounts-server'})
51 66 || empty($requestsParams->dataCenter)
52 67 || empty($requestsParams->clientId)
@@ -96,13 +111,20 @@
96 111 * Process ajax request for refresh recruit modules
97 112 *
98 113 * @return JSON recruit module data
99 114 */
100 - public static function refreshModulesAjaxHelper() {
101 - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) {
115 + public static function refreshModulesAjaxHelper()
116 + {
117 + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
102 118 $authorizationHeader = null;
103 - $inputJSON = file_get_contents('php://input');
104 - $queryParams = json_decode($inputJSON);
119 +
120 + GlobalHelper::requirePostMethod();
121 +
122 + try {
123 + $queryParams = GlobalHelper::formatRequestData();
124 + } catch (\InvalidArgumentException $e) {
125 + wp_send_json_error($e->getMessage(), 400);
126 + }
105 127 if (
106 128 empty($queryParams->tokenDetails)
107 129 || empty($queryParams->dataCenter)
108 130 || empty($queryParams->clientId)
@@ -176,13 +198,20 @@
176 198 );
177 199 }
178 200 }
179 201
180 - public static function refreshNoteTypesAjaxHelper() {
181 - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) {
202 + public static function refreshNoteTypesAjaxHelper()
203 + {
204 + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
182 205 $authorizationHeader = null;
183 - $inputJSON = file_get_contents('php://input');
184 - $queryParams = json_decode($inputJSON);
206 +
207 + GlobalHelper::requirePostMethod();
208 + try {
209 + $queryParams = GlobalHelper::formatRequestData();
210 + } catch (\InvalidArgumentException $e) {
211 + wp_send_json_error($e->getMessage(), 400);
212 + }
213 +
185 214 if (
186 215 empty($queryParams->tokenDetails)
187 216 || empty($queryParams->dataCenter)
188 217 || empty($queryParams->clientId)
@@ -244,12 +273,19 @@
244 273 * Process ajax request for refresh recruit modules
245 274 *
246 275 * @return JSON recruit module data
247 276 */
248 - public static function refreshRelatedModulesAjaxHelper() {
249 - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) {
250 - $inputJSON = file_get_contents('php://input');
251 - $queryParams = json_decode($inputJSON);
277 + public static function refreshRelatedModulesAjaxHelper()
278 + {
279 + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
280 + GlobalHelper::requirePostMethod();
281 +
282 + try {
283 + $queryParams = GlobalHelper::formatRequestData();
284 + } catch (\InvalidArgumentException $e) {
285 + wp_send_json_error($e->getMessage(), 400);
286 + }
287 +
252 288 if (
253 289 empty($queryParams->tokenDetails)
254 290 || empty($queryParams->dataCenter)
255 291 || empty($queryParams->clientId)
@@ -314,14 +350,21 @@
314 350 * Process ajax request for refesh recruit layouts
315 351 *
316 352 * @return JSON recruit layout data
317 353 */
318 - public static function getFields() {
354 + public static function getFields()
355 + {
319 356 $authorizationHeader = null;
320 357 $requiredParams = null;
321 - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) {
322 - $inputJSON = file_get_contents('php://input');
323 - $queryParams = json_decode($inputJSON);
358 + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
359 + GlobalHelper::requirePostMethod();
360 +
361 + try {
362 + $queryParams = GlobalHelper::formatRequestData();
363 + } catch (\InvalidArgumentException $e) {
364 + wp_send_json_error($e->getMessage(), 400);
365 + }
366 +
324 367 if (
325 368 empty($queryParams->module)
326 369 || empty($queryParams->tokenDetails)
327 370 || empty($queryParams->dataCenter)
@@ -466,12 +509,13 @@
466 509
467 510 /**
468 511 * Helps to refresh zoho recruit access_token
469 512 *
470 - * @param Array $apiData Contains required data for refresh access token
471 - * @return JSON $tokenDetails API token details
513 + * @param object $apiData Contains required data for refresh access token
514 + * @return string | boolean $tokenDetails API token details
472 515 */
473 - protected static function _refreshAccessToken($apiData) {
516 + protected static function _refreshAccessToken($apiData)
517 + {
474 518 if (
475 519 empty($apiData->dataCenter)
476 520 || empty($apiData->clientId)
477 521 || empty($apiData->clientSecret)
@@ -507,9 +551,10 @@
507 551 * @param Obeject $tokenDetails refreshed token info
508 552 *
509 553 * @return null
510 554 */
511 - protected static function _saveRefreshedToken($formID, $integrationID, $tokenDetails, $others = null) {
555 + protected static function _saveRefreshedToken($formID, $integrationID, $tokenDetails, $others = null)
556 + {
512 557 if (empty($formID) || empty($integrationID)) {
513 558 return;
514 559 }
515 560
@@ -528,12 +573,13 @@
528 573 if (!empty($others['related_modules'])) {
529 574 $newDetails->default->relatedlist['modules'] = $others['related_modules'];
530 575 }
531 576
532 - $integrationHandler->updateIntegration($integrationID, $zrecruitDetails[0]->integration_name, 'Zoho Recruit', \json_encode($newDetails), 'form');
577 + $integrationHandler->updateIntegration($integrationID, $zrecruitDetails[0]->integration_name, 'Zoho Recruit', wp_json_encode($newDetails), 'form');
533 578 }
534 579
535 - public function execute(IntegrationHandler $integrationHandler, $integrationData, $fieldValues, $entryID, $logID) {
580 + public function execute(IntegrationHandler $integrationHandler, $integrationData, $fieldValues, $entryID, $logID)
581 + {
536 582 $integrationDetails = is_string($integrationData->integration_details) ? json_decode($integrationData->integration_details) : $integrationData->integration_details;
537 583 $tokenDetails = $integrationDetails->tokenDetails;
538 584 $module = $integrationDetails->module;
539 585 $fieldMap = $integrationDetails->field_map;