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
V3.3.2 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 All 139 releases
← All changes | includes/Core/Integration/ZohoBigin/FilesApiHelper.php +20 -2 2.10.0 → 3.3.1 View file →
@@ -6,8 +6,9 @@
6 6 */
7 7
8 8 namespace BitCode\BitForm\Core\Integration\ZohoBigin;
9 9
10 +use BitCode\BitForm\Core\Util\FileHandler;
10 11 use BitCode\BitForm\Core\Util\HttpHelper;
11 12
12 13 /**
13 14 * Provide functionality for Upload files
@@ -30,9 +31,9 @@
30 31 $this->_payloadBoundary = wp_generate_password(24);
31 32 $this->_defaultHeader['Authorization'] = "Zoho-oauthtoken {$tokenDetails->access_token}";
32 33 $this->_defaultHeader['content-type'] = 'multipart/form; boundary=' . $this->_payloadBoundary;
33 34 $this->_apiDomain = \urldecode($tokenDetails->api_domain);
34 - $this->_basepath = BITFORMS_UPLOAD_DIR . DIRECTORY_SEPARATOR . $formID . DIRECTORY_SEPARATOR . $entryID . DIRECTORY_SEPARATOR;
35 + $this->_basepath = FileHandler::getEntriesFileUploadDir($formID, $entryID) . DIRECTORY_SEPARATOR;
35 36 }
36 37
37 38 /**
38 39 * Helps to execute upload files api
@@ -44,8 +45,9 @@
44 45 * @return mixed $uploadedFiles ID's of uploaded file in Zoho Bigin
45 46 */
46 47 public function uploadFiles($files, $module, $recordID, $isPhoto = null)
47 48 {
49 + $files = self::normalizeFileNames($files);
48 50 $uploadFileEndpoint = '';
49 51
50 52 if ($isPhoto) {
51 53 $uploadFileEndpoint = "https://www.zohoapis.com/bigin/v1/{$module}/{$recordID}/photo";
@@ -81,5 +83,21 @@
81 83 $payload .= '--' . $this->_payloadBoundary . '--';
82 84
83 85 return HttpHelper::post($uploadFileEndpoint, $payload, $this->_defaultHeader);
84 86 }
85 -}
87 +
88 + /**
89 + * Field values may arrive as public file URLs (see IntegrationHandler::handleFileUrl),
90 + * so reduce each to the stored file name before resolving against the entry directory.
91 + *
92 + * @param mixed $files file name(s) or URL(s)
93 + *
94 + * @return mixed
95 + */
96 + private static function normalizeFileNames($files)
97 + {
98 + if (is_array($files)) {
99 + return array_map([__CLASS__, 'normalizeFileNames'], $files);
100 + }
101 + return is_string($files) ? basename(wp_parse_url($files, PHP_URL_PATH) ?: $files) : $files;
102 + }
103 +}