From 72c6ac1c7263dcc73aed38f8da1a71faf386c5ee Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 23 Apr 2020 13:21:39 +0200 Subject: [PATCH] Complete #13708, normalization of code --- htdocs/adherents/class/adherent.class.php | 15 ++++----- .../adherents/class/adherent_type.class.php | 2 +- htdocs/asset/class/asset_type.class.php | 2 +- htdocs/categories/class/categorie.class.php | 6 ++-- htdocs/comm/action/class/actioncomm.class.php | 15 ++++----- htdocs/comm/propal/card.php | 2 +- htdocs/comm/propal/class/propal.class.php | 30 +++++++----------- htdocs/commande/card.php | 2 +- htdocs/commande/class/commande.class.php | 19 +++++------- htdocs/commande/orderstoinvoice.php | 2 +- htdocs/compta/bank/class/account.class.php | 11 +++---- htdocs/compta/facture/card.php | 4 +-- .../facture/class/facture-rec.class.php | 6 ++-- htdocs/compta/facture/class/facture.class.php | 6 ++-- htdocs/contact/class/contact.class.php | 4 +-- htdocs/contrat/card.php | 2 +- htdocs/contrat/class/contrat.class.php | 31 +++++++++---------- htdocs/core/actions_massactions.inc.php | 2 +- htdocs/core/class/commonobject.class.php | 21 ++++++++----- htdocs/don/class/don.class.php | 4 +-- htdocs/expedition/class/expedition.class.php | 11 ++++--- htdocs/fichinter/class/fichinter.class.php | 10 +++--- .../class/fournisseur.commande.class.php | 6 ++-- .../fournisseur.commande.dispatch.class.php | 2 +- .../fourn/class/fournisseur.facture.class.php | 12 +++---- htdocs/fourn/commande/card.php | 4 +-- htdocs/fourn/facture/card.php | 4 +-- htdocs/product/class/product.class.php | 4 +-- htdocs/product/stock/class/entrepot.class.php | 6 ++-- .../product/stock/class/productlot.class.php | 4 +-- htdocs/projet/class/project.class.php | 4 +-- htdocs/projet/class/task.class.php | 4 +-- htdocs/reception/class/reception.class.php | 2 +- htdocs/resource/class/dolresource.class.php | 4 +-- htdocs/salaries/class/paymentsalary.class.php | 4 +-- htdocs/societe/class/societe.class.php | 4 +-- htdocs/supplier_proposal/card.php | 2 +- .../class/supplier_proposal.class.php | 25 +++++++-------- htdocs/ticket/class/ticket.class.php | 16 ++++------ htdocs/user/class/user.class.php | 4 +-- 40 files changed, 149 insertions(+), 169 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 4225dad5f31..dd2593329e0 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -657,7 +657,7 @@ class Adherent extends CommonObject $action = 'update'; // Actions on extra fields - if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) { @@ -927,14 +927,11 @@ class Adherent extends CommonObject // Removed extrafields if (!$error) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $result = $this->deleteExtraFields(); - if ($result < 0) { - $error++; - $errorflag = -4; - dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR); - } + $result = $this->deleteExtraFields(); + if ($result < 0) { + $error++; + $errorflag = -4; + dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR); } } diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 442d8cf091f..46733575c36 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -409,7 +409,7 @@ class AdherentType extends CommonObject $action = 'update'; // Actions on extra fields - if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) diff --git a/htdocs/asset/class/asset_type.class.php b/htdocs/asset/class/asset_type.class.php index edb6fdf90c9..56be39a8ad0 100644 --- a/htdocs/asset/class/asset_type.class.php +++ b/htdocs/asset/class/asset_type.class.php @@ -202,7 +202,7 @@ class AssetType extends CommonObject $action = 'update'; // Actions on extra fields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (! $error) { $result = $this->insertExtraFields(); if ($result < 0) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 9c0985078e7..dc451855c0a 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -461,7 +461,7 @@ class Categorie extends CommonObject $action = 'create'; // Actions on extra fields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) @@ -553,7 +553,7 @@ class Categorie extends CommonObject $action = 'update'; // Actions on extra fields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) @@ -646,7 +646,7 @@ class Categorie extends CommonObject } // Removed extrafields - if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->deleteExtraFields(); if ($result < 0) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 8c1e2051a81..0cd1eeb5051 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -567,14 +567,11 @@ class ActionComm extends CommonObject if (!$error) { // Actions on extra fields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + $result = $this->insertExtraFields(); + if ($result < 0) + { + $error++; + } } if (!$error && !$notrigger) @@ -1048,7 +1045,7 @@ class ActionComm extends CommonObject $action = 'update'; // Actions on extra fields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 92338ebf68e..85927472c56 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -511,7 +511,7 @@ if (empty($reshook)) } // Extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { + if (method_exists($lines[$i], 'fetch_optionals')) { $lines[$i]->fetch_optionals(); $array_options = $lines[$i]->array_options; } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 6a2eac53f95..465bb52033c 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1253,13 +1253,10 @@ class Propal extends CommonObject // Actions on extra fields if (!$error) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + $result = $this->insertExtraFields(); + if ($result < 0) { - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } + $error++; } } @@ -1683,7 +1680,7 @@ class Propal extends CommonObject $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options) > 0) + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) @@ -3053,15 +3050,12 @@ class Propal extends CommonObject // Removed extrafields if (!$error) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + $result = $this->deleteExtraFields(); + if ($result < 0) { - $result = $this->deleteExtraFields(); - if ($result < 0) - { - $error++; - $errorflag = -4; - dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR); - } + $error++; + $errorflag = -4; + dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR); } } @@ -4152,7 +4146,7 @@ class PropaleLigne extends CommonObjectLine { $this->rowid = $this->db->last_insert_id(MAIN_DB_PREFIX.'propaldet'); - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $this->id = $this->rowid; $result = $this->insertExtraFields(); @@ -4204,7 +4198,7 @@ class PropaleLigne extends CommonObjectLine if ($this->db->query($sql)) { // Remove extrafields - if ((!$error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used + if (!$error) { $this->id = $this->rowid; $result = $this->deleteExtraFields(); @@ -4334,7 +4328,7 @@ class PropaleLigne extends CommonObjectLine $resql = $this->db->query($sql); if ($resql) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $this->id = $this->rowid; $result = $this->insertExtraFields(); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index b43a702c2f2..4aad42ca44f 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -384,7 +384,7 @@ if (empty($reshook)) } // Extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) // For avoid conflicts if trigger used + if (method_exists($lines[$i], 'fetch_optionals')) // For avoid conflicts if trigger used { $lines[$i]->fetch_optionals(); $array_options = $lines[$i]->array_options; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index c39a5a05a13..9a13ae1abdf 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3342,7 +3342,7 @@ class Commande extends CommonOrder $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options) > 0) + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) @@ -3437,14 +3437,11 @@ class Commande extends CommonOrder if (!$error) { // Remove extrafields - if ((!$error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used + $result = $this->deleteExtraFields(); + if ($result < 0) { - $result = $this->deleteExtraFields(); - if ($result < 0) - { - $error++; - dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); - } + $error++; + dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); } } @@ -4255,7 +4252,7 @@ class OrderLine extends CommonOrderLine if ($resql) { // Remove extrafields - if ((!$error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used + if (!$error) { $this->id = $this->rowid; $result = $this->deleteExtraFields(); @@ -4401,7 +4398,7 @@ class OrderLine extends CommonOrderLine $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'commandedet'); $this->rowid = $this->id; - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) @@ -4534,7 +4531,7 @@ class OrderLine extends CommonOrderLine $resql = $this->db->query($sql); if ($resql) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $this->id = $this->rowid; $result = $this->insertExtraFields(); diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php index bad5034eac5..f230f7935a5 100644 --- a/htdocs/commande/orderstoinvoice.php +++ b/htdocs/commande/orderstoinvoice.php @@ -285,7 +285,7 @@ if (($action == 'create' || $action == 'add') && !$error) } // Extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { + if (method_exists($lines[$i], 'fetch_optionals')) { $lines[$i]->fetch_optionals(); $array_options = $lines[$i]->array_options; } diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index ab99173b614..58115537b1f 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -823,13 +823,10 @@ class Account extends CommonObject if ($result) { // Actions on extra fields (by external module or standard code) - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { - if (!$error) - { - $result = $this->insertExtraFields(); - if ($result < 0) $error++; - } + $result = $this->insertExtraFields(); + if ($result < 0) $error++; } if (!$error && !$notrigger) @@ -1107,7 +1104,7 @@ class Account extends CommonObject if ($result) { // Remove extrafields - if ((empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used + if (!$error) { $result = $this->deleteExtraFields(); if ($result < 0) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 4f111c26f39..e5cfb1574dc 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1146,7 +1146,7 @@ if (empty($reshook)) foreach ($facture_source->lines as $line) { // Extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($line, 'fetch_optionals')) { + if (method_exists($line, 'fetch_optionals')) { // load extrafields $line->fetch_optionals(); } @@ -1644,7 +1644,7 @@ if (empty($reshook)) } // Extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { + if (method_exists($lines[$i], 'fetch_optionals')) { $lines[$i]->fetch_optionals(); $array_options = $lines[$i]->array_options; } diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 205ca88290e..bbb926f7772 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -342,7 +342,7 @@ class FactureRec extends CommonInvoice if ($objectline->fetch($result_insert)) { // Extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($facsrc->lines[$i], 'fetch_optionals')) { + if (method_exists($facsrc->lines[$i], 'fetch_optionals')) { $facsrc->lines[$i]->fetch_optionals($facsrc->lines[$i]->rowid); $objectline->array_options = $facsrc->lines[$i]->array_options; } @@ -438,7 +438,7 @@ class FactureRec extends CommonInvoice $resql = $this->db->query($sql); if ($resql) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) @@ -2112,7 +2112,7 @@ class FactureLigneRec extends CommonInvoiceLine $resql = $this->db->query($sql); if ($resql) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index b6f9c4d7969..b6f41149331 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1881,7 +1881,7 @@ class Facture extends CommonInvoice $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options) > 0) + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) @@ -5237,7 +5237,7 @@ class FactureLigne extends CommonInvoiceLine $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'facturedet'); $this->rowid = $this->id; // For backward compatibility - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) @@ -5423,7 +5423,7 @@ class FactureLigne extends CommonInvoiceLine $resql = $this->db->query($sql); if ($resql) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $this->id = $this->rowid; $result = $this->insertExtraFields(); diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 7f52195297b..a3cdb1747a0 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -489,7 +489,7 @@ class Contact extends CommonObject $action = 'update'; // Actions on extra fields - if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) @@ -1168,7 +1168,7 @@ class Contact extends CommonObject } // Removed extrafields - if ((!$error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) { + if (!$error) { // For avoid conflicts if trigger used $result = $this->deleteExtraFields(); if ($result < 0) $error++; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 9d240a31a79..322d309b15b 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -316,7 +316,7 @@ if (empty($reshook)) // Extrafields $array_options = array(); // For avoid conflicts if trigger used - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { + if (method_exists($lines[$i], 'fetch_optionals')) { $lines[$i]->fetch_optionals(); $array_options = $lines[$i]->array_options; } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 310aed1cd52..5bf9f1f11c1 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1035,7 +1035,7 @@ class Contrat extends CommonObject } } - if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) @@ -1383,7 +1383,7 @@ class Contrat extends CommonObject $resql = $this->db->query($sql); if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options) > 0) + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) @@ -1588,7 +1588,7 @@ class Contrat extends CommonObject { $contractlineid = $this->db->last_insert_id(MAIN_DB_PREFIX."contratdet"); - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) // For avoid conflicts if trigger used + if (!$error) { $contractline = new ContratLigne($this->db); $contractline->array_options = $array_options; @@ -1777,7 +1777,7 @@ class Contrat extends CommonObject $result = $this->update_statut($user); if ($result >= 0) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) // For avoid conflicts if trigger used + if (is_array($array_options) && count($array_options) > 0) // For avoid conflicts if trigger used { $contractline = new ContratLigne($this->db); $contractline->fetch($rowid); @@ -1859,18 +1859,15 @@ class Contrat extends CommonObject $error++; } - if (empty($error)) { + if (!$error) { // Remove extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + $contractline = new ContratLigne($this->db); + $contractline->id = $idline; + $result = $contractline->deleteExtraFields(); + if ($result < 0) { - $contractline = new ContratLigne($this->db); - $contractline->id = $idline; - $result = $contractline->deleteExtraFields(); - if ($result < 0) - { - $error++; - $this->error = "Error ".get_class($this)."::deleteline deleteExtraFields error -4 ".$contractline->error; - } + $error++; + $this->error = "Error ".get_class($this)."::deleteline deleteExtraFields error -4 ".$contractline->error; } } @@ -3092,7 +3089,7 @@ class ContratLigne extends CommonObjectLine $error++; } - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options) > 0) // For avoid conflicts if trigger used + if (!$error) // For avoid conflicts if trigger used { $result = $this->insertExtraFields(); if ($result < 0) @@ -3202,6 +3199,8 @@ class ContratLigne extends CommonObjectLine { global $conf, $user; + $error = 0; + // Insertion dans la base $sql = "INSERT INTO ".MAIN_DB_PREFIX."contratdet"; $sql .= " (fk_contrat, label, description, fk_product, qty, vat_src_code, tva_tx,"; @@ -3240,7 +3239,7 @@ class ContratLigne extends CommonObjectLine $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'contratdet'); // Insert of extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options) > 0) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index e8cfa803573..ebae28e9582 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -751,7 +751,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders } // Extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { + if (method_exists($lines[$i], 'fetch_optionals')) { $lines[$i]->fetch_optionals(); $array_options = $lines[$i]->array_options; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 20dbdf18fd3..3d8871dc07a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5351,9 +5351,14 @@ abstract class CommonObject * Delete all extra fields values for the current object. * * @return int <0 if KO, >0 if OK + * @see deleteExtraLanguages(), insertExtraField(), updateExtraField(), setValueFrom() */ public function deleteExtraFields() { + global $conf; + + if (!empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return 0; + $this->db->begin(); $table_element = $this->table_element; @@ -5383,18 +5388,18 @@ abstract class CommonObject * @param string $trigger If defined, call also the trigger (for example COMPANY_MODIFY) * @param User $userused Object user * @return int -1=error, O=did nothing, 1=OK - * @see insertExtraLanguages(), updateExtraField(), setValueFrom() + * @see insertExtraLanguages(), updateExtraField(), deleteExtraField(), setValueFrom() */ public function insertExtraFields($trigger = '', $userused = null) { global $conf, $langs, $user; + if (!empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return 0; + if (empty($userused)) $userused = $user; $error = 0; - if (!empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return 0; // For avoid conflicts if trigger used - if (!empty($this->array_options)) { // Check parameters @@ -5792,18 +5797,18 @@ abstract class CommonObject * @param string $trigger If defined, call also the trigger (for example COMPANY_MODIFY) * @param User $userused Object user * @return int -1=error, O=did nothing, 1=OK - * @see updateExtraLanguages(), setValueFrom(), insertExtraFields() + * @see updateExtraLanguages(), insertExtraFields(), deleteExtraFields(), setValueFrom() */ public function updateExtraField($key, $trigger = null, $userused = null) { global $conf, $langs, $user; + if (!empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return 0; + if (empty($userused)) $userused = $user; $error = 0; - if (!empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return 0; // For avoid conflicts if trigger used - if (!empty($this->array_options) && isset($this->array_options["options_".$key])) { // Check parameters @@ -8174,7 +8179,7 @@ abstract class CommonObject } // Update extrafield - if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options) > 0) + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) @@ -8335,7 +8340,7 @@ abstract class CommonObject if (empty($error)) { // Remove extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $tmpobjectline = new $tmpforobjectlineclass($this->db); $tmpobjectline->id = $idline; diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 8260656e4d0..102d7e58685 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -432,7 +432,7 @@ class Don extends CommonObject // Update extrafield if (!$error) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) @@ -519,7 +519,7 @@ class Don extends CommonObject // Update extrafield if (!$error) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 624add5c075..e1c24106e09 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -380,7 +380,7 @@ class Expedition extends CommonObject } // Actions on extra fields - if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) @@ -1046,7 +1046,8 @@ class Expedition extends CommonObject } } $line->entrepot_id = $linebatch->entrepot_id; - $line->origin_line_id = $dbatch['ix_l']; + $line->origin_line_id = $dbatch['ix_l']; // deprecated + $line->fk_origin_line = $dbatch['ix_l']; $line->qty = $dbatch['qty']; $line->detail_batch = $tab; @@ -2617,7 +2618,7 @@ class ExpeditionLigne extends CommonObjectLine { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."expeditiondet"); - if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) @@ -2691,7 +2692,7 @@ class ExpeditionLigne extends CommonObjectLine if (!$error && $this->db->query($sql)) { // Remove extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->deleteExtraFields(); if ($result < 0) @@ -2895,7 +2896,7 @@ class ExpeditionLigne extends CommonObjectLine if (!$error) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index f8a62da7ba6..502eb5ccb69 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -305,7 +305,7 @@ class Fichinter extends CommonObject if (!$resql) $error++; } - if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) @@ -385,7 +385,7 @@ class Fichinter extends CommonObject dol_syslog(get_class($this)."::update", LOG_DEBUG); if ($this->db->query($sql)) { - if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) @@ -1001,7 +1001,7 @@ class Fichinter extends CommonObject if (!$resql) $error++; } - if ((!$error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used + if (!$error) { // Remove extrafields $res = $this->deleteExtraFields(); @@ -1552,7 +1552,7 @@ class FichinterLigne extends CommonObjectLine $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'fichinterdet'); $this->rowid = $this->id; - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) @@ -1623,7 +1623,7 @@ class FichinterLigne extends CommonObjectLine $resql = $this->db->query($sql); if ($resql) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index e5505cbaa9f..c95e403a24c 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2063,7 +2063,7 @@ class CommandeFournisseur extends CommonOrder } // Remove extrafields - if ((!$error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used + if (!$error) { $result = $this->deleteExtraFields(); if ($result < 0) @@ -3626,7 +3626,7 @@ class CommandeFournisseurLigne extends CommonOrderLine $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); $this->rowid = $this->id; - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) @@ -3716,7 +3716,7 @@ class CommandeFournisseurLigne extends CommonOrderLine $result = $this->db->query($sql); if ($result > 0) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) diff --git a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php index d7b8807bb28..041958448fa 100644 --- a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php +++ b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php @@ -362,7 +362,7 @@ class CommandeFournisseurDispatch extends CommonObject if (!$error) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { if (empty($this->id) && !empty($this->rowid))$this->id = $this->rowid; $result = $this->insertExtraFields(); diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index f2f1bac9257..8bbee47a2cd 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -558,7 +558,7 @@ class FactureFournisseur extends CommonInvoice if ($result > 0) { // Actions on extra fields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); // This also set $this->error or $this->errors if errors are found if ($result < 0) @@ -977,7 +977,7 @@ class FactureFournisseur extends CommonInvoice } } - if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) + if (! $error) { $result=$this->insertExtraFields(); if ($result < 0) @@ -1243,7 +1243,7 @@ class FactureFournisseur extends CommonInvoice } // Remove extrafields - if ((!$error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used + if (!$error) { $result = $this->deleteExtraFields(); if ($result < 0) @@ -3145,7 +3145,7 @@ class SupplierInvoiceLine extends CommonObjectLine $this->deleteObjectLinked(); // Remove extrafields - if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used + if (! $error) { $result=$this->deleteExtraFields(); if ($result < 0) @@ -3265,7 +3265,7 @@ class SupplierInvoiceLine extends CommonObjectLine $this->rowid = $this->id; $error = 0; - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) @@ -3406,7 +3406,7 @@ class SupplierInvoiceLine extends CommonObjectLine $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); $this->rowid = $this->id; // backward compatibility - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index bc86076644c..f2ab694e352 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1064,7 +1064,7 @@ if (empty($reshook)) if (!$error) { // Actions on extra fields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $object->insertExtraFields('ORDER_SUPPLIER_MODIFY'); if ($result < 0) @@ -1190,7 +1190,7 @@ if (empty($reshook)) } // Extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) // For avoid conflicts if + if (method_exists($lines[$i], 'fetch_optionals')) // For avoid conflicts if { $lines[$i]->fetch_optionals(); $array_option = $lines[$i]->array_options; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 697c8cb74f0..0b63356480c 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -951,7 +951,7 @@ if (empty($reshook)) $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); // Extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { + if (method_exists($lines[$i], 'fetch_optionals')) { $lines[$i]->fetch_optionals(); } @@ -1597,7 +1597,7 @@ if (empty($reshook)) if (!$error) { // Actions on extra fields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $object->insertExtraFields('BILL_SUPPLIER_MODIFY'); if ($result < 0) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index c37dbaeb3f7..4f4334e4125 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1052,7 +1052,7 @@ class Product extends CommonObject $action = 'update'; // Actions on extra fields - if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) { $error++; @@ -1265,7 +1265,7 @@ class Product extends CommonObject } // Remove extrafields - if ((!$error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used + if (!$error) { $result = $this->deleteExtraFields(); if ($result < 0) { diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 3dd22c9e5c3..db2f84db15a 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -221,7 +221,7 @@ class Entrepot extends CommonObject // Actions on extra fields if (!$error) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) @@ -319,7 +319,7 @@ class Entrepot extends CommonObject $this->errors[] = "Error ".$this->db->lasterror(); } - if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options) > 0) { + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) { @@ -383,7 +383,7 @@ class Entrepot extends CommonObject // Removed extrafields if (!$error) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->deleteExtraFields(); if ($result < 0) diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 6db4e81db79..f0a5c0a48ea 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -185,7 +185,7 @@ class Productlot extends CommonObject $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); // Actions on extra fields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) @@ -359,7 +359,7 @@ class Productlot extends CommonObject } // Actions on extra fields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 0e793361d2b..674db2cc5d6 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -316,7 +316,7 @@ class Project extends CommonObject // Update extrafield if (!$error) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) @@ -405,7 +405,7 @@ class Project extends CommonObject // Update extrafield if (!$error) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index f3f75b716c1..41f6a76afb2 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -205,7 +205,7 @@ class Task extends CommonObject // Update extrafield if (!$error) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) @@ -384,7 +384,7 @@ class Task extends CommonObject // Update extrafield if (!$error) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index b09a5918def..2bb34859a6b 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -750,7 +750,7 @@ class Reception extends CommonObject } // extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) // For avoid conflicts if trigger used + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) $line->array_options = $array_options; $line->fk_product = $fk_product; diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 75c6e50dec3..4cda97b39d1 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -136,7 +136,7 @@ class Dolresource extends CommonObject $action = 'create'; // Actions on extra fields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) @@ -309,7 +309,7 @@ class Dolresource extends CommonObject $action = 'update'; // Actions on extra fields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) diff --git a/htdocs/salaries/class/paymentsalary.class.php b/htdocs/salaries/class/paymentsalary.class.php index 44c25b09a13..82cdf3c80ce 100644 --- a/htdocs/salaries/class/paymentsalary.class.php +++ b/htdocs/salaries/class/paymentsalary.class.php @@ -160,7 +160,7 @@ class PaymentSalary extends CommonObject // Update extrafield if (!$error) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) @@ -449,7 +449,7 @@ class PaymentSalary extends CommonObject // Update extrafield if (!$error) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index ea175c13c6a..c35b17fe4fa 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1393,7 +1393,7 @@ class Societe extends CommonObject $action = 'update'; // Actions on extra fields - if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) @@ -1771,7 +1771,7 @@ class Societe extends CommonObject } // Removed extrafields - if ((!$error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used + if (!$error) { $result = $this->deleteExtraFields(); if ($result < 0) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 5910f77a819..ee9f5a1d072 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -353,7 +353,7 @@ if (empty($reshook)) } // Extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { + if (method_exists($lines[$i], 'fetch_optionals')) { $lines[$i]->fetch_optionals(); $array_options = $lines[$i]->array_options; } diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 3e69fbc167f..52bb42c4526 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1063,7 +1063,7 @@ class SupplierProposal extends CommonObject $action = 'update'; // Actions on extra fields - if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) @@ -2116,16 +2116,13 @@ class SupplierProposal extends CommonObject // Removed extrafields if (!$error) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $result = $this->deleteExtraFields(); - if ($result < 0) - { - $error++; - $errorflag = -4; - dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR); - } - } + $result = $this->deleteExtraFields(); + if ($result < 0) + { + $error++; + $errorflag = -4; + dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR); + } } if (!$error) @@ -3106,7 +3103,7 @@ class SupplierProposalLine extends CommonObjectLine { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'supplier_proposaldet'); - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) @@ -3155,7 +3152,7 @@ class SupplierProposalLine extends CommonObjectLine if ($this->db->query($sql)) { // Remove extrafields - if ((!$error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used + if (!$error) { $result = $this->deleteExtraFields(); if ($result < 0) @@ -3277,7 +3274,7 @@ class SupplierProposalLine extends CommonObjectLine $resql = $this->db->query($sql); if ($resql) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 863c0c03072..172309a233e 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -408,11 +408,9 @@ class Ticket extends CommonObject //Update extrafield if (!$error) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { // For avoid conflicts if trigger used - $result = $this->insertExtraFields(); - if ($result < 0) { - $error++; - } + $result = $this->insertExtraFields(); + if ($result < 0) { + $error++; } } @@ -838,11 +836,9 @@ class Ticket extends CommonObject if (!$error) { // Update extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { // For avoid conflicts if trigger used - $result = $this->insertExtraFields(); - if ($result < 0) { - $error++; - } + $result = $this->insertExtraFields(); + if ($result < 0) { + $error++; } } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index f944083f6c5..24bf871af1f 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1094,7 +1094,7 @@ class User extends CommonObject } // Remove extrafields - if ((!$error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used + if (!$error) { $result = $this->deleteExtraFields(); if ($result < 0) @@ -1762,7 +1762,7 @@ class User extends CommonObject $action = 'update'; // Actions on extra fields - if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) + if (!$error) { $result = $this->insertExtraFields(); if ($result < 0)