From 9209c83054b909eeaaa4c8ce48ea868c3e907aa0 Mon Sep 17 00:00:00 2001 From: marc Date: Sun, 24 Jul 2022 14:49:57 +0200 Subject: [PATCH 1/3] Fix deleting logo/photo doesn't delete file from disk --- htdocs/societe/card.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index b6c483fc026..b20a00e0c4d 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -554,9 +554,7 @@ if (empty($reshook)) { } //var_dump($object->array_languages);exit; - if (GETPOST('deletephoto')) { - $object->logo = ''; - } elseif (!empty($_FILES['photo']['name'])) { + if (!empty($_FILES['photo']['name'])) { $object->logo = dol_sanitizeFileName($_FILES['photo']['name']); } From d8dfe360ecfab25fef8e78b6db926964c5209cc0 Mon Sep 17 00:00:00 2001 From: marc Date: Sun, 24 Jul 2022 15:03:32 +0200 Subject: [PATCH 2/3] Fix #21518 delete old logo/photo from disk when load a new logo/photo --- htdocs/societe/card.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index b20a00e0c4d..0436a1160a7 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -555,6 +555,7 @@ if (empty($reshook)) { //var_dump($object->array_languages);exit; if (!empty($_FILES['photo']['name'])) { + $current_logo = $object->logo; $object->logo = dol_sanitizeFileName($_FILES['photo']['name']); } @@ -784,6 +785,13 @@ if (empty($reshook)) { } if ($file_OK) { if (image_format_supported($_FILES['photo']['name']) > 0) { + if($current_logo != $object->logo) { + $fileimg = $dir.'/'.$current_logo; + $dirthumbs = $dir.'/thumbs'; + dol_delete_file($fileimg); + dol_delete_dir_recursive($dirthumbs); + } + dol_mkdir($dir); if (@is_dir($dir)) { From bd88c9e0cd0d0361ffd6aa91036d487fbbaa221a Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 24 Jul 2022 13:15:39 +0000 Subject: [PATCH 3/3] Fixing style errors. --- htdocs/societe/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 0436a1160a7..c8370452d4f 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -785,11 +785,11 @@ if (empty($reshook)) { } if ($file_OK) { if (image_format_supported($_FILES['photo']['name']) > 0) { - if($current_logo != $object->logo) { + if ($current_logo != $object->logo) { $fileimg = $dir.'/'.$current_logo; $dirthumbs = $dir.'/thumbs'; dol_delete_file($fileimg); - dol_delete_dir_recursive($dirthumbs); + dol_delete_dir_recursive($dirthumbs); } dol_mkdir($dir);