diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 537b6f76a63..5d7664b13aa 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -464,7 +464,7 @@ class Adherent extends CommonObject $action='update'; // Actions on extra fields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { $result=$this->insertExtraFields(); if ($result < 0) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 75f518074b1..ca8372c04ed 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -142,7 +142,7 @@ class AdherentType extends CommonObject /** * Met a jour en base donnees du type * - * @param User $user Object user making change + * @param User $user Object user making change * @param int $notrigger 1=do not execute triggers, 0 otherwise * @return int >0 if OK, < 0 if KO */ @@ -172,7 +172,7 @@ class AdherentType extends CommonObject $action='update'; // Actions on extra fields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { $result=$this->insertExtraFields(); if ($result < 0) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 9ebd4a85e5e..e49fe43e2c9 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1464,6 +1464,8 @@ class Propal extends CommonObject */ function update(User $user, $notrigger=0) { + global $conf; + $error=0; // Clean parameters @@ -1512,17 +1514,23 @@ class Propal extends CommonObject $error++; $this->errors[]="Error ".$this->db->lasterror(); } - if (! $error) + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) { - if (! $notrigger) + $result=$this->insertExtraFields(); + if ($result < 0) { - // Call trigger - $result=$this->call_trigger('PROPAL_MODIFY', $user); - if ($result < 0) $error++; - // End call triggers + $error++; } } + if (! $error && ! $notrigger) + { + // Call trigger + $result=$this->call_trigger('PROPAL_MODIFY', $user); + if ($result < 0) $error++; + // End call triggers + } + // Commit or rollback if ($error) { diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index fd903c4fcfb..ecd2be95d7a 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3067,17 +3067,23 @@ class Commande extends CommonOrder $error++; $this->errors[]="Error ".$this->db->lasterror(); } - if (! $error) + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) { - if (! $notrigger) + $result=$this->insertExtraFields(); + if ($result < 0) { - // Call trigger - $result=$this->call_trigger('ORDER_MODIFY', $user); - if ($result < 0) $error++; - // End call triggers + $error++; } } + if (! $error && ! $notrigger) + { + // Call trigger + $result=$this->call_trigger('ORDER_MODIFY', $user); + if ($result < 0) $error++; + // End call triggers + } + // Commit or rollback if ($error) { diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index c6e43206c78..93a97eaee1a 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1549,6 +1549,8 @@ class Facture extends CommonInvoice */ function update(User $user, $notrigger=0) { + global $conf; + $error=0; // Clean parameters @@ -1614,17 +1616,23 @@ class Facture extends CommonInvoice $error++; $this->errors[]="Error ".$this->db->lasterror(); } - if (! $error) + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) { - if (! $notrigger) + $result=$this->insertExtraFields(); + if ($result < 0) { - // Call trigger - $result=$this->call_trigger('BILL_MODIFY',$user); - if ($result < 0) $error++; - // End call triggers + $error++; } } + if (! $error && ! $notrigger) + { + // Call trigger + $result=$this->call_trigger('BILL_MODIFY',$user); + if ($result < 0) $error++; + // End call triggers + } + // Commit or rollback if ($error) { diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 013751e8282..d7df30d5ee5 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -371,15 +371,12 @@ class Contact extends CommonObject $action='update'; // Actions on extra fields - if (! $error) + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { - 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++; } } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 640793b7f37..a867d8937c9 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -925,16 +925,13 @@ class Contrat extends CommonObject } } - if (! $error) + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { - 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++; + } } // Insert contacts commerciaux ('SALESREPSIGN','contrat') @@ -1283,18 +1280,7 @@ class Contrat extends CommonObject $resql = $this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - if (! $error) - { - if (! $notrigger) - { - // Call triggers - $result=$this->call_trigger('CONTRACT_MODIFY',$user); - if ($result < 0) { $error++; } - // End call triggers - } - } - - if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) { $result=$this->insertExtraFields(); if ($result < 0) @@ -1303,6 +1289,14 @@ class Contrat extends CommonObject } } + if (! $error && ! $notrigger) + { + // Call triggers + $result=$this->call_trigger('CONTRACT_MODIFY',$user); + if ($result < 0) { $error++; } + // End call triggers + } + // Commit or rollback if ($error) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 1dfc9c90718..6fc7467bb9d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7044,15 +7044,12 @@ abstract class CommonObject } // Update extrafield - if (! $error) + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) { - 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++; } } diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 4042b202300..5728d60932a 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -313,7 +313,7 @@ class Expedition extends CommonObject } // Actions on extra fields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { $result=$this->insertExtraFields(); if ($result < 0) @@ -541,8 +541,7 @@ class Expedition extends CommonObject */ $result=$this->fetch_thirdparty(); - // Retreive all extrafield - // fetch optionals attributes and labels + // Retreive extrafields $this->fetch_optionals(); /* @@ -2412,7 +2411,8 @@ class ExpeditionLigne extends CommonObjectLine if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."expeditiondet"); - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { $result=$this->insertExtraFields(); if ($result < 0) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 370fed20768..d14419f49b0 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -222,7 +222,7 @@ class Fichinter extends CommonObject if (! $resql) $error++; } - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { $result=$this->insertExtraFields(); if ($result < 0) @@ -285,6 +285,8 @@ class Fichinter extends CommonObject $this->fk_project = 0; } + $error = 0; + $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter SET "; @@ -299,8 +301,16 @@ 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 + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } - if (! $notrigger) + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('FICHINTER_MODIFY',$user); @@ -372,8 +382,7 @@ class Fichinter extends CommonObject if ($this->statut == 0) $this->brouillon = 1; - // Retreive all extrafield - // fetch optionals attributes and labels + // Retreive extrafields $this->fetch_optionals(); /* diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index c271346d4bc..d9e393575df 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -916,7 +916,7 @@ class Product extends CommonObject $action='update'; // Actions on extra fields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { $result=$this->insertExtraFields(); if ($result < 0) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index f5b291ba2a0..38d07e8e4db 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -754,6 +754,7 @@ class Societe extends CommonObject function update($id, $user='', $call_trigger=1, $allowmodcodeclient=0, $allowmodcodefournisseur=0, $action='update', $nosyncmember=1) { global $langs,$conf,$hookmanager; + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; if (empty($id)) $id = $this->id; @@ -1053,7 +1054,7 @@ class Societe extends CommonObject $action='update'; // Actions on extra fields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { $result=$this->insertExtraFields(); if ($result < 0) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 54672da2b75..c3b6e4b3338 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1013,7 +1013,7 @@ class SupplierProposal extends CommonObject $action='update'; // Actions on extra fields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { $result=$this->insertExtraFields(); if ($result < 0) @@ -1022,7 +1022,7 @@ class SupplierProposal extends CommonObject } } - if (! $erro && ! $notrigger) + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('PROPAL_SUPPLIER_CREATE',$user); diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 8e3ae7222fb..fed37fc0d5a 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -135,7 +135,7 @@ class User extends CommonObject public $default_c_exp_tax_cat; public $default_range; - + public $fields=array( 'rowid'=>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), 'lastname'=>array('type'=>'varchar(50)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20, 'searchall'=>1, 'comment'=>'Reference of object'), @@ -1581,7 +1581,7 @@ class User extends CommonObject $action='update'; // Actions on extra fields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { $result=$this->insertExtraFields(); if ($result < 0)