';
@@ -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 .= '