From 1a385052f6e66436784a40d286dc609a7febfa30 Mon Sep 17 00:00:00 2001 From: kastoras Date: Fri, 7 May 2021 23:39:14 +0300 Subject: [PATCH 1/7] New Create share link on file upload Create MAIN_CREATE_SHARE_ON_FILE_UPLOAD, when this set to 1 and a file is uploaded a shared link will be created --- htdocs/core/lib/files.lib.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index ce5e7129bcf..1a52102d61d 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1766,7 +1766,7 @@ function dol_remove_file_process($filenb, $donotupdatesession = 0, $donotdeletef */ function addFileIntoDatabaseIndex($dir, $file, $fullpathorig = '', $mode = 'uploaded', $setsharekey = 0, $object = null) { - global $db, $user; + global $db, $user, $conf; $result = 0; @@ -1792,6 +1792,9 @@ function addFileIntoDatabaseIndex($dir, $file, $fullpathorig = '', $mode = 'uplo $ecmfile->src_object_type = $object->table_element; } + if(!empty($conf->global->MAIN_CREATE_SHARE_ON_FILE_UPLOAD) && $conf->global->MAIN_CREATE_SHARE_ON_FILE_UPLOAD=='1'){ + $setsharekey = 1; + } if ($setsharekey) { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $ecmfile->share = getRandomPassword(true); From fc26e5eecfd6faff7dcf9509db1dd1b9597222f2 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 7 May 2021 20:42:53 +0000 Subject: [PATCH 2/7] Fixing style errors. --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 1a52102d61d..9bf520d56b5 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1792,7 +1792,7 @@ function addFileIntoDatabaseIndex($dir, $file, $fullpathorig = '', $mode = 'uplo $ecmfile->src_object_type = $object->table_element; } - if(!empty($conf->global->MAIN_CREATE_SHARE_ON_FILE_UPLOAD) && $conf->global->MAIN_CREATE_SHARE_ON_FILE_UPLOAD=='1'){ + if (!empty($conf->global->MAIN_CREATE_SHARE_ON_FILE_UPLOAD) && $conf->global->MAIN_CREATE_SHARE_ON_FILE_UPLOAD=='1') { $setsharekey = 1; } if ($setsharekey) { From 76c10f053abeeab7baf8203048cc05e016a87b17 Mon Sep 17 00:00:00 2001 From: kastoras Date: Tue, 11 May 2021 22:29:07 +0300 Subject: [PATCH 3/7] Change parameter name to MAIN_FORCE_SHARING_ON_ANY_UPLOADED_FILE --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 1a52102d61d..4232eb78b40 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1792,7 +1792,7 @@ function addFileIntoDatabaseIndex($dir, $file, $fullpathorig = '', $mode = 'uplo $ecmfile->src_object_type = $object->table_element; } - if(!empty($conf->global->MAIN_CREATE_SHARE_ON_FILE_UPLOAD) && $conf->global->MAIN_CREATE_SHARE_ON_FILE_UPLOAD=='1'){ + if(!empty($conf->global->MAIN_FORCE_SHARING_ON_ANY_UPLOADED_FILE) && $conf->global->MAIN_FORCE_SHARING_ON_ANY_UPLOADED_FILE=='1'){ $setsharekey = 1; } if ($setsharekey) { From cd9ea9566b5d27bff62a515efec1329447c0a55c Mon Sep 17 00:00:00 2001 From: kastoras Date: Tue, 11 May 2021 22:31:38 +0300 Subject: [PATCH 4/7] Change parameter name to MAIN_FORCE_SHARING_ON_ANY_UPLOADED_FILE --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 9bf520d56b5..4232eb78b40 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1792,7 +1792,7 @@ function addFileIntoDatabaseIndex($dir, $file, $fullpathorig = '', $mode = 'uplo $ecmfile->src_object_type = $object->table_element; } - if (!empty($conf->global->MAIN_CREATE_SHARE_ON_FILE_UPLOAD) && $conf->global->MAIN_CREATE_SHARE_ON_FILE_UPLOAD=='1') { + if(!empty($conf->global->MAIN_FORCE_SHARING_ON_ANY_UPLOADED_FILE) && $conf->global->MAIN_FORCE_SHARING_ON_ANY_UPLOADED_FILE=='1'){ $setsharekey = 1; } if ($setsharekey) { From b8a3485c4cd73f113c5b011e7faa4b6d37078329 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 11 May 2021 19:33:23 +0000 Subject: [PATCH 5/7] Fixing style errors. --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 4232eb78b40..7ee3dbee46f 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1792,7 +1792,7 @@ function addFileIntoDatabaseIndex($dir, $file, $fullpathorig = '', $mode = 'uplo $ecmfile->src_object_type = $object->table_element; } - if(!empty($conf->global->MAIN_FORCE_SHARING_ON_ANY_UPLOADED_FILE) && $conf->global->MAIN_FORCE_SHARING_ON_ANY_UPLOADED_FILE=='1'){ + if (!empty($conf->global->MAIN_FORCE_SHARING_ON_ANY_UPLOADED_FILE) && $conf->global->MAIN_FORCE_SHARING_ON_ANY_UPLOADED_FILE=='1') { $setsharekey = 1; } if ($setsharekey) { From 659f24efa9be2059d21bbd73dffb39e6fa58c642 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 17 Aug 2021 20:10:47 +0200 Subject: [PATCH 6/7] Update files.lib.php --- htdocs/core/lib/files.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 7ee3dbee46f..4d2da5217b6 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1792,9 +1792,10 @@ function addFileIntoDatabaseIndex($dir, $file, $fullpathorig = '', $mode = 'uplo $ecmfile->src_object_type = $object->table_element; } - if (!empty($conf->global->MAIN_FORCE_SHARING_ON_ANY_UPLOADED_FILE) && $conf->global->MAIN_FORCE_SHARING_ON_ANY_UPLOADED_FILE=='1') { + if (!empty($conf->global->MAIN_FORCE_SHARING_ON_ANY_UPLOADED_FILE)) { $setsharekey = 1; } + if ($setsharekey) { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $ecmfile->share = getRandomPassword(true); From 5d0318c98f8225675dce953a8d2c662e665c9366 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 17 Aug 2021 18:11:12 +0000 Subject: [PATCH 7/7] Fixing style errors. --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 4d2da5217b6..be5f793974b 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1795,7 +1795,7 @@ function addFileIntoDatabaseIndex($dir, $file, $fullpathorig = '', $mode = 'uplo if (!empty($conf->global->MAIN_FORCE_SHARING_ON_ANY_UPLOADED_FILE)) { $setsharekey = 1; } - + if ($setsharekey) { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $ecmfile->share = getRandomPassword(true);