diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index ef4df465154..a672e19d351 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3160,6 +3160,7 @@ class Propal extends CommonObject // Delete record into ECM index and physically if (!$error) { $res = $this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive + $res = $this->deleteEcmFiles(1); // Deleting files physically is done later with the dol_delete_dir_recursive if (!$res) { $error++; } @@ -3182,7 +3183,7 @@ class Propal extends CommonObject } } if (file_exists($dir)) { - $res = @dol_delete_dir_recursive($dir); + $res = @dol_delete_dir_recursive($dir); // delete files physically + into ecm tables if (!$res) { $this->error = 'ErrorFailToDeleteDir'; $this->errors[] = $this->error; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index fcfa2153ff7..eef8dc9e7da 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3507,6 +3507,7 @@ class Commande extends CommonOrder // Delete record into ECM index and physically if (!$error) { $res = $this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive + $res = $this->deleteEcmFiles(1); // Deleting files physically is done later with the dol_delete_dir_recursive if (!$res) { $error++; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 6433f63fe0d..6d14a6077bb 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2866,7 +2866,8 @@ class Facture extends CommonInvoice $resql = $this->db->query($sql); if ($resql) { // Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive - $this->deleteEcmFiles(); + $this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive + $this->deleteEcmFiles(1); // Deleting files physically is done later with the dol_delete_dir_recursive // On efface le repertoire de pdf provisoire $ref = dol_sanitizeFileName($this->ref); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 87c9b7adf40..a53e9cbaf0d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -10417,16 +10417,26 @@ abstract class CommonObject $element = 'fournisseur/commande'; break; case 'invoice_supplier': + // Special cases that need to use get_exdir to get real dir of object + // In future, all object should use this to define path of documents. $element = 'fournisseur/facture/'.get_exdir($this->id, 2, 0, 1, $this, 'invoice_supplier'); break; case 'shipping': $element = 'expedition/sending'; break; + case 'task': + case 'project_task': + require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; + + $project_result = $this->fetch_projet(); + if ($project_result >= 0) { + $element = 'projet/'.dol_sanitizeFileName($object->project->ref).'/'; + } default: $element = $this->element; } - // Delete ecm_files extrafields + // Delete ecm_files_extrafields with mode 0 (using name) $sql = "DELETE FROM ".$this->db->prefix()."ecm_files_extrafields WHERE fk_object IN ("; $sql .= " SELECT rowid FROM ".$this->db->prefix()."ecm_files WHERE filename LIKE '".$this->db->escape($this->ref)."%'"; $sql .= " AND filepath = '".$this->db->escape($element)."/".$this->db->escape($this->ref)."' AND entity = ".((int) $conf->entity); // No need of getEntity here @@ -10438,7 +10448,7 @@ abstract class CommonObject return false; } - // Delete ecm_files + // Delete ecm_files with mode 0 (using name) $sql = "DELETE FROM ".$this->db->prefix()."ecm_files"; $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%'"; $sql .= " AND filepath = '".$this->db->escape($element)."/".$this->db->escape($this->ref)."' AND entity = ".((int) $conf->entity); // No need of getEntity here diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 285b0cef578..f88c40144c9 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1500,7 +1500,8 @@ class Expedition extends CommonObject $this->db->commit(); // Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive - $this->deleteEcmFiles(); + $this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive + $this->deleteEcmFiles(1); // Deleting files physically is done later with the dol_delete_dir_recursive // We delete PDFs $ref = dol_sanitizeFileName($this->ref); diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 9ffebdb8fde..85519f3c7c7 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1196,6 +1196,7 @@ class ExpenseReport extends CommonObject // Delete record into ECM index and physically if (!$error) { $res = $this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive + $res = $this->deleteEcmFiles(1); // Deleting files physically is done later with the dol_delete_dir_recursive if (!$res) { $error++; } diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index a67fa0d1d75..c0059a2538b 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -1116,7 +1116,8 @@ class Fichinter extends CommonObject if (!$error) { // Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive - $this->deleteEcmFiles(); + $this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive + $this->deleteEcmFiles(1); // Deleting files physically is done later with the dol_delete_dir_recursive // Remove directory with files $fichinterref = dol_sanitizeFileName($this->ref); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index fb376f4b14f..cb286a9798b 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2331,7 +2331,8 @@ class CommandeFournisseur extends CommonOrder if (!$error) { // Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive - $this->deleteEcmFiles(); + $this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive + $this->deleteEcmFiles(1); // Deleting files physically is done later with the dol_delete_dir_recursive // We remove directory $ref = dol_sanitizeFileName($this->ref); diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 5417fdc3669..71024d6cd82 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1122,7 +1122,7 @@ class FactureFournisseur extends CommonInvoice */ public function update($user = null, $notrigger = 0) { - global $conf, $langs; + global $langs; $error = 0; // Clean parameters @@ -1153,9 +1153,6 @@ class FactureFournisseur extends CommonInvoice if (isset($this->label)) { $this->label = trim($this->label); } - if (isset($this->libelle)) { - $this->libelle = trim($this->libelle); // deprecated - } if (isset($this->paye)) { $this->paye = trim($this->paye); } @@ -1414,7 +1411,7 @@ class FactureFournisseur extends CommonInvoice */ public function delete(User $user, $notrigger = 0) { - global $langs, $conf; + global $conf; $rowid = $this->id; @@ -1492,7 +1489,8 @@ class FactureFournisseur extends CommonInvoice if (!$error) { // Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive - $this->deleteEcmFiles(); + $this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive + $this->deleteEcmFiles(1); // Deleting files physically is done later with the dol_delete_dir_recursive // We remove directory if ($conf->fournisseur->facture->dir_output) { diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index d28c527fbe3..2a6eeae7030 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1547,6 +1547,7 @@ class Product extends CommonObject // Delete record into ECM index and physically if (!$error) { $res = $this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive + $res = $this->deleteEcmFiles(1); // Deleting files physically is done later with the dol_delete_dir_recursive if (!$res) { $error++; } diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index f072bffc5fe..a203c0ac8a8 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -2030,7 +2030,8 @@ class SupplierProposal extends CommonObject if (!$error) { // Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive - $this->deleteEcmFiles(); + $this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive + $this->deleteEcmFiles(1); // Deleting files physically is done later with the dol_delete_dir_recursive // We remove directory $ref = dol_sanitizeFileName($this->ref);