Work on direct download links
This commit is contained in:
parent
0eb416d4af
commit
beac7a7439
@ -1537,7 +1537,7 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio
|
||||
$ecmfile=new EcmFiles($db);
|
||||
$ecmfile->filepath = $rel_dir;
|
||||
$ecmfile->filename = $filename;
|
||||
$ecmfile->label = md5_file(dol_osencode($destfull));
|
||||
$ecmfile->label = md5_file(dol_osencode($destfull)); // MD5 of file content
|
||||
$ecmfile->fullpath_orig = $TFile['name'][$i];
|
||||
$ecmfile->gen_or_uploaded = 'uploaded';
|
||||
$ecmfile->description = ''; // indexed content
|
||||
|
||||
@ -46,7 +46,7 @@ class EcmFiles //extends CommonObject
|
||||
|
||||
/**
|
||||
*/
|
||||
public $label;
|
||||
public $label; // hash of file md5_file(dol_osencode($destfull)), so MD5 of file content
|
||||
public $entity;
|
||||
public $filename;
|
||||
public $filepath;
|
||||
|
||||
@ -249,11 +249,23 @@ print dol_print_size($totalsize);
|
||||
print '</td></tr>';
|
||||
*/
|
||||
|
||||
$relativetodocument = 'ecm/'.$relativepath; // $relativepath is relative to ECM dir, we need relative to document
|
||||
$filepath=$relativepath.$file->label;
|
||||
$filepathtodocument=$relativetodocument.$file->label;
|
||||
|
||||
print '<tr><td>'.$langs->trans("HashSaved").'</td><td>';
|
||||
$ecmfile = new EcmFiles($db);
|
||||
print $filepath;
|
||||
//$filenametosearch=basename($filepath);
|
||||
//$filedirtosearch=basedir($filepath);
|
||||
$ecmfile->fetch(0, '', $filepathtodocument);
|
||||
if (! empty($ecmfile->label))
|
||||
{
|
||||
print $ecmfile->label;
|
||||
}
|
||||
else
|
||||
{
|
||||
print img_warning().' '.$langs->trans("FileNotYetIndexedInDatabase");
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Define $urlwithroot
|
||||
@ -261,6 +273,19 @@ $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($
|
||||
$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 '<tr><td>'.$langs->trans("DirectDownloadInternalLink").'</td><td>';
|
||||
$modulepart='ecm';
|
||||
$forcedownload=1;
|
||||
$rellink='/document.php?modulepart='.$modulepart;
|
||||
if ($forcedownload) $rellink.='&attachment=1';
|
||||
if (! empty($object->entity)) $rellink.='&entity='.$object->entity;
|
||||
$rellink.='&file='.urlencode($filepath);
|
||||
$fulllink=$urlwithroot.$rellink;
|
||||
print img_picto('','object_globe.png').' ';
|
||||
print '<input type="text" class="quatrevingtpercent" id="downloadinternallink" name="downloadinternellink" value="'.dol_escape_htmltag($fulllink).'">';
|
||||
print ' <a href="'.$fulllink.'">'.$langs->trans("Download").'</a>';
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("DirectDownloadLink").'</td><td>';
|
||||
$modulepart='ecm';
|
||||
$forcedownload=1;
|
||||
@ -269,12 +294,15 @@ if ($forcedownload) $rellink.='&attachment=1';
|
||||
if (! empty($object->entity)) $rellink.='&entity='.$object->entity;
|
||||
$rellink.='&file='.urlencode($filepath);
|
||||
$fulllink=$urlwithroot.$rellink;
|
||||
print img_picto('','object_globe.png').' ';
|
||||
print '<input type="text" class="quatrevingtpercent" id="downloadlink" name="downloadlink" value="'.dol_escape_htmltag($fulllink).'">';
|
||||
print ' <a href="'.$fulllink.'">'.$langs->trans("Download").'</a>';
|
||||
// TODO
|
||||
//print img_picto('','object_globe.png').' ';
|
||||
//print '<input type="text" class="quatrevingtpercent" id="downloadlink" name="downloadexternallink" value="'.dol_escape_htmltag($fulllink).'">';
|
||||
//print ' <a href="'.$fulllink.'">'.$langs->trans("Download").'</a>';
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print ajax_autoselect('downloadinternallink');
|
||||
print ajax_autoselect('downloadlink');
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
@ -42,4 +42,6 @@ CannotRemoveDirectoryContainsFiles=Removed not possible because it contains some
|
||||
ECMFileManager=File manager
|
||||
ECMSelectASection=Select a directory on left tree...
|
||||
DirNotSynchronizedSyncFirst=This directory seems to be created or modified outside ECM module. You must click on "Resync" button first to synchronize disk and database to get content of this directory.
|
||||
ReSyncListOfDir=Resync list of directories
|
||||
ReSyncListOfDir=Resync list of directories
|
||||
HashSaved=Hash of file
|
||||
FileNotYetIndexedInDatabase=File not yet indexed into database (try to re-upload it)
|
||||
@ -792,7 +792,8 @@ GroupBy=Group by...
|
||||
ViewFlatList=View flat list
|
||||
RemoveString=Remove string '%s'
|
||||
SomeTranslationAreUncomplete=Some languages may be partially translated or may contains errors. If you detect some, you can fix language files registering to <a href="https://transifex.com/projects/p/dolibarr/" target="_blank">https://transifex.com/projects/p/dolibarr/</a>.
|
||||
DirectDownloadLink=Direct download link
|
||||
DirectDownloadLink=Direct download link (public/external)
|
||||
DirectDownloadInternalLink=Direct download link (need to be logged and permissions)
|
||||
Download=Download
|
||||
ActualizeCurrency=Update currency rate
|
||||
Fiscalyear=Fiscal year
|
||||
|
||||
Loading…
Reference in New Issue
Block a user