From c186f132181f519bb0ec30f66998e048ae982a84 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 15 Nov 2014 19:04:21 +0100 Subject: [PATCH] Fix: Param $action was not defined. A better fix must be done later be removing useless hooks that are duplicate with triggers. --- htdocs/adherents/class/adherent.class.php | 5 ++- htdocs/categories/class/categorie.class.php | 8 +++-- htdocs/comm/action/class/actioncomm.class.php | 7 +++- htdocs/comm/propal/class/propal.class.php | 6 +++- htdocs/commande/class/commande.class.php | 6 +++- htdocs/compta/facture/class/facture.class.php | 2 ++ htdocs/contact/class/contact.class.php | 2 ++ .../class/fournisseur.commande.class.php | 2 ++ .../fourn/class/fournisseur.facture.class.php | 2 ++ htdocs/product/class/product.class.php | 2 ++ htdocs/societe/class/societe.class.php | 2 ++ htdocs/user/class/user.class.php | 3 ++ htdocs/user/class/usergroup.class.php | 35 +++++++++++-------- 13 files changed, 61 insertions(+), 21 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index cdbfabf4576..714fd2af3ca 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -465,8 +465,11 @@ class Adherent extends CommonObject $nbrowsaffected+=$this->db->affected_rows($resql); + $action='update'; + // Actions on extra fields (by external module) - $hookmanager->initHooks(array('memberdao')); + // FIXME 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 diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 5af59689c18..de8d494f9fc 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -198,11 +198,13 @@ class Categorie extends CommonObject { $this->id = $id; + $action='create'; + // Actions on extra fields (by external module or standard code) // FIXME le hook fait double emploi avec le trigger !! $hookmanager->initHooks(array('HookModuleNamedao')); $parameters=array('socid'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,'create'); // Note that $action and $object may have been modified by some hooks + $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 @@ -289,12 +291,14 @@ class Categorie extends CommonObject dol_syslog(get_class($this)."::update", LOG_DEBUG); if ($this->db->query($sql)) { + $action='update'; // Actions on extra fields (by external module or standard code) // FIXME le hook fait double emploi avec le trigger !! $hookmanager->initHooks(array('HookCategorydao')); $parameters=array(); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,'update'); // Note that $action and $object may have been modified by some hooks + $action='update'; + $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 diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index b4a5fdeed60..34e88dd893e 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -241,8 +241,11 @@ class ActionComm extends CommonObject if (! $error) { + $action='create'; + // Actions on extra fields (by external module or standard code) - $hookmanager->initHooks(array('actioncommdao')); + // FIXME 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)) @@ -560,8 +563,10 @@ class ActionComm extends CommonObject dol_syslog(get_class($this)."::update", LOG_DEBUG); if ($this->db->query($sql)) { + $action='update'; // Actions on extra fields (by external module or standard code) + // FIXME 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 diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 3de6b5ad075..16d2edd0e96 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -846,6 +846,8 @@ class Propal extends CommonObject $resql=$this->update_price(1); if ($resql) { + $action='update'; + // Actions on extra fields (by external module or standard code) // FIXME le hook fait double emploi avec le trigger !! $hookmanager->initHooks(array('propaldao')); @@ -1264,6 +1266,8 @@ class Propal extends CommonObject */ function update_extrafields($user) { + $action='update'; + // Actions on extra fields (by external module or standard code) // FIXME le hook fait double emploi avec le trigger !! $hookmanager->initHooks(array('propaldao')); @@ -2879,7 +2883,7 @@ class PropaleLigne extends CommonObject $error=0; - dol_syslog("PropaleLigne::insert rang=".$this->rang); + dol_syslog(get_class($this)."::insert rang=".$this->rang); // Clean parameters if (empty($this->tva_tx)) $this->tva_tx=0; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index ce3ec431180..f400925b059 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -801,6 +801,8 @@ class Commande extends CommonOrder if (! $error) { + $action='create'; + // Actions on extra fields (by external module or standard code) // FIXME le hook fait double emploi avec le trigger !! $hookmanager->initHooks(array('orderdao')); @@ -2928,6 +2930,8 @@ class Commande extends CommonOrder */ function update_extrafields($user) { + $action='create'; + // Actions on extra fields (by external module or standard code) // FIXME le hook fait double emploi avec le trigger !! $hookmanager->initHooks(array('orderdao')); @@ -3280,7 +3284,7 @@ class OrderLine extends CommonOrderLine $error=0; - dol_syslog("OrderLine::insert rang=".$this->rang); + dol_syslog(get_class($this)."::insert rang=".$this->rang); // Clean parameters if (empty($this->tva_tx)) $this->tva_tx=0; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index e410ab49de2..7c8dc7c6c59 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -464,6 +464,8 @@ class Facture extends CommonInvoice $result=$this->update_price(1); if ($result > 0) { + $action='create'; + // Actions on extra fields (by external module or standard code) // FIXME le hook fait double emploi avec le trigger !! $hookmanager->initHooks(array('invoicedao')); diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index cef881fca37..6a7776b27bd 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -283,6 +283,8 @@ class Contact extends CommonObject unset($this->state_code); unset($this->state); + $action='update'; + // Actions on extra fields (by external module or standard code) $hookmanager->initHooks(array('contactdao')); $parameters=array('socid'=>$this->id); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 853109fe195..b96e7f01c95 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -953,6 +953,8 @@ class CommandeFournisseur extends CommonOrder if (! $error) { + $action='create'; + // Actions on extra fields (by external module or standard code) // FIXME le hook fait double emploi avec le trigger !! $hookmanager->initHooks(array('supplierorderdao')); diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 2de2d73e8ac..69c235fd831 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -255,6 +255,8 @@ class FactureFournisseur extends CommonInvoice $result=$this->update_price(); if ($result > 0) { + $action='create'; + // Actions on extra fields (by external module or standard code) // FIXME le hook fait double emploi avec le trigger !! $hookmanager->initHooks(array('supplierinvoicedao')); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 4ec459fff85..1bc30b2df5f 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -680,6 +680,8 @@ 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); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index df7eafe3d9d..fbdf42d86f5 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -878,6 +878,8 @@ class Societe extends CommonObject } } + $action='update'; + // Actions on extra fields (by external module or standard code) // FIXME le hook fait double emploi avec le trigger !! $hookmanager->initHooks(array('thirdpartydao')); diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index b91356f7b88..15a5cf8b8ed 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1265,7 +1265,10 @@ class User extends CommonObject } } + $action='update'; + // Actions on extra fields (by external module or standard code) + // FIXME le hook fait double emploi avec le trigger !! $hookmanager->initHooks(array('userdao')); $parameters=array('socid'=>$this->id); $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index e096f8fc470..5ff1a928d1c 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -620,16 +620,10 @@ class UserGroup extends CommonObject if ($this->update(1) < 0) return -2; - if (! $notrigger) - { - // Call trigger - $result=$this->call_trigger('GROUP_CREATE',$user); - if ($result < 0) { $error++; $this->db->rollback(); return -1; } - // End call triggers - } - + $action='create'; // Actions on extra fields (by external module or standard code) + // FIXME le hook fait double emploi avec le trigger !! $hookmanager->initHooks(array('groupdao')); $parameters=array(); $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks @@ -646,6 +640,14 @@ class UserGroup extends CommonObject } else if ($reshook < 0) $error++; + if (! $error && ! $notrigger) + { + // Call trigger + $result=$this->call_trigger('GROUP_CREATE',$user); + if ($result < 0) { $error++; $this->db->rollback(); return -1; } + // End call triggers + } + if ($error > 0) { $error++; $this->db->rollback(); return -1; } else $this->db->commit(); @@ -689,15 +691,10 @@ class UserGroup extends CommonObject $resql = $this->db->query($sql); if ($resql) { - if (! $notrigger) - { - // Call trigger - $result=$this->call_trigger('GROUP_MODIFY',$user); - if ($result < 0) { $error++; } - // End call triggers - } + $action='update'; // Actions on extra fields (by external module or standard code) + // FIXME le hook fait double emploi avec le trigger !! $hookmanager->initHooks(array('groupdao')); $parameters=array(); $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks @@ -714,6 +711,14 @@ class UserGroup extends CommonObject } else if ($reshook < 0) $error++; + if (! $error && ! $notrigger) + { + // Call trigger + $result=$this->call_trigger('GROUP_MODIFY',$user); + if ($result < 0) { $error++; } + // End call triggers + } + if (! $error) { $this->db->commit();