Fix removal of a file
This commit is contained in:
parent
2831f90b42
commit
0eb416d4af
@ -19,12 +19,12 @@
|
||||
* \file htdocs/ecm/docfile.php
|
||||
* \ingroup ecm
|
||||
* \brief Card of a file for ECM module
|
||||
* \author Laurent Destailleur
|
||||
*/
|
||||
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php';
|
||||
|
||||
@ -103,11 +103,9 @@ if (! empty($_GET["fileid"]))
|
||||
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
* ACTIONS
|
||||
*
|
||||
* Put here all code to do according to value of "action" parameter
|
||||
********************************************************************/
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'cancel')
|
||||
{
|
||||
@ -166,11 +164,9 @@ if ($action == 'update')
|
||||
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
* PAGE
|
||||
*
|
||||
* Put here all code to do according to value of "action" parameter
|
||||
********************************************************************/
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
|
||||
@ -253,6 +249,13 @@ print dol_print_size($totalsize);
|
||||
print '</td></tr>';
|
||||
*/
|
||||
|
||||
$filepath=$relativepath.$file->label;
|
||||
|
||||
print '<tr><td>'.$langs->trans("HashSaved").'</td><td>';
|
||||
$ecmfile = new EcmFiles($db);
|
||||
print $filepath;
|
||||
print '</td></tr>';
|
||||
|
||||
// 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
|
||||
@ -264,7 +267,6 @@ $forcedownload=1;
|
||||
$rellink='/document.php?modulepart='.$modulepart;
|
||||
if ($forcedownload) $rellink.='&attachment=1';
|
||||
if (! empty($object->entity)) $rellink.='&entity='.$object->entity;
|
||||
$filepath=$relativepath.$file->label;
|
||||
$rellink.='&file='.urlencode($filepath);
|
||||
$fulllink=$urlwithroot.$rellink;
|
||||
print img_picto('','object_globe.png').' ';
|
||||
|
||||
@ -143,26 +143,24 @@ if ($action == 'confirm_deletefile')
|
||||
{
|
||||
if (GETPOST('confirm') == 'yes')
|
||||
{
|
||||
// GETPOST('urlfile','alpha') is full relative URL from ecm root dir. Contains path of all sections.
|
||||
//var_dump(GETPOST('urlfile'));exit;
|
||||
$langs->load("other");
|
||||
if ($section)
|
||||
{
|
||||
$result=$ecmdir->fetch($section);
|
||||
if (! ($result > 0))
|
||||
{
|
||||
dol_print_error($db,$ecmdir->error);
|
||||
exit;
|
||||
}
|
||||
$relativepath=$ecmdir->getRelativePath();
|
||||
}
|
||||
else $relativepath='';
|
||||
|
||||
$upload_dir = $conf->ecm->dir_output.($relativepath?'/'.$relativepath:'');
|
||||
$file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_POST are already decoded by PHP).
|
||||
$file = $upload_dir . "/" . GETPOST('urlfile','alpha'); // Do not use urldecode here ($_GET and $_POST are already decoded by PHP).
|
||||
//var_dump($file);exit;
|
||||
|
||||
$ret=dol_delete_file($file);
|
||||
if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
|
||||
else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
|
||||
|
||||
$result=$ecmdir->changeNbOfFiles('-');
|
||||
$ret=dol_delete_file($file); // This include also the delete from file index in database.
|
||||
if ($ret)
|
||||
{
|
||||
setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile','alpha')), null, 'mesgs');
|
||||
$result=$ecmdir->changeNbOfFiles('-');
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile','alpha')), null, 'errors');
|
||||
}
|
||||
|
||||
clearstatcache();
|
||||
}
|
||||
@ -375,7 +373,7 @@ else
|
||||
print '</a>';
|
||||
}
|
||||
$url=((! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))?'#':($_SERVER["PHP_SELF"].'?action=refreshmanual'.($module?'&module='.$module:'').($section?'&section='.$section:'')));
|
||||
print '<a href="'.$url.'" class="inline-block valignmiddle toolbarbutton" title="'.dol_escape_htmltag($langs->trans('Refresh')).'">';
|
||||
print '<a href="'.$url.'" class="inline-block valignmiddle toolbarbutton" title="'.dol_escape_htmltag($langs->trans('ReSyncListOfDir')).'">';
|
||||
print '<img id="refreshbutton" class="toolbarbutton" border="0" src="'.DOL_URL_ROOT.'/theme/common/view-refresh.png">';
|
||||
print '</a>';
|
||||
|
||||
|
||||
@ -41,4 +41,5 @@ ECMDirectoryForFiles=Relative directory for files
|
||||
CannotRemoveDirectoryContainsFiles=Removed not possible because it contains some files
|
||||
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 "Refresh" button first to synchronize disk and database to get content of this directory.
|
||||
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
|
||||
@ -67,6 +67,7 @@ $amount=price2num(GETPOST("amount",'alpha'));
|
||||
if (! GETPOST("currency",'alpha')) $currency=$conf->currency;
|
||||
else $currency=GETPOST("currency",'alpha');
|
||||
$source = GETPOST("s",'alpha')?GETPOST("s",'alpha'):GETPOST("source",'alpha');
|
||||
$download = GETPOST('d','int')?GETPOST('d','int'):GETPOST('download','int');
|
||||
|
||||
if (! $action)
|
||||
{
|
||||
@ -854,7 +855,7 @@ if ($source == 'invoice')
|
||||
print '</td></tr>'."\n";
|
||||
|
||||
// Add download link
|
||||
if (GETPOST('download','int') > 0)
|
||||
if ($download > 0)
|
||||
{
|
||||
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Document");
|
||||
print '</td><td class="CTableRow'.($var?'1':'2').'">';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user