From 8e8db387979c74900df919ee17024b892719e80d Mon Sep 17 00:00:00 2001 From: LAURIER Alexis <19586755+AlexisLaurier@users.noreply.github.com> Date: Wed, 10 Feb 2021 12:39:14 +0100 Subject: [PATCH 1/5] contract card.php - manage multicompany files Use of multidir_output[$object->entity] instead of dir_output to manage shared entities --- htdocs/contrat/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index a346d955f14..5da79e45607 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -2131,7 +2131,7 @@ if ($action == 'create') * Documents generes */ $filename = dol_sanitizeFileName($object->ref); - $filedir = $conf->contrat->dir_output."/".dol_sanitizeFileName($object->ref); + $filedir = $conf->contrat->multidir_output[$object->entity]."/".dol_sanitizeFileName($object->ref); $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed = $user->rights->contrat->lire; $delallowed = $user->rights->contrat->creer; From e2ac46f0255d70e91f99cc975599b3837292dc52 Mon Sep 17 00:00:00 2001 From: LAURIER Alexis <19586755+AlexisLaurier@users.noreply.github.com> Date: Wed, 10 Feb 2021 12:44:36 +0100 Subject: [PATCH 2/5] manage documents folder as contrat - document.php --- htdocs/contrat/card.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 5da79e45607..41fb7f0057e 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -883,8 +883,8 @@ if (empty($reshook)) $action = 'editref'; } else { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $old_filedir = $conf->contrat->dir_output.'/'.dol_sanitizeFileName($old_ref); - $new_filedir = $conf->contrat->dir_output.'/'.dol_sanitizeFileName($object->ref); + $old_filedir = $conf->contrat->multidir_output[$object->entity].'/'.dol_sanitizeFileName($old_ref); + $new_filedir = $conf->contrat->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); $files = dol_dir_list($old_filedir); if (!empty($files)) @@ -929,7 +929,7 @@ if (empty($reshook)) // Actions to build doc - $upload_dir = $conf->contrat->dir_output; + $upload_dir = $conf->contrat->multidir_output[$object->entity]; $permissiontoadd = $user->rights->contrat->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; @@ -2162,7 +2162,7 @@ if ($action == 'create') // Presend form $modelmail = 'contract'; $defaulttopic = 'SendContractRef'; - $diroutput = $conf->contrat->dir_output; + $diroutput = $conf->contrat->multidir_output[$object->entity]; $trackid = 'con'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; From ca5eed691dc7ede6638ea07569a9faf59800f43d Mon Sep 17 00:00:00 2001 From: LAURIER Alexis <19586755+AlexisLaurier@users.noreply.github.com> Date: Wed, 10 Feb 2021 12:45:45 +0100 Subject: [PATCH 3/5] manage entity folder in contrat/document.php --- htdocs/contrat/document.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php index b68da3170ed..ba15af0de19 100644 --- a/htdocs/contrat/document.php +++ b/htdocs/contrat/document.php @@ -74,7 +74,7 @@ if ($object->id > 0) $object->fetch_thirdparty(); } -$upload_dir = $conf->contrat->dir_output.'/'.dol_sanitizeFileName($object->ref); +$upload_dir = $conf->contrat->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); $modulepart = 'contract'; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context From 92c374624e8613c0c41a21910d0f11525baf53ee Mon Sep 17 00:00:00 2001 From: LAURIER Alexis <19586755+AlexisLaurier@users.noreply.github.com> Date: Wed, 10 Feb 2021 12:58:40 +0100 Subject: [PATCH 4/5] contrat card.php - showdocuments add parameters Add missing parameters to showdocuments to manage properly contract entity --- htdocs/contrat/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 41fb7f0057e..be89fb2d3f6 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -2137,7 +2137,7 @@ if ($action == 'create') $delallowed = $user->rights->contrat->creer; - print $formfile->showdocuments('contract', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); + print $formfile->showdocuments('contract', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang, '', $object); // Show links to link elements From cb4295b702ad87054aea4a590b05c7a992ef722c Mon Sep 17 00:00:00 2001 From: LAURIER Alexis <19586755+AlexisLaurier@users.noreply.github.com> Date: Wed, 10 Feb 2021 13:02:13 +0100 Subject: [PATCH 5/5] dol_check_secure_access_document contrat multidir_ Use multidir_output for contracts document check to manage entity on each contract --- htdocs/core/lib/files.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 1bdaeef13ef..0703e3ede70 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2709,13 +2709,13 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } if (!empty($conf->stock->enabled)) $original_file = $conf->stock->multidir_output[$entity].'/movement/'.$original_file; } // Wrapping pour les contrats - elseif ($modulepart == 'contract' && !empty($conf->contrat->dir_output)) + elseif ($modulepart == 'contract' && !empty($conf->contrat->multidir_output[$entity])) { if ($fuser->rights->contrat->{$lire} || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } - $original_file = $conf->contrat->dir_output.'/'.$original_file; + $original_file = $conf->contrat->multidir_output[$entity].'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."contrat WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('contract').")"; } // Wrapping pour les dons elseif ($modulepart == 'donation' && !empty($conf->don->dir_output))