diff --git a/htdocs/ecm/dir_card.php b/htdocs/ecm/dir_card.php
index e313787b01f..e2b031305d9 100644
--- a/htdocs/ecm/dir_card.php
+++ b/htdocs/ecm/dir_card.php
@@ -160,23 +160,28 @@ if ($action == 'confirm_deletedir' && $confirm == 'yes')
{
// Fetch was already done
$result=$ecmdir->delete($user);
+ if ($result <= 0)
+ {
+ $langs->load('errors');
+ setEventMessages($langs->trans($ecmdir->error,$ecmdir->label), null, 'errors');
+ }
}
else
{
- $resbool = dol_delete_dir($upload_dir);
+ $resbool = dol_delete_dir($upload_dir, 1);
if ($resbool) $result = 1;
- else $result = 0;
+ else
+ {
+ $langs->load('errors');
+ setEventMessages($langs->trans("ErrorFailToDeleteDir", $upload_dir), null, 'errors');
+ $result = 0;
+ }
}
if ($result > 0)
{
header("Location: ".$backtourl);
exit;
}
- else
- {
- $langs->load('errors');
- setEventMessages($langs->trans($ecmdir->error,$ecmdir->label), null, 'errors');
- }
}
// Update dirname or description
@@ -281,6 +286,7 @@ if ($module == 'ecm')
llxHeader();
// Built the file List
+$filearrayall=dol_dir_list($upload_dir,"all",0,'','',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
@@ -469,7 +475,7 @@ if ($action != 'edit' && $action != 'delete')
print ''.$langs->trans('ECMAddSection').'';
}
- if (count($filearray) == 0)
+ if (count($filearrayall) == 0)
{
if ($permtoadd)
{
@@ -482,7 +488,10 @@ if ($action != 'edit' && $action != 'delete')
}
else
{
- print ''.$langs->trans('Delete').'';
+ if (count($filearray) > 0)
+ print ''.$langs->trans('Delete').'';
+ else
+ print ''.$langs->trans('Delete').'';
}
print '';
}
diff --git a/htdocs/langs/en_US/ecm.lang b/htdocs/langs/en_US/ecm.lang
index fe5600004ed..588044f18df 100644
--- a/htdocs/langs/en_US/ecm.lang
+++ b/htdocs/langs/en_US/ecm.lang
@@ -39,6 +39,7 @@ ShowECMSection=Show directory
DeleteSection=Remove directory
ConfirmDeleteSection=Can you confirm you want to delete the directory %s?
ECMDirectoryForFiles=Relative directory for files
+CannotRemoveDirectoryContainsFilesOrDirs=Removed not possible because it contains some files or sub-directories
CannotRemoveDirectoryContainsFiles=Removed not possible because it contains some files
ECMFileManager=File manager
ECMSelectASection=Select a directory in the tree...