← All changes
|
includes/Core/Integration/ZohoProjects/FilesApiHelper.php
+2
-20
3.3.1
→
2.15.3
View file →
| @@ -6,9 +6,8 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace BitCode\BitForm\Core\Integration\ZohoProjects; |
| 9 | 9 | |
| 10 | -use BitCode\BitForm\Core\Util\FileHandler; | |
| 11 | 10 | use BitCode\BitForm\Core\Util\HttpHelper; |
| 12 | 11 | |
| 13 | 12 | /** |
| 14 | 13 | * Provide functionality for Upload files |
| @@ -31,9 +30,9 @@ | ||
| 31 | 30 | $this->_payloadBoundary = wp_generate_password(24); |
| 32 | 31 | $this->_defaultHeader['Authorization'] = "Zoho-oauthtoken {$tokenDetails->access_token}"; |
| 33 | 32 | $this->_defaultHeader['content-type'] = 'multipart/form-data; boundary=' . $this->_payloadBoundary; |
| 34 | 33 | $this->_apiDomain = \urldecode($tokenDetails->api_domain); |
| 35 | - $this->_basepath = FileHandler::getEntriesFileUploadDir($formID, $entryID) . DIRECTORY_SEPARATOR; | |
| 34 | + $this->_basepath = BITFORMS_UPLOAD_DIR . DIRECTORY_SEPARATOR . $formID . DIRECTORY_SEPARATOR . $entryID . DIRECTORY_SEPARATOR; | |
| 36 | 35 | } |
| 37 | 36 | |
| 38 | 37 | /** |
| 39 | 38 | * Helps to execute upload files api |
| @@ -46,10 +45,9 @@ | ||
| 46 | 45 | * @return mixed $uploadedFiles ID's of uploaded file in Zoho Projects |
| 47 | 46 | */ |
| 48 | 47 | public function uploadFiles($files, $portalId, $projectId, $event, $eventId, $dataCenter) |
| 49 | 48 | { |
| 50 | - $files = self::normalizeFileNames($files); | |
| 51 | - $uploadFileEndpoint = "https://projectsapi.zoho.{$dataCenter}/restapi/portal/{$portalId}/projects/{$projectId}/" . ('task' === $event || 'subtask' === $event ? 'tasks' : 'bugs') . "/{$eventId}/attachments/"; | |
| 49 | + $uploadFileEndpoint = "https://projectsapi.zoho.{$dataCenter}/restapi/portal/{$portalId}/projects/{$projectId}/" . ('task' === $event || 'subtask' === $event ? 'tasks' : 'bugs') . "/${eventId}/attachments/"; | |
| 52 | 50 | |
| 53 | 51 | $payload = ''; |
| 54 | 52 | if (is_array($files)) { |
| 55 | 53 | foreach ($files as $fileIndex => $fileName) { |
| @@ -79,22 +77,6 @@ | ||
| 79 | 77 | $payload .= '--' . $this->_payloadBoundary . '--'; |
| 80 | 78 | $uploadResponse = HttpHelper::post($uploadFileEndpoint, $payload, $this->_defaultHeader); |
| 81 | 79 | |
| 82 | 80 | return $uploadResponse; |
| 83 | - } | |
| 84 | - | |
| 85 | - /** | |
| 86 | - * Field values may arrive as public file URLs (see IntegrationHandler::handleFileUrl), | |
| 87 | - * so reduce each to the stored file name before resolving against the entry directory. | |
| 88 | - * | |
| 89 | - * @param mixed $files file name(s) or URL(s) | |
| 90 | - * | |
| 91 | - * @return mixed | |
| 92 | - */ | |
| 93 | - private static function normalizeFileNames($files) | |
| 94 | - { | |
| 95 | - if (is_array($files)) { | |
| 96 | - return array_map([__CLASS__, 'normalizeFileNames'], $files); | |
| 97 | - } | |
| 98 | - return is_string($files) ? basename(wp_parse_url($files, PHP_URL_PATH) ?: $files) : $files; | |
| 99 | 81 | } |
| 100 | 82 | } |