Merge pull request #21351 from Quatadah/dolicloud-qnasdami-product-allow-external-download

NEW #19680 Add option PRODUCT_ALLOW_EXTERNAL_DOWNLOAD
This commit is contained in:
Laurent Destailleur 2022-07-06 15:52:19 +02:00 committed by GitHub
commit 55ba95643b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -5569,6 +5569,9 @@ abstract class CommonObject
if ($this->element == 'bank_account' && !empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) {
$setsharekey = true;
}
if ($this->element == 'product' && !empty($conf->global->PRODUCT_ALLOW_EXTERNAL_DOWNLOAD)) {
$setsharekey = true;
}
if ($this->element == 'contrat' && !empty($conf->global->CONTRACT_ALLOW_EXTERNAL_DOWNLOAD)) {
$setsharekey = true;
}

View File

@ -1717,7 +1717,9 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess
// Update index table of files (llx_ecm_files)
if ($donotupdatesession == 1) {
$result = addFileIntoDatabaseIndex($upload_dir, basename($destfile).($resupload == 2 ? '.noexe' : ''), $TFile['name'][$i], 'uploaded', 0, $object);
$sharefile = 0;
if ($TFile['type'][$i] == 'application/pdf' && strpos($_SERVER["REQUEST_URI"], 'product') !== false && !empty($conf->global->PRODUCT_ALLOW_EXTERNAL_DOWNLOAD)) $sharefile = 1;
$result = addFileIntoDatabaseIndex($upload_dir, basename($destfile).($resupload == 2 ? '.noexe' : ''), $TFile['name'][$i], 'uploaded', $sharefile, $object);
if ($result < 0) {
if ($allowoverwrite) {
// Do not show error message. We can have an error due to DB_ERROR_RECORD_ALREADY_EXISTS