diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 7014a6de963..ebca0177868 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2633,12 +2633,6 @@ if ($action == 'create') { print showOnlineSignatureUrl('proposal', $object->ref).'
'; } - // Show direct download link - if ($object->statut != Propal::STATUS_DRAFT && !empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) { - print '
'."\n"; - print showDirectDownloadLink($object).'
'; - } - print '
'; // List of actions on element diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 5fa26be7f4e..0665a567738 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2629,12 +2629,6 @@ if ($action == 'create' && $usercancreate) { print showOnlinePaymentUrl('order', $object->ref).'
'; } - // Show direct download link - if ($object->statut != Commande::STATUS_DRAFT && !empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) { - print '
'."\n"; - print showDirectDownloadLink($object).'
'; - } - print '
'; // List of actions on element diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 57fad75e041..bde5a6e6c38 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -5512,13 +5512,6 @@ if ($action == 'create') { print showOnlinePaymentUrl('invoice', $object->ref).'
'; } - // Show direct download link - //if ($object->statut != Facture::STATUS_DRAFT && !empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) { - if ($object->statut != Facture::STATUS_DRAFT) { - print '
'."\n"; - print showDirectDownloadLink($object).'
'; - } - print '
'; // List of actions on element diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 9e342b9b8d3..1ab26b73c75 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -2124,12 +2124,6 @@ if ($action == 'create') { $linktoelem = $form->showLinkToObjectBlock($object, null, array('contrat')); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - // Show direct download link - if ($object->statut != Contrat::STATUS_DRAFT && !empty($conf->global->CONTRACT_ALLOW_EXTERNAL_DOWNLOAD)) { - print '
'."\n"; - print showDirectDownloadLink($object).'
'; - } - print '
'; $MAXEVENT = 10; diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index de5738db9af..168a1e499bd 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -369,6 +369,8 @@ class FormFile */ public function showdocuments($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed = 0, $modelselected = '', $allowgenifempty = 1, $forcenomultilang = 0, $iconPDF = 0, $notused = 0, $noform = 0, $param = '', $title = '', $buttonlabel = '', $codelang = '', $morepicto = '', $object = null, $hideifempty = 0, $removeaction = 'remove_file') { + global $dolibarr_main_url_root; + // Deprecation warning if (!empty($iconPDF)) { dol_syslog(__METHOD__.": passing iconPDF parameter is deprecated", LOG_WARNING); @@ -698,7 +700,7 @@ class FormFile $out .= ''; $addcolumforpicto = ($delallowed || $printer || $morepicto); - $colspan = (3 + ($addcolumforpicto ? 1 : 0)); + $colspan = (4 + ($addcolumforpicto ? 1 : 0)); $colspanmore = 0; $out .= ''; @@ -798,6 +800,23 @@ class FormFile // Loop on each file found if (is_array($file_list)) { + // Defined relative dir to DOL_DATA_ROOT + $relativedir = ''; + if ($filedir) { + $relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filedir); + $relativedir = preg_replace('/^[\\/]/', '', $relativedir); + } + + // Get list of files stored into database for same relative directory + if ($relativedir) { + completeFileArrayWithDatabaseInfo($file_list, $relativedir); + + //var_dump($sortfield.' - '.$sortorder); + if ($sortfield && $sortorder) { // If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name) + $file_list = dol_sort_array($file_list, $sortfield, $sortorder); + } + } + foreach ($file_list as $file) { // Define relative path for download link (depends on module) $relativepath = $file["name"]; // Cas general @@ -838,6 +857,34 @@ class FormFile $date = (!empty($file['date']) ? $file['date'] : dol_filemtime($filedir."/".$file["name"])); $out .= ''.dol_print_date($date, 'dayhour', 'tzuser').''; + // Show share link + $out .= ''; + if ($file['share']) { + // Define $urlwithroot + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + + //print ''.$langs->trans("Hash").' : '.$file['share'].''; + $forcedownload = 0; + $paramlink = ''; + if (!empty($file['share'])) { + $paramlink .= ($paramlink ? '&' : '').'hashp='.$file['share']; // Hash for public share + } + if ($forcedownload) { + $paramlink .= ($paramlink ? '&' : '').'attachment=1'; + } + + $fulllink = $urlwithroot.'/document.php'.($paramlink ? '?'.$paramlink : ''); + + $out .= img_picto($langs->trans("FileSharedViaALink"), 'globe').' '; + $out .= ''; + $out .= ajax_autoselect('downloadlink'.$file['rowid']); + } else { + //print ''.$langs->trans("FileNotShared").''; + } + $out .= ''; + if ($delallowed || $printer || $morepicto) { $out .= ''; if ($delallowed) { @@ -1096,6 +1143,7 @@ class FormFile if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO) && $filearray[0]['level1name'] == 'photos') { $relativepath = preg_replace('/^.*\/produit\//', '', $filearray[0]['path']).'/'; } + // Defined relative dir to DOL_DATA_ROOT $relativedir = ''; if ($upload_dir) { @@ -1352,7 +1400,7 @@ class FormFile $fulllink = $urlwithroot.'/document.php'.($paramlink ? '?'.$paramlink : ''); print img_picto($langs->trans("FileSharedViaALink"), 'globe').' '; - print ''; + print ''; } else { //print ''.$langs->trans("FileNotShared").''; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d2e6cd368ed..2b981530834 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8803,7 +8803,7 @@ function showDirectDownloadLink($object) $out = ''; $url = $object->getLastMainDocLink($object->element); - $out .= img_picto($langs->trans("PublicDownloadLinkdesc"), 'globe').' '.$langs->trans("DirectDownloadLink").'
'; + $out .= img_picto($langs->trans("PublicDownloadLinkDesc"), 'globe').' '.$langs->trans("DirectDownloadLink").'
'; if ($url) { $out .= ''; $out .= ajax_autoselect("directdownloadlink", 0);