From f582cf9c0ffe43edfb354307cba0bd12ef97cbdb Mon Sep 17 00:00:00 2001 From: Fedor Date: Mon, 20 Oct 2025 17:23:20 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D0=BF=D1=83=D1=82=D0=B8=20Nextcloud=20?= =?UTF-8?q?=D1=81=20/crm2/=20=D0=BD=D0=B0=20/crm/=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=BE=D0=B3=D0=BE=20=D1=81=D0=B5=D1=80=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Обновленные файлы: - crm_extensions/nextcloud_editor/js/nextcloud-editor.js (5 путей) - crm_extensions/file_storage/api/get_edit_urls.php (6 путей) - modules/Documents/actions/NcPrepareEdit.php (2 пути) - crm_extensions/file_storage/api/prepare_edit.php (1 путь) - crm_extensions/file_storage/NextcloudClient.php (1 путь) - data/CRMEntity.php (nc_path для новых файлов) Все пути теперь используют /crm/ вместо /crm2/ для соответствия новому External Storage на office.clientright.ru --- crm_extensions/file_storage/NextcloudClient.php | 2 +- crm_extensions/file_storage/api/get_edit_urls.php | 12 ++++++------ crm_extensions/file_storage/api/prepare_edit.php | 2 +- .../nextcloud_editor/js/nextcloud-editor.js | 10 +++++----- data/CRMEntity.php | 2 +- modules/Documents/actions/NcPrepareEdit.php | 4 ++-- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/crm_extensions/file_storage/NextcloudClient.php b/crm_extensions/file_storage/NextcloudClient.php index 05da7678..5e032437 100644 --- a/crm_extensions/file_storage/NextcloudClient.php +++ b/crm_extensions/file_storage/NextcloudClient.php @@ -203,7 +203,7 @@ class NextcloudClient { if (substr($fileName, 0, 1) === '_') { $fileName = substr($fileName, 1); } - $editUrl = $this->baseUrl . '/apps/files/?dir=/crm2/CRM_Active_Files/Documents/' . $recordId . '&openfile=' . urlencode($fileName); + $editUrl = $this->baseUrl . '/apps/files/?dir=/crm/CRM_Active_Files/Documents/' . $recordId . '&openfile=' . urlencode($fileName); return [ 'success' => true, diff --git a/crm_extensions/file_storage/api/get_edit_urls.php b/crm_extensions/file_storage/api/get_edit_urls.php index 85e24cd0..3fec5d82 100644 --- a/crm_extensions/file_storage/api/get_edit_urls.php +++ b/crm_extensions/file_storage/api/get_edit_urls.php @@ -24,12 +24,12 @@ try { // Создаем различные варианты URL $urls = [ - 'direct_edit' => $baseUrl . '/apps/files/files/662?dir=/crm2/CRM_Active_Files/Documents/' . $recordId . '&openfile=' . urlencode($fileName) . '&action=edit', - 'openfile_only' => $baseUrl . '/apps/files/files/662?dir=/crm2/CRM_Active_Files/Documents/' . $recordId . '&openfile=' . urlencode($fileName), - 'edit_true' => $baseUrl . '/apps/files/files/662?dir=/crm2/CRM_Active_Files/Documents/' . $recordId . '&openfile=' . urlencode($fileName) . '&edit=true', - 'richdocuments' => $baseUrl . '/apps/richdocuments/open?path=/crm2/CRM_Active_Files/Documents/' . $recordId . '/' . urlencode($fileName), - 'onlyoffice' => $baseUrl . '/apps/onlyoffice/open?path=/crm2/CRM_Active_Files/Documents/' . $recordId . '/' . urlencode($fileName), - 'files_app' => $baseUrl . '/apps/files/?dir=/crm2/CRM_Active_Files/Documents/' . $recordId . '&openfile=' . urlencode($fileName) . '&action=edit' + 'direct_edit' => $baseUrl . '/apps/files/files/662?dir=/crm/CRM_Active_Files/Documents/' . $recordId . '&openfile=' . urlencode($fileName) . '&action=edit', + 'openfile_only' => $baseUrl . '/apps/files/files/662?dir=/crm/CRM_Active_Files/Documents/' . $recordId . '&openfile=' . urlencode($fileName), + 'edit_true' => $baseUrl . '/apps/files/files/662?dir=/crm/CRM_Active_Files/Documents/' . $recordId . '&openfile=' . urlencode($fileName) . '&edit=true', + 'richdocuments' => $baseUrl . '/apps/richdocuments/open?path=/crm/CRM_Active_Files/Documents/' . $recordId . '/' . urlencode($fileName), + 'onlyoffice' => $baseUrl . '/apps/onlyoffice/open?path=/crm/CRM_Active_Files/Documents/' . $recordId . '/' . urlencode($fileName), + 'files_app' => $baseUrl . '/apps/files/?dir=/crm/CRM_Active_Files/Documents/' . $recordId . '&openfile=' . urlencode($fileName) . '&action=edit' ]; echo json_encode([ diff --git a/crm_extensions/file_storage/api/prepare_edit.php b/crm_extensions/file_storage/api/prepare_edit.php index ada63d96..40f9247a 100644 --- a/crm_extensions/file_storage/api/prepare_edit.php +++ b/crm_extensions/file_storage/api/prepare_edit.php @@ -72,7 +72,7 @@ try { if (substr($actualFileName, 0, 1) === '_') { $actualFileName = substr($actualFileName, 1); } - $nextcloudPath = '/crm2/CRM_Active_Files/Documents/' . $recordId . '/' . $actualFileName; + $nextcloudPath = '/crm/CRM_Active_Files/Documents/' . $recordId . '/' . $actualFileName; // Проверяем, существует ли файл в Nextcloud $fileExists = $nextcloudClient->fileExists($nextcloudPath); diff --git a/crm_extensions/nextcloud_editor/js/nextcloud-editor.js b/crm_extensions/nextcloud_editor/js/nextcloud-editor.js index cdabcc29..8f8936f3 100644 --- a/crm_extensions/nextcloud_editor/js/nextcloud-editor.js +++ b/crm_extensions/nextcloud_editor/js/nextcloud-editor.js @@ -78,17 +78,17 @@ function createEditUrls(baseEditUrl, recordId, fileName, fileId = 662) { // Извлекаем базовый URL из базовой ссылки const baseUrl = 'https://office.clientright.ru'; const encodedFileName = encodeURIComponent(fileName); - const filePath = `/crm2/CRM_Active_Files/Documents/${recordId}/${encodedFileName}`; + const filePath = `/crm/CRM_Active_Files/Documents/${recordId}/${encodedFileName}`; const urls = { - 'correct_path': fileId ? `${baseUrl}/apps/files/files/${fileId}?dir=/crm2/CRM_Active_Files/Documents/${recordId}&editing=false&openfile=true` : `${baseUrl}/apps/files/?dir=/crm2/CRM_Active_Files/Documents/${recordId}&openfile=${encodedFileName}`, + 'correct_path': fileId ? `${baseUrl}/apps/files/files/${fileId}?dir=/crm/CRM_Active_Files/Documents/${recordId}&editing=false&openfile=true` : `${baseUrl}/apps/files/?dir=/crm/CRM_Active_Files/Documents/${recordId}&openfile=${encodedFileName}`, 'collabora_path': `${baseUrl}/apps/richdocuments/open?path=${filePath}`, 'onlyoffice_path': `${baseUrl}/apps/onlyoffice/open?path=${filePath}`, - 'files_manager': `${baseUrl}/apps/files/?dir=/crm2/CRM_Active_Files/Documents/${recordId}&openfile=${encodedFileName}`, + 'files_manager': `${baseUrl}/apps/files/?dir=/crm/CRM_Active_Files/Documents/${recordId}&openfile=${encodedFileName}`, 'collabora_id': fileId ? `${baseUrl}/apps/richdocuments/index?fileId=${fileId}` : null, 'onlyoffice_id': fileId ? `${baseUrl}/apps/onlyoffice?fileId=${fileId}` : null, - 'files_app': `${baseUrl}/apps/files/?dir=/crm2/CRM_Active_Files/Documents/${recordId}&openfile=${encodedFileName}&action=edit`, - 'simple_files': `${baseUrl}/apps/files/?dir=/crm2/CRM_Active_Files/Documents/${recordId}` + 'files_app': `${baseUrl}/apps/files/?dir=/crm/CRM_Active_Files/Documents/${recordId}&openfile=${encodedFileName}&action=edit`, + 'simple_files': `${baseUrl}/apps/files/?dir=/crm/CRM_Active_Files/Documents/${recordId}` }; // Убираем null значения diff --git a/data/CRMEntity.php b/data/CRMEntity.php index f76fe37d..94e7da9b 100644 --- a/data/CRMEntity.php +++ b/data/CRMEntity.php @@ -390,7 +390,7 @@ class CRMEntity { ? $s3_metadata['url'] : ('https://'.$s3_metadata['bucket'].'/'.$s3_metadata['key']); // Исправляем nc_path - добавляем дублирование crm2 для Nextcloud - $nc_path = '/crm2/' . $s3_metadata['key']; + $nc_path = '/crm/' . $s3_metadata['key']; $sql4 = "UPDATE vtiger_notes SET filename=?, filelocationtype='E', filesize=?, s3_bucket=?, s3_key=?, s3_etag=?, nc_path=? WHERE notesid=?"; $params4 = array(strip_tags(trim($s3_url)), $s3_metadata['size'], $s3_metadata['bucket'], $s3_metadata['key'], $s3_metadata['etag'], $nc_path, $current_id); $result4 = $adb->pquery($sql4, $params4); diff --git a/modules/Documents/actions/NcPrepareEdit.php b/modules/Documents/actions/NcPrepareEdit.php index 13c04e08..4909eb61 100644 --- a/modules/Documents/actions/NcPrepareEdit.php +++ b/modules/Documents/actions/NcPrepareEdit.php @@ -81,7 +81,7 @@ class Documents_NcPrepareEdit_Action extends Vtiger_Action_Controller { * Получение пути к директории */ private function getDirPath($recordId): string { - return '/crm2/CRM_Active_Files/Documents/' . $recordId; + return '/crm/CRM_Active_Files/Documents/' . $recordId; } /** @@ -131,7 +131,7 @@ class Documents_NcPrepareEdit_Action extends Vtiger_Action_Controller { * Получение пути к файлу в Nextcloud */ private function getNcPath(int $recordId, string $fileName): string { - return "/crm2/CRM_Active_Files/Documents/{$recordId}/" . rawurlencode($fileName); + return "/crm/CRM_Active_Files/Documents/{$recordId}/" . rawurlencode($fileName); } /**