Fix: Param $action was not defined.

A better fix must be done later be removing useless hooks that are
duplicate with triggers.
This commit is contained in:
Laurent Destailleur 2014-11-15 19:04:21 +01:00
parent ec4b29c65d
commit c186f13218
13 changed files with 61 additions and 21 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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'));

View File

@ -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);

View File

@ -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'));

View File

@ -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'));

View File

@ -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);

View File

@ -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'));

View File

@ -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

View File

@ -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();