Skip to content

Commit

Permalink
Merge pull request #32811 from hregis/fix_18_cannot_delete_file_task
Browse files Browse the repository at this point in the history
FIX can not delete files in task card
  • Loading branch information
eldy authored Jan 27, 2025
2 parents a404b80 + c7ee83b commit c6ab6cd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions htdocs/core/lib/files.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 8 additions & 6 deletions htdocs/projet/tasks/task.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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');
}
}

Expand All @@ -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)) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c6ab6cd

Please sign in to comment.