← All changes
|
includes/Core/Integration/ZohoProjects/ZohoProjectsHandler.php
+33
-104
3.3.1
→
2.15.3
View file →
| @@ -6,17 +6,11 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace BitCode\BitForm\Core\Integration\ZohoProjects; |
| 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\HttpHelper; |
| 16 | 12 | use BitCode\BitForm\Core\Util\IpTool; |
| 17 | -use BitCode\BitForm\GlobalHelper; | |
| 18 | -use WP_Error; | |
| 19 | 13 | |
| 20 | 14 | /** |
| 21 | 15 | * Provide functionality for ZohoCrm integration |
| 22 | 16 | */ |
| @@ -57,17 +51,11 @@ | ||
| 57 | 51 | * @return string zoho crm api response and status |
| 58 | 52 | */ |
| 59 | 53 | public static function generateTokens() |
| 60 | 54 | { |
| 61 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 62 | - GlobalHelper::requirePostMethod(); | |
| 63 | - | |
| 64 | - try { | |
| 65 | - $requestsParams = GlobalHelper::formatRequestData(); | |
| 66 | - } catch (\InvalidArgumentException $e) { | |
| 67 | - wp_send_json_error($e->getMessage(), 400); | |
| 68 | - } | |
| 69 | - | |
| 55 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 56 | + $inputJSON = file_get_contents('php://input'); | |
| 57 | + $requestsParams = json_decode($inputJSON); | |
| 70 | 58 | if ( |
| 71 | 59 | empty($requestsParams->{'accounts-server'}) |
| 72 | 60 | || empty($requestsParams->dataCenter) |
| 73 | 61 | || empty($requestsParams->clientId) |
| @@ -115,17 +103,11 @@ | ||
| 115 | 103 | |
| 116 | 104 | public static function refreshPortalsAjaxHelper() |
| 117 | 105 | { |
| 118 | 106 | $authorizationHeader = null; |
| 119 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 120 | - GlobalHelper::requirePostMethod(); | |
| 121 | - | |
| 122 | - try { | |
| 123 | - $queryParams = GlobalHelper::formatRequestData(); | |
| 124 | - } catch (\InvalidArgumentException $e) { | |
| 125 | - wp_send_json_error($e->getMessage(), 400); | |
| 126 | - } | |
| 127 | - | |
| 107 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 108 | + $inputJSON = file_get_contents('php://input'); | |
| 109 | + $queryParams = json_decode($inputJSON); | |
| 128 | 110 | if ( |
| 129 | 111 | empty($queryParams->tokenDetails) |
| 130 | 112 | || empty($queryParams->dataCenter) |
| 131 | 113 | || empty($queryParams->clientId) |
| @@ -186,17 +168,11 @@ | ||
| 186 | 168 | |
| 187 | 169 | public static function refreshProjectsAjaxHelper() |
| 188 | 170 | { |
| 189 | 171 | $authorizationHeader = null; |
| 190 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 191 | - GlobalHelper::requirePostMethod(); | |
| 192 | - | |
| 193 | - try { | |
| 194 | - $queryParams = GlobalHelper::formatRequestData(); | |
| 195 | - } catch (\InvalidArgumentException $e) { | |
| 196 | - wp_send_json_error($e->getMessage(), 400); | |
| 197 | - } | |
| 198 | - | |
| 172 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 173 | + $inputJSON = file_get_contents('php://input'); | |
| 174 | + $queryParams = json_decode($inputJSON); | |
| 199 | 175 | if ( |
| 200 | 176 | empty($queryParams->tokenDetails) |
| 201 | 177 | || empty($queryParams->dataCenter) |
| 202 | 178 | || empty($queryParams->clientId) |
| @@ -260,17 +236,11 @@ | ||
| 260 | 236 | |
| 261 | 237 | public static function refreshMilestonesAjaxHelper() |
| 262 | 238 | { |
| 263 | 239 | $authorizationHeader = null; |
| 264 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 265 | - GlobalHelper::requirePostMethod(); | |
| 266 | - | |
| 267 | - try { | |
| 268 | - $queryParams = GlobalHelper::formatRequestData(); | |
| 269 | - } catch (\InvalidArgumentException $e) { | |
| 270 | - wp_send_json_error($e->getMessage(), 400); | |
| 271 | - } | |
| 272 | - | |
| 240 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 241 | + $inputJSON = file_get_contents('php://input'); | |
| 242 | + $queryParams = json_decode($inputJSON); | |
| 273 | 243 | if ( |
| 274 | 244 | empty($queryParams->tokenDetails) |
| 275 | 245 | || empty($queryParams->dataCenter) |
| 276 | 246 | || empty($queryParams->clientId) |
| @@ -333,17 +303,11 @@ | ||
| 333 | 303 | |
| 334 | 304 | public static function refreshTasklistsAjaxHelper() |
| 335 | 305 | { |
| 336 | 306 | $authorizationHeader = null; |
| 337 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 338 | - GlobalHelper::requirePostMethod(); | |
| 339 | - | |
| 340 | - try { | |
| 341 | - $queryParams = GlobalHelper::formatRequestData(); | |
| 342 | - } catch (\InvalidArgumentException $e) { | |
| 343 | - wp_send_json_error($e->getMessage(), 400); | |
| 344 | - } | |
| 345 | - | |
| 307 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 308 | + $inputJSON = file_get_contents('php://input'); | |
| 309 | + $queryParams = json_decode($inputJSON); | |
| 346 | 310 | if ( |
| 347 | 311 | empty($queryParams->tokenDetails) |
| 348 | 312 | || empty($queryParams->dataCenter) |
| 349 | 313 | || empty($queryParams->clientId) |
| @@ -411,17 +375,11 @@ | ||
| 411 | 375 | |
| 412 | 376 | public static function refreshTasksAjaxHelper() |
| 413 | 377 | { |
| 414 | 378 | $authorizationHeader = null; |
| 415 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 416 | - GlobalHelper::requirePostMethod(); | |
| 417 | - | |
| 418 | - try { | |
| 419 | - $queryParams = GlobalHelper::formatRequestData(); | |
| 420 | - } catch (\InvalidArgumentException $e) { | |
| 421 | - wp_send_json_error($e->getMessage(), 400); | |
| 422 | - } | |
| 423 | - | |
| 379 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 380 | + $inputJSON = file_get_contents('php://input'); | |
| 381 | + $queryParams = json_decode($inputJSON); | |
| 424 | 382 | if ( |
| 425 | 383 | empty($queryParams->tokenDetails) |
| 426 | 384 | || empty($queryParams->dataCenter) |
| 427 | 385 | || empty($queryParams->clientId) |
| @@ -490,17 +448,11 @@ | ||
| 490 | 448 | } |
| 491 | 449 | |
| 492 | 450 | public static function refreshFieldsAjaxHelper() |
| 493 | 451 | { |
| 494 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 495 | - GlobalHelper::requirePostMethod(); | |
| 496 | - | |
| 497 | - try { | |
| 498 | - $queryParams = GlobalHelper::formatRequestData(); | |
| 499 | - } catch (\InvalidArgumentException $e) { | |
| 500 | - wp_send_json_error($e->getMessage(), 400); | |
| 501 | - } | |
| 502 | - | |
| 452 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 453 | + $inputJSON = file_get_contents('php://input'); | |
| 454 | + $queryParams = json_decode($inputJSON); | |
| 503 | 455 | if ( |
| 504 | 456 | empty($queryParams->tokenDetails) |
| 505 | 457 | || empty($queryParams->dataCenter) |
| 506 | 458 | || empty($queryParams->clientId) |
| @@ -837,17 +789,11 @@ | ||
| 837 | 789 | |
| 838 | 790 | public static function refreshUsersAjaxHelper() |
| 839 | 791 | { |
| 840 | 792 | $authorizationHeader = null; |
| 841 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 842 | - GlobalHelper::requirePostMethod(); | |
| 843 | - | |
| 844 | - try { | |
| 845 | - $queryParams = GlobalHelper::formatRequestData(); | |
| 846 | - } catch (\InvalidArgumentException $e) { | |
| 847 | - wp_send_json_error($e->getMessage(), 400); | |
| 848 | - } | |
| 849 | - | |
| 793 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 794 | + $inputJSON = file_get_contents('php://input'); | |
| 795 | + $queryParams = json_decode($inputJSON); | |
| 850 | 796 | if ( |
| 851 | 797 | empty($queryParams->tokenDetails) |
| 852 | 798 | || empty($queryParams->dataCenter) |
| 853 | 799 | || empty($queryParams->clientId) |
| @@ -915,17 +861,11 @@ | ||
| 915 | 861 | |
| 916 | 862 | public static function refreshTaskLaysAjaxHelper() |
| 917 | 863 | { |
| 918 | 864 | $authorizationHeader = null; |
| 919 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 920 | - GlobalHelper::requirePostMethod(); | |
| 921 | - | |
| 922 | - try { | |
| 923 | - $queryParams = GlobalHelper::formatRequestData(); | |
| 924 | - } catch (\InvalidArgumentException $e) { | |
| 925 | - wp_send_json_error($e->getMessage(), 400); | |
| 926 | - } | |
| 927 | - | |
| 865 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 866 | + $inputJSON = file_get_contents('php://input'); | |
| 867 | + $queryParams = json_decode($inputJSON); | |
| 928 | 868 | if ( |
| 929 | 869 | empty($queryParams->tokenDetails) |
| 930 | 870 | || empty($queryParams->dataCenter) |
| 931 | 871 | || empty($queryParams->clientId) |
| @@ -986,16 +926,11 @@ | ||
| 986 | 926 | |
| 987 | 927 | public static function refreshGroupsAjaxHelper() |
| 988 | 928 | { |
| 989 | 929 | $authorizationHeader = null; |
| 990 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 991 | - GlobalHelper::requirePostMethod(); | |
| 992 | - | |
| 993 | - try { | |
| 994 | - $queryParams = GlobalHelper::formatRequestData(); | |
| 995 | - } catch (\InvalidArgumentException $e) { | |
| 996 | - wp_send_json_error($e->getMessage(), 400); | |
| 997 | - } | |
| 930 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 931 | + $inputJSON = file_get_contents('php://input'); | |
| 932 | + $queryParams = json_decode($inputJSON); | |
| 998 | 933 | if ( |
| 999 | 934 | empty($queryParams->tokenDetails) |
| 1000 | 935 | || empty($queryParams->dataCenter) |
| 1001 | 936 | || empty($queryParams->clientId) |
| @@ -1056,17 +991,11 @@ | ||
| 1056 | 991 | |
| 1057 | 992 | public static function refreshTagsAjaxHelper() |
| 1058 | 993 | { |
| 1059 | 994 | $authorizationHeader = null; |
| 1060 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 1061 | - GlobalHelper::requirePostMethod(); | |
| 1062 | - | |
| 1063 | - try { | |
| 1064 | - $queryParams = GlobalHelper::formatRequestData(); | |
| 1065 | - } catch (\InvalidArgumentException $e) { | |
| 1066 | - wp_send_json_error($e->getMessage(), 400); | |
| 1067 | - } | |
| 1068 | - | |
| 995 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 996 | + $inputJSON = file_get_contents('php://input'); | |
| 997 | + $queryParams = json_decode($inputJSON); | |
| 1069 | 998 | if ( |
| 1070 | 999 | empty($queryParams->tokenDetails) |
| 1071 | 1000 | || empty($queryParams->dataCenter) |
| 1072 | 1001 | || empty($queryParams->clientId) |