← All changes
|
includes/Core/Integration/ZohoMail/ZohoMailHandler.php
+20
-13
2.0
→
2.15.3
View file →
| @@ -14,13 +14,15 @@ | ||
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * Provide functionality for ZohoCrm integration |
| 17 | 17 | */ |
| 18 | -class ZohoMailHandler { | |
| 18 | +class ZohoMailHandler | |
| 19 | +{ | |
| 19 | 20 | private $_formID; |
| 20 | 21 | private $_integrationID; |
| 21 | 22 | |
| 22 | - public function __construct($integrationID, $fromID) { | |
| 23 | + public function __construct($integrationID, $fromID) | |
| 24 | + { | |
| 23 | 25 | $this->_formID = $fromID; |
| 24 | 26 | $this->_integrationID = $integrationID; |
| 25 | 27 | } |
| 26 | 28 | |
| @@ -28,9 +30,10 @@ | ||
| 28 | 30 | * Helps to register ajax function's with wp |
| 29 | 31 | * |
| 30 | 32 | * @return null |
| 31 | 33 | */ |
| 32 | - public static function registerAjax() { | |
| 34 | + public static function registerAjax() | |
| 35 | + { | |
| 33 | 36 | add_action('wp_ajax_bitforms_zmail_generate_token', [__CLASS__, 'generateTokens']); |
| 34 | 37 | add_action('wp_ajax_bitforms_zmail_refresh_workspaces', [__CLASS__, 'refreshWorkspacesAjaxHelper']); |
| 35 | 38 | add_action('wp_ajax_bitforms_zmail_refresh_tables', [__CLASS__, 'refreshTablesAjaxHelper']); |
| 36 | 39 | add_action('wp_ajax_bitforms_zmail_refresh_table_headers', [__CLASS__, 'refreshTableHeadersAjaxHelper']); |
| @@ -40,9 +43,10 @@ | ||
| 40 | 43 | * Process ajax request for generate_token |
| 41 | 44 | * |
| 42 | 45 | * @return JSON zoho crm api response and status |
| 43 | 46 | */ |
| 44 | - public static function generateTokens() { | |
| 47 | + public static function generateTokens() | |
| 48 | + { | |
| 45 | 49 | if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { |
| 46 | 50 | $authorizationHeader = null; |
| 47 | 51 | $inputJSON = file_get_contents('php://input'); |
| 48 | 52 | $requestsParams = json_decode($inputJSON); |
| @@ -101,12 +105,13 @@ | ||
| 101 | 105 | |
| 102 | 106 | /** |
| 103 | 107 | * Helps to refresh zoho crm access_token |
| 104 | 108 | * |
| 105 | - * @param Array $apiData Contains required data for refresh access token | |
| 106 | - * @return JSON $tokenDetails API token details | |
| 109 | + * @param object $apiData Contains required data for refresh access token | |
| 110 | + * @return string|boolean $tokenDetails API token details | |
| 107 | 111 | */ |
| 108 | - protected static function _refreshAccessToken($apiData) { | |
| 112 | + protected static function _refreshAccessToken($apiData) | |
| 113 | + { | |
| 109 | 114 | if ( |
| 110 | 115 | empty($apiData->dataCenter) |
| 111 | 116 | || empty($apiData->clientId) |
| 112 | 117 | || empty($apiData->clientSecret) |
| @@ -136,15 +141,16 @@ | ||
| 136 | 141 | |
| 137 | 142 | /** |
| 138 | 143 | * Save updated access_token to avoid unnecessary token generation |
| 139 | 144 | * |
| 140 | - * @param Integer $fromID ID of Integration related form | |
| 141 | - * @param Integer $integrationID ID of Zoho crm Integration | |
| 142 | - * @param Obeject $tokenDetails refreshed token info | |
| 145 | + * @param integer $fromID ID of Integration related form | |
| 146 | + * @param integer $integrationID ID of Zoho crm Integration | |
| 147 | + * @param object $tokenDetails refreshed token info | |
| 143 | 148 | * |
| 144 | 149 | * @return null |
| 145 | 150 | */ |
| 146 | - protected static function _saveRefreshedToken($formID, $integrationID, $tokenDetails, $others = null) { | |
| 151 | + protected static function _saveRefreshedToken($formID, $integrationID, $tokenDetails, $others = null) | |
| 152 | + { | |
| 147 | 153 | if (empty($formID) || empty($integrationID)) { |
| 148 | 154 | return; |
| 149 | 155 | } |
| 150 | 156 | |
| @@ -157,12 +163,13 @@ | ||
| 157 | 163 | $newDetails = json_decode($zmailDetails[0]->integration_details); |
| 158 | 164 | |
| 159 | 165 | $newDetails->tokenDetails = $tokenDetails; |
| 160 | 166 | |
| 161 | - $integrationHandler->updateIntegration($integrationID, $zmailDetails[0]->integration_name, 'Zoho Mail', \json_encode($newDetails), 'form'); | |
| 167 | + $integrationHandler->updateIntegration($integrationID, $zmailDetails[0]->integration_name, 'Zoho Mail', wp_json_encode($newDetails), 'form'); | |
| 162 | 168 | } |
| 163 | 169 | |
| 164 | - public function execute(IntegrationHandler $integrationHandler, $integrationData, $fieldValues, $entryID, $logID) { | |
| 170 | + public function execute(IntegrationHandler $integrationHandler, $integrationData, $fieldValues, $entryID, $logID) | |
| 171 | + { | |
| 165 | 172 | $integrationDetails = is_string($integrationData->integration_details) ? json_decode($integrationData->integration_details) : $integrationData->integration_details; |
| 166 | 173 | |
| 167 | 174 | $tokenDetails = $integrationDetails->tokenDetails; |
| 168 | 175 | |