diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 2ed990205ad69..ee9b55b21c3d4 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1448,6 +1448,7 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0, } } } else { + $ok = false; // to avoid false positive dol_syslog("No files to delete found", LOG_DEBUG); } } else { diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index b8ff5a6f9bc48..4f1ca11848bc4 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -65,7 +65,10 @@ } if ($id > 0 || $ref) { - $object->fetch($id, $ref); + $ret = $object->fetch($id, $ref); + if ($ret > 0) { + $projectstatic->fetch($object->fk_project); + } } // Security check @@ -204,14 +207,14 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $langs->load("other"); - $upload_dir = $conf->project->dir_output; + $upload_dir = $conf->project->dir_output."/".dol_sanitizeFileName($projectstatic->ref)."/".dol_sanitizeFileName($object->ref); $file = $upload_dir.'/'.dol_sanitizeFileName(GETPOST('file')); $ret = dol_delete_file($file); if ($ret) { - setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); + setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs'); } else { - setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); + setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors'); } } @@ -222,7 +225,6 @@ $form = new Form($db); $formother = new FormOther($db); $formfile = new FormFile($db); -$result = $projectstatic->fetch($object->fk_project); $title = $object->ref; if (!empty($withproject)) { @@ -692,7 +694,7 @@ /* * Generated documents */ - $filename = dol_sanitizeFileName($projectstatic->ref)."/".dol_sanitizeFileName($object->ref); + $filename = ''; $filedir = $conf->project->dir_output."/".dol_sanitizeFileName($projectstatic->ref)."/".dol_sanitizeFileName($object->ref); $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed = ($user->rights->projet->lire);