ソースを参照

Fix bad delete of lines into llx_ecm_files

Laurent Destailleur 1 年間 前
コミット
7659bba97a

+ 2 - 1
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;

+ 1 - 0
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++;
 			}

+ 2 - 1
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);

+ 12 - 2
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

+ 2 - 1
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);

+ 1 - 0
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++;
 			}

+ 2 - 1
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);

+ 2 - 1
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);

+ 4 - 6
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) {

+ 1 - 0
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++;
 				}

+ 2 - 1
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);