diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 760791027cb..899ba0c9db7 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -463,24 +463,15 @@ class Adherent extends CommonObject $action='update'; - // Actions on extra fields (by external module) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('memberdao')); - $parameters=array('id'=>$this->id); - $action=''; - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) + // Actions on extra fields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - 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++; } } - else if ($reshook < 0) $error++; // Update password if (! $error && $this->pass) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index f1b44d3f1e7..75f518074b1 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -171,22 +171,15 @@ class AdherentType extends CommonObject { $action='update'; - // Actions on extra fields (by external module or standard code) - $hookmanager->initHooks(array('membertypedao')); - $parameters=array('membertype'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) + // Actions on extra fields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - 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++; } } - else if ($reshook < 0) $error++; if (! $error && ! $notrigger) { diff --git a/htdocs/assets/class/asset_type.class.php b/htdocs/assets/class/asset_type.class.php index 9889ceeb5d1..d4d12916e9a 100644 --- a/htdocs/assets/class/asset_type.class.php +++ b/htdocs/assets/class/asset_type.class.php @@ -155,22 +155,15 @@ class AssetType extends CommonObject { $action='update'; - // Actions on extra fields (by external module or standard code) - $hookmanager->initHooks(array('assettypedao')); - $parameters=array('assettype'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) + // Actions on extra fields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - 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++; } } - else if ($reshook < 0) $error++; if (! $error && ! $notrigger) { diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index d8d5b10a2b5..71240d63d8f 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -338,28 +338,23 @@ class Categorie extends CommonObject $action='create'; - // Actions on extra fields (by external module or standard code) - // TODO the hook duplicates the trigger !! - $hookmanager->initHooks(array('HookModuleNamedao')); - $parameters=array('socid'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) + // Actions on extra fields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - 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++; } } - else if ($reshook < 0) $error++; - // Call trigger - $result=$this->call_trigger('CATEGORY_CREATE',$user); - if ($result < 0) { $error++; } - // End call triggers + if (! $error) + { + // Call trigger + $result=$this->call_trigger('CATEGORY_CREATE',$user); + if ($result < 0) { $error++; } + // End call triggers + } if ( ! $error ) { @@ -432,28 +427,23 @@ class Categorie extends CommonObject { $action='update'; - // Actions on extra fields (by external module or standard code) - // TODO the hook duplicates the trigger !! - $hookmanager->initHooks(array('HookCategorydao')); - $parameters=array(); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) + // Actions on extra fields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - 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++; } } - else if ($reshook < 0) $error++; - // Call trigger - $result=$this->call_trigger('CATEGORY_MODIFY',$user); - if ($result < 0) { $error++; $this->db->rollback(); return -1; } - // End call triggers + if (! $error) + { + // Call trigger + $result=$this->call_trigger('CATEGORY_MODIFY',$user); + if ($result < 0) { $error++; $this->db->rollback(); return -1; } + // End call triggers + } $this->db->commit(); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 7960bbd764d..5234a05db43 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -384,23 +384,15 @@ class ActionComm extends CommonObject { $action='create'; - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('actioncommdao')); - $parameters=array('actcomm'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) - { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $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++; + } } - else if ($reshook < 0) $error++; } if (! $error && ! $notrigger) @@ -865,23 +857,15 @@ class ActionComm extends CommonObject { $action='update'; - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('actioncommdao')); - $parameters=array('actcomm'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) - { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $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++; + } } - else if ($reshook < 0) $error++; // Now insert assignedusers if (! $error) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 6e98329a4cc..68abd9f9a3f 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1114,12 +1114,8 @@ class Propal extends CommonObject { $action='update'; - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('propaldao')); - $parameters=array('socid'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) + // Actions on extra fields + if (! $error) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { @@ -1130,9 +1126,8 @@ class Propal extends CommonObject } } } - else if ($reshook < 0) $error++; - if (! $notrigger) + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('PROPAL_CREATE',$user); @@ -3953,7 +3948,7 @@ class PropaleLigne extends CommonObjectLine } } - if (! $notrigger) + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('LINEPROPAL_INSERT',$user); @@ -4136,7 +4131,7 @@ class PropaleLigne extends CommonObjectLine } } - if (! $notrigger) + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('LINEPROPAL_UPDATE',$user); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 57aa7ce8b04..b3757021ee8 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1269,24 +1269,16 @@ if (empty($reshook)) if (! $error) { - // Actions on extra fields (by external module or standard code) - $hookmanager->initHooks(array('orderdao')); - $parameters = array('id' => $object->id); - $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by - // some hooks - if (empty($reshook)) { - $result = $object->insertExtraFields('ORDER_MODIFY'); - if ($result < 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - } - } else if ($reshook < 0) + // Actions on extra fields + $result = $object->insertExtraFields('ORDER_MODIFY'); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); $error++; + } } - if ($error) - $action = 'edit_extras'; + if ($error) $action = 'edit_extras'; } if ($action == 'set_thirdparty' && $user->rights->commande->creer) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index dd0e41ee836..0c63da5d4c2 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -4208,7 +4208,7 @@ class OrderLine extends CommonOrderLine } } - if (! $notrigger) + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('LINEORDER_UPDATE',$user); diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 7cd8b8e07b8..044ca7da392 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2117,7 +2117,7 @@ if (empty($reshook)) $fromElement = GETPOST('fromelement'); $fromElementid = GETPOST('fromelementid'); $importLines = GETPOST('line_checkbox'); - + if(!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) { if($fromElement == 'commande') @@ -2164,7 +2164,7 @@ if (empty($reshook)) $fk_prev_id = ''; $fk_unit = $originLine->fk_unit; $pu_ht_devise = $originLine->multicurrency_subprice; - + $res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $ventil, $info_bits, $fk_remise_except, $price_base_type, $pu_ttc, $type, $rang, $special_code, $origin, $origin_id, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $array_options, $situation_percent, $fk_prev_id, $fk_unit,$pu_ht_devise); if($res > 0){ $importCount++; @@ -2172,18 +2172,18 @@ if (empty($reshook)) $error++; } } - else{ - $error++; + else{ + $error++; } } - + if($error) { setEventMessage($langs->trans('ErrorsOnXLines',$error), 'errors'); } } } - + // Actions when printing a doc from card include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; @@ -2209,22 +2209,15 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); if ($ret < 0) $error++; - if (! $error) { - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('invoicedao')); - $parameters = array('id' => $object->id); - $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by - // some hooks - if (empty($reshook)) { - $result = $object->insertExtraFields('BILL_MODIFY'); - if ($result < 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - } - } else if ($reshook < 0) - $error ++; + if (! $error) + { + // Actions on extra fields + $result = $object->insertExtraFields('BILL_MODIFY'); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } } if ($error) @@ -4537,16 +4530,16 @@ else if ($id > 0 || ! empty($ref)) // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('invoice')); - + $compatibleImportElementsList = false; - if($user->rights->facture->creer - && $object->statut == Facture::STATUS_DRAFT + if($user->rights->facture->creer + && $object->statut == Facture::STATUS_DRAFT && ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) ) { $compatibleImportElementsList = array('commande'); // import from linked elements } $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem,$compatibleImportElementsList); - + // Show online payment link $useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled)); diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 8759f2eebf3..aebce8e4b07 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -1791,7 +1791,7 @@ class FactureLigneRec extends CommonInvoiceLine } } - if (! $notrigger) + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('LINEBILL_REC_UPDATE',$user); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 77238e5b62d..343bbbe6414 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -750,35 +750,20 @@ class Facture extends CommonInvoice { $action='create'; - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - /* - $hookmanager->initHooks(array('invoicedao')); - $parameters=array('invoiceid'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) - { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - {*/ + // Actions on extra fields if (! $error) { $result=$this->insertExtraFields(); if ($result < 0) $error++; } - /*} - } - else if ($reshook < 0) $error++;*/ - if (! $error) - { - if (! $notrigger) - { - // Call trigger - $result=$this->call_trigger('BILL_CREATE',$user); - if ($result < 0) $error++; - // End call triggers - } - } + if (! $error && ! $notrigger) + { + // Call trigger + $result=$this->call_trigger('BILL_CREATE',$user); + if ($result < 0) $error++; + // End call triggers + } if (! $error) { @@ -4697,7 +4682,7 @@ class FactureLigne extends CommonInvoiceLine } } - if (! $notrigger) + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('LINEBILL_UPDATE',$user); diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 6f96e74d345..33132620662 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -417,7 +417,8 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); if ($ret < 0) $error++; - if (! $error) { + if (! $error) + { $result = $object->insertExtraFields('BILLREC_MODIFY'); if ($result < 0) { diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 83ad411b4b6..898144f993a 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -366,11 +366,8 @@ class Contact extends CommonObject $action='update'; - // Actions on extra fields (by external module or standard code) - $hookmanager->initHooks(array('contactdao')); - $parameters=array('socid'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) + // Actions on extra fields + if (! $error) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { @@ -381,7 +378,6 @@ class Contact extends CommonObject } } } - else if ($reshook < 0) $error++; if (! $error && $this->user_id > 0) { diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 86bfe2e6823..4be83ffa30a 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -396,7 +396,7 @@ class Don extends CommonObject } // Update extrafield - if (!$error) { + if (! $error) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { $result=$this->insertExtraFields(); @@ -482,7 +482,7 @@ class Don extends CommonObject } // Update extrafield - if (!$error) + if (! $error) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 719f738d081..89f1aee7b4b 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -164,20 +164,13 @@ if (empty($reshook)) if (! $error) { - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('expeditiondao')); - $parameters = array('id' => $object->id); - $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) { - $result = $object->insertExtraFields('SHIPMENT_MODIFY'); - if ($result < 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - } - } else if ($reshook < 0) - $error++; + // Actions on extra fields + $result = $object->insertExtraFields('SHIPMENT_MODIFY'); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } } if ($error) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 05328d57b05..dd3123930fe 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -311,23 +311,15 @@ class Expedition extends CommonObject } } - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('expeditiondao')); - $parameters=array('socid'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) + // Actions on extra fields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - 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++; } } - else if ($reshook < 0) $error++; if (! $error && ! $notrigger) { @@ -1105,7 +1097,7 @@ class Expedition extends CommonObject $error++; } - if (! $error) + if (! $error) { if (! $notrigger) { @@ -2690,19 +2682,21 @@ class ExpeditionLigne extends CommonObjectLine $this->errors[]=$this->db->lasterror()." - sql=$sql"; $error++; } - else + } + + if (! $error) + { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - 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) - { - $this->errors[]=$this->error; - $error++; - } + $this->errors[]=$this->error; + $error++; } } } + if (! $error && ! $notrigger) { // Call trigger diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index e3218d5f578..ac1368660da 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -189,20 +189,13 @@ if (empty($reshook)) if (! $error) { - // Actions on extra fields (by external module or standard code) - $hookmanager->initHooks(array('orderdao')); - $parameters = array('id' => $object->id); - $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by - // some hooks - if (empty($reshook)) { - $result = $object->insertExtraFields('SHIPMENT_MODIFY'); - if ($result < 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - } - } else if ($reshook < 0) - $error++; + // Actions on extra fields + $result = $object->insertExtraFields('SHIPMENT_MODIFY'); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } } if ($error) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index eea3545bb07..33bf5245e62 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -288,20 +288,13 @@ if (empty($reshook)) if (! $error) { - // Actions on extra fields (by external module or standard code) - $hookmanager->initHooks(array('expensereportdao')); - $parameters = array('id' => $object->id); - $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by - // some hooks - if (empty($reshook)) { - $result = $object->insertExtraFields('FICHINTER_MODIFY'); - if ($result < 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - } - } else if ($reshook < 0) - $error++; + // Actions on extra fields + $result = $object->insertExtraFields('FICHINTER_MODIFY'); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } } if ($error) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index b4a2b58a18e..01e7e1d7160 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -750,20 +750,12 @@ if (empty($reshook)) if (! $error) { - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('interventiondao')); - $parameters=array('id'=>$object->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) + // Actions on extra fields + $result=$object->insertExtraFields('INTERVENTION_MODIFY'); + if ($result < 0) { - $result=$object->insertExtraFields('INTERVENTION_MODIFY'); - if ($result < 0) - { - $error++; - } + $error++; } - else if ($reshook < 0) $error++; } if ($error) $action = 'edit_extras'; diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 1204830fb0f..9f596e61279 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -253,7 +253,7 @@ class Fichinter extends CommonObject } - if (! $notrigger) + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('FICHINTER_CREATE',$user); diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index af36e6d572e..14b9a490da9 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -121,11 +121,13 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; + if (! $error) { $result = $object->insertExtraFields('COMPANY_MODIFY'); if ($result < 0) $error++; } + if ($error) $action = 'edit_extras'; } } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 04e22501b95..07788e55947 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3259,7 +3259,6 @@ class CommandeFournisseurLigne extends CommonOrderLine if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); if ($result < 0) { @@ -3347,7 +3346,6 @@ class CommandeFournisseurLigne extends CommonOrderLine { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); if ($result < 0) { diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 2a9198f0380..35addb8ee13 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -444,23 +444,15 @@ class FactureFournisseur extends CommonInvoice { $action='create'; - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('supplierinvoicedao')); - $parameters=array('socid'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) + // Actions on extra fields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + $result=$this->insertExtraFields(); // This also set $this->error or $this->errors if errors are found + if ($result < 0) { - $result=$this->insertExtraFields(); // This also set $this->error or $this->errors if errors are found - if ($result < 0) - { - $error++; - } + $error++; } } - else if ($reshook < 0) $error++; if (! $error) { @@ -2830,7 +2822,9 @@ class SupplierInvoiceLine extends CommonObjectLine if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - if ($this->insertExtraFields() < 0) { + $result = $this->insertExtraFields(); + if ($result < 0) + { $error++; } } @@ -2976,7 +2970,7 @@ class SupplierInvoiceLine extends CommonObjectLine } } - if (! $notrigger) + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('LINEBILL_SUPPLIER_CREATE',$user); diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 31574a4b3c0..89a508ea2ec 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -955,32 +955,19 @@ if (empty($reshook)) if (! $error) { - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('supplierorderdao')); - $parameters=array('id'=>$object->id); - - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - - if (empty($reshook)) + // Actions on extra fields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + $result=$object->insertExtraFields('ORDER_SUPPLIER_MODIFY'); + if ($result < 0) { - $result=$object->insertExtraFields('ORDER_SUPPLIER_MODIFY'); - - if ($result < 0) - { - $error++; - } - + $error++; } } - else if ($reshook < 0) $error++; } - else - { + + if ($error) $action = 'edit_extras'; - } } /* diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index d0d3b505245..35b81b39a71 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1459,35 +1459,21 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute', 'none')); if ($ret < 0) $error++; - if (!$error) + if (! $error) { - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('supplierinvoicedao')); - $parameters=array('id'=>$object->id); - - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - - if (empty($reshook)) + // Actions on extra fields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + $result=$object->insertExtraFields('BILL_SUPPLIER_MODIFY'); + if ($result < 0) { - - $result=$object->insertExtraFields('BILL_SUPPLIER_MODIFY'); - - if ($result < 0) - { - $error++; - } - + $error++; } } - else if ($reshook < 0) $error++; } - else - { + + if ($error) $action = 'edit_extras'; - } } if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->fournisseur->facture->creer) diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php index 0e61adcb279..b6b25424e65 100644 --- a/htdocs/livraison/card.php +++ b/htdocs/livraison/card.php @@ -202,20 +202,13 @@ if ($action == 'update_extras') if (! $error) { - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('livraisondao')); - $parameters = array('id' => $object->id); - $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) { - $result = $object->insertExtraFields('DELIVERY_MODIFY'); - if ($result < 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - } - } else if ($reshook < 0) + // Actions on extra fields + $result = $object->insertExtraFields('DELIVERY_MODIFY'); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); $error++; + } } if ($error) diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php index d0d24d39144..46b3c113ff2 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -540,7 +540,7 @@ class Livraison extends CommonObject global $conf; $error = 0; - if ($id > 0 && !$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used + if ($id > 0 && ! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used { $livraisonline = new LivraisonLigne($this->db); $livraisonline->array_options=$array_options; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index cd79259c9a2..7135f2b20ab 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -926,22 +926,15 @@ class Product extends CommonObject $action='update'; - // Actions on extra fields (by external module or standard code) - $hookmanager->initHooks(array('productdao')); - $parameters=array('id'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) + // Actions on extra fields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - 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++; } } - else if ($reshook < 0) $error++; if (! $error && ! $notrigger) { diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index f269e260b25..937e6c1240f 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -131,20 +131,13 @@ if (empty($reshook)) if (! $error) { - // Actions on extra fields (by external module or standard code) - $hookmanager->initHooks(array('productlotdao')); - $parameters = array('id' => $object->id); - $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by - // some hooks - if (empty($reshook)) { - $result = $object->insertExtraFields('PRODUCT_LOT_MODIFY'); - if ($result < 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - } - } else if ($reshook < 0) - $error++; + // Actions on extra fields + $result = $object->insertExtraFields('PRODUCT_LOT_MODIFY'); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } } if ($error) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index ba200ddcfb0..6a0850c9191 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -223,7 +223,7 @@ class Project extends CommonObject } // Update extrafield - if (!$error) { + if (! $error) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { $result=$this->insertExtraFields(); @@ -234,13 +234,13 @@ class Project extends CommonObject } } - if (!$error && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS)) + if (! $error && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS)) { $res = $this->setValid($user); if ($res < 0) $error++; } - if (!$error) + if (! $error) { $this->db->commit(); return $ret; @@ -320,7 +320,7 @@ class Project extends CommonObject } } - if (! $error && !$notrigger) + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('PROJECT_MODIFY',$user); diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 28b3c9b12f3..57b705e2286 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -333,6 +333,18 @@ class Task extends CommonObject $resql = $this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + // Update extrafield + if (! $error) { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + } + if (! $error) { if (! $notrigger) @@ -344,18 +356,6 @@ class Task 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++; - } - } - } - if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) { // We remove directory diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 7db33a9bfae..7c3999db7c9 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -119,23 +119,15 @@ class Dolresource extends CommonObject { $action='create'; - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('actioncommdao')); - $parameters=array('actcomm'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) - { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $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++; + } } - else if ($reshook < 0) $error++; } if (! $error) @@ -305,23 +297,15 @@ class Dolresource extends CommonObject { $action='update'; - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('actioncommdao')); - $parameters=array('actcomm'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) + // Actions on extra fields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - 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++; } } - else if ($reshook < 0) $error++; } // Commit or rollback diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 2a896df0170..c1a62204331 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1056,23 +1056,15 @@ class Societe extends CommonObject $action='update'; - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('thirdpartydao')); - $parameters=array('socid'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) + // Actions on extra fields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - 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++; } } - else if ($reshook < 0) $error++; if (! $error && $call_trigger) { diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index ce70fe996d3..8a6068f7116 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -960,24 +960,17 @@ class SupplierProposal extends CommonObject { $action='update'; - // Actions on extra fields (by external module or standard code) - $hookmanager->initHooks(array('supplier_proposaldao')); - $parameters=array('socid'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) - { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $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++; + } } - else if ($reshook < 0) $error++; - if (! $notrigger) + if (! $erro && ! $notrigger) { // Call trigger $result=$this->call_trigger('PROPAL_SUPPLIER_CREATE',$user); @@ -2885,7 +2878,7 @@ class SupplierProposalLine extends CommonObjectLine } } - if (! $notrigger) + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('LINESUPPLIER_PROPOSAL_INSERT',$user); @@ -3061,7 +3054,7 @@ class SupplierProposalLine extends CommonObjectLine } } - if (! $notrigger) + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('LINESUPPLIER_PROPOSAL_UPDATE',$user); diff --git a/htdocs/ticketsup/class/ticketsup.class.php b/htdocs/ticketsup/class/ticketsup.class.php index ed27003846b..4375d141041 100644 --- a/htdocs/ticketsup/class/ticketsup.class.php +++ b/htdocs/ticketsup/class/ticketsup.class.php @@ -400,7 +400,7 @@ class Ticketsup extends CommonObject } //Update extrafield - if (!$error) { + if (! $error) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { // For avoid conflicts if trigger used $result = $this->insertExtraFields(); if ($result < 0) { @@ -822,32 +822,25 @@ class Ticketsup extends CommonObject $this->errors[] = "Error " . $this->db->lasterror(); } - if (!$error) { - // FIXME le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('TicketSupDao')); - $parameters = array('ticketsupid' => $this->id); - $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { // For avoid conflicts if trigger used - $result = $this->insertExtraFields(); - if ($result < 0) { - $error++; - } - } - } elseif ($reshook < 0) { - $error++; - } - - if (!$notrigger) { - // Call trigger - $result=$this->call_trigger('TICKET_MODIFY', $user); - if ($result < 0) { + if (! $error) { + // Update extrafields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { // For avoid conflicts if trigger used + $result = $this->insertExtraFields(); + if ($result < 0) { $error++; } - // End call triggers } } + if (! $error && ! $notrigger) { + // Call trigger + $result=$this->call_trigger('TICKET_MODIFY', $user); + if ($result < 0) { + $error++; + } + // End call triggers + } + // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 6d992246eea..9df599dd0bc 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1572,7 +1572,7 @@ class User extends CommonObject $action='update'; - // Actions on extra fields (by external module or standard code) + // Actions on extra fields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { $result=$this->insertExtraFields();