NEW When a doc file is shared, link is visible from main page of doc.

This commit is contained in:
Laurent Destailleur 2021-04-15 17:56:55 +02:00
parent f1d55d38ba
commit db5dcd3e52
6 changed files with 51 additions and 28 deletions

View File

@ -2633,12 +2633,6 @@ if ($action == 'create') {
print showOnlineSignatureUrl('proposal', $object->ref).'<br>';
}
// Show direct download link
if ($object->statut != Propal::STATUS_DRAFT && !empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) {
print '<br><!-- Link to download main doc -->'."\n";
print showDirectDownloadLink($object).'<br>';
}
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
// List of actions on element

View File

@ -2629,12 +2629,6 @@ if ($action == 'create' && $usercancreate) {
print showOnlinePaymentUrl('order', $object->ref).'<br>';
}
// Show direct download link
if ($object->statut != Commande::STATUS_DRAFT && !empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) {
print '<br><!-- Link to download main doc -->'."\n";
print showDirectDownloadLink($object).'<br>';
}
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
// List of actions on element

View File

@ -5512,13 +5512,6 @@ if ($action == 'create') {
print showOnlinePaymentUrl('invoice', $object->ref).'<br>';
}
// Show direct download link
//if ($object->statut != Facture::STATUS_DRAFT && !empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) {
if ($object->statut != Facture::STATUS_DRAFT) {
print '<br><!-- Link to download main doc -->'."\n";
print showDirectDownloadLink($object).'<br>';
}
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
// List of actions on element

View File

@ -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 '<br><!-- Link to download main doc -->'."\n";
print showDirectDownloadLink($object).'<br>';
}
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
$MAXEVENT = 10;

View File

@ -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 .= '<tr class="liste_titre">';
$addcolumforpicto = ($delallowed || $printer || $morepicto);
$colspan = (3 + ($addcolumforpicto ? 1 : 0));
$colspan = (4 + ($addcolumforpicto ? 1 : 0));
$colspanmore = 0;
$out .= '<th colspan="'.$colspan.'" class="formdoc liste_titre maxwidthonsmartphone center">';
@ -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 .= '<td class="nowrap right">'.dol_print_date($date, 'dayhour', 'tzuser').'</td>';
// Show share link
$out .= '<td class="nowrap">';
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 '<span class="opacitymedium">'.$langs->trans("Hash").' : '.$file['share'].'</span>';
$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 .= '<input type="text" class="quatrevingtpercent width75" id="downloadlink'.$file['rowid'].'" name="downloadexternallink" title="'.dol_escape_htmltag($langs->trans("FileSharedViaALink")).'" value="'.dol_escape_htmltag($fulllink).'">';
$out .= ajax_autoselect('downloadlink'.$file['rowid']);
} else {
//print '<span class="opacitymedium">'.$langs->trans("FileNotShared").'</span>';
}
$out .= '</td>';
if ($delallowed || $printer || $morepicto) {
$out .= '<td class="right nowraponall">';
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 '<input type="text" class="quatrevingtpercent minwidth200imp" id="downloadlink" name="downloadexternallink" value="'.dol_escape_htmltag($fulllink).'">';
print '<input type="text" class="quatrevingtpercent minwidth200imp" id="downloadlink'.$filearray[$key]['rowid'].'" name="downloadexternallink" title="'.dol_escape_htmltag($langs->trans("FileSharedViaALink")).'" value="'.dol_escape_htmltag($fulllink).'">';
} else {
//print '<span class="opacitymedium">'.$langs->trans("FileNotShared").'</span>';
}

View File

@ -8803,7 +8803,7 @@ function showDirectDownloadLink($object)
$out = '';
$url = $object->getLastMainDocLink($object->element);
$out .= img_picto($langs->trans("PublicDownloadLinkdesc"), 'globe').' <span class="opacitymedium">'.$langs->trans("DirectDownloadLink").'</span><br>';
$out .= img_picto($langs->trans("PublicDownloadLinkDesc"), 'globe').' <span class="opacitymedium">'.$langs->trans("DirectDownloadLink").'</span><br>';
if ($url) {
$out .= '<div class="urllink"><input type="text" id="directdownloadlink" class="quatrevingtpercent" value="'.$url.'"></div>';
$out .= ajax_autoselect("directdownloadlink", 0);