Remove old deprecated hook insertExtraFields. Triggers must be used for

action on CRUD events.
This commit is contained in:
Laurent Destailleur 2018-04-10 12:03:01 +02:00
parent 65996c47ff
commit 7108f68db9
36 changed files with 251 additions and 465 deletions

View File

@ -463,24 +463,15 @@ class Adherent extends CommonObject
$action='update'; $action='update';
// Actions on extra fields (by external module) // Actions on extra fields
// TODO le hook fait double emploi avec le trigger !! if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
$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))
{ {
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used $result=$this->insertExtraFields();
if ($result < 0)
{ {
$result=$this->insertExtraFields(); $error++;
if ($result < 0)
{
$error++;
}
} }
} }
else if ($reshook < 0) $error++;
// Update password // Update password
if (! $error && $this->pass) if (! $error && $this->pass)

View File

@ -171,22 +171,15 @@ class AdherentType extends CommonObject
{ {
$action='update'; $action='update';
// Actions on extra fields (by external module or standard code) // Actions on extra fields
$hookmanager->initHooks(array('membertypedao')); if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
$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))
{ {
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used $result=$this->insertExtraFields();
if ($result < 0)
{ {
$result=$this->insertExtraFields(); $error++;
if ($result < 0)
{
$error++;
}
} }
} }
else if ($reshook < 0) $error++;
if (! $error && ! $notrigger) if (! $error && ! $notrigger)
{ {

View File

@ -155,22 +155,15 @@ class AssetType extends CommonObject
{ {
$action='update'; $action='update';
// Actions on extra fields (by external module or standard code) // Actions on extra fields
$hookmanager->initHooks(array('assettypedao')); if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
$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))
{ {
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used $result=$this->insertExtraFields();
if ($result < 0)
{ {
$result=$this->insertExtraFields(); $error++;
if ($result < 0)
{
$error++;
}
} }
} }
else if ($reshook < 0) $error++;
if (! $error && ! $notrigger) if (! $error && ! $notrigger)
{ {

View File

@ -338,28 +338,23 @@ class Categorie extends CommonObject
$action='create'; $action='create';
// Actions on extra fields (by external module or standard code) // Actions on extra fields
// TODO the hook duplicates the trigger !! if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
$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))
{ {
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used $result=$this->insertExtraFields();
if ($result < 0)
{ {
$result=$this->insertExtraFields(); $error++;
if ($result < 0)
{
$error++;
}
} }
} }
else if ($reshook < 0) $error++;
// Call trigger if (! $error)
$result=$this->call_trigger('CATEGORY_CREATE',$user); {
if ($result < 0) { $error++; } // Call trigger
// End call triggers $result=$this->call_trigger('CATEGORY_CREATE',$user);
if ($result < 0) { $error++; }
// End call triggers
}
if ( ! $error ) if ( ! $error )
{ {
@ -432,28 +427,23 @@ class Categorie extends CommonObject
{ {
$action='update'; $action='update';
// Actions on extra fields (by external module or standard code) // Actions on extra fields
// TODO the hook duplicates the trigger !! if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
$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))
{ {
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used $result=$this->insertExtraFields();
if ($result < 0)
{ {
$result=$this->insertExtraFields(); $error++;
if ($result < 0)
{
$error++;
}
} }
} }
else if ($reshook < 0) $error++;
// Call trigger if (! $error)
$result=$this->call_trigger('CATEGORY_MODIFY',$user); {
if ($result < 0) { $error++; $this->db->rollback(); return -1; } // Call trigger
// End call triggers $result=$this->call_trigger('CATEGORY_MODIFY',$user);
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
// End call triggers
}
$this->db->commit(); $this->db->commit();

View File

@ -384,23 +384,15 @@ class ActionComm extends CommonObject
{ {
$action='create'; $action='create';
// Actions on extra fields (by external module or standard code) // Actions on extra fields
// TODO le hook fait double emploi avec le trigger !! if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
$hookmanager->initHooks(array('actioncommdao')); {
$parameters=array('actcomm'=>$this->id); $result=$this->insertExtraFields();
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks if ($result < 0)
if (empty($reshook)) {
{ $error++;
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) if (! $error && ! $notrigger)
@ -865,23 +857,15 @@ class ActionComm extends CommonObject
{ {
$action='update'; $action='update';
// Actions on extra fields (by external module or standard code) // Actions on extra fields
// TODO le hook fait double emploi avec le trigger !! if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
$hookmanager->initHooks(array('actioncommdao')); {
$parameters=array('actcomm'=>$this->id); $result=$this->insertExtraFields();
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks if ($result < 0)
if (empty($reshook)) {
{ $error++;
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 // Now insert assignedusers
if (! $error) if (! $error)

View File

@ -1114,12 +1114,8 @@ class Propal extends CommonObject
{ {
$action='update'; $action='update';
// Actions on extra fields (by external module or standard code) // Actions on extra fields
// TODO le hook fait double emploi avec le trigger !! if (! $error)
$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))
{ {
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
{ {
@ -1130,9 +1126,8 @@ class Propal extends CommonObject
} }
} }
} }
else if ($reshook < 0) $error++;
if (! $notrigger) if (! $error && ! $notrigger)
{ {
// Call trigger // Call trigger
$result=$this->call_trigger('PROPAL_CREATE',$user); $result=$this->call_trigger('PROPAL_CREATE',$user);
@ -3953,7 +3948,7 @@ class PropaleLigne extends CommonObjectLine
} }
} }
if (! $notrigger) if (! $error && ! $notrigger)
{ {
// Call trigger // Call trigger
$result=$this->call_trigger('LINEPROPAL_INSERT',$user); $result=$this->call_trigger('LINEPROPAL_INSERT',$user);
@ -4136,7 +4131,7 @@ class PropaleLigne extends CommonObjectLine
} }
} }
if (! $notrigger) if (! $error && ! $notrigger)
{ {
// Call trigger // Call trigger
$result=$this->call_trigger('LINEPROPAL_UPDATE',$user); $result=$this->call_trigger('LINEPROPAL_UPDATE',$user);

View File

@ -1269,24 +1269,16 @@ if (empty($reshook))
if (! $error) if (! $error)
{ {
// Actions on extra fields (by external module or standard code) // Actions on extra fields
$hookmanager->initHooks(array('orderdao')); $result = $object->insertExtraFields('ORDER_MODIFY');
$parameters = array('id' => $object->id); if ($result < 0)
$reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by {
// some hooks setEventMessages($object->error, $object->errors, 'errors');
if (empty($reshook)) {
$result = $object->insertExtraFields('ORDER_MODIFY');
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
} else if ($reshook < 0)
$error++; $error++;
}
} }
if ($error) if ($error) $action = 'edit_extras';
$action = 'edit_extras';
} }
if ($action == 'set_thirdparty' && $user->rights->commande->creer) if ($action == 'set_thirdparty' && $user->rights->commande->creer)

View File

@ -4208,7 +4208,7 @@ class OrderLine extends CommonOrderLine
} }
} }
if (! $notrigger) if (! $error && ! $notrigger)
{ {
// Call trigger // Call trigger
$result=$this->call_trigger('LINEORDER_UPDATE',$user); $result=$this->call_trigger('LINEORDER_UPDATE',$user);

View File

@ -2209,22 +2209,15 @@ if (empty($reshook))
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none'));
if ($ret < 0) $error++; 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 !! // Actions on extra fields
$hookmanager->initHooks(array('invoicedao')); $result = $object->insertExtraFields('BILL_MODIFY');
$parameters = array('id' => $object->id); if ($result < 0)
$reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by {
// some hooks setEventMessages($object->error, $object->errors, 'errors');
if (empty($reshook)) { $error++;
$result = $object->insertExtraFields('BILL_MODIFY'); }
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
} else if ($reshook < 0)
$error ++;
} }
if ($error) if ($error)

View File

@ -1791,7 +1791,7 @@ class FactureLigneRec extends CommonInvoiceLine
} }
} }
if (! $notrigger) if (! $error && ! $notrigger)
{ {
// Call trigger // Call trigger
$result=$this->call_trigger('LINEBILL_REC_UPDATE',$user); $result=$this->call_trigger('LINEBILL_REC_UPDATE',$user);

View File

@ -750,35 +750,20 @@ class Facture extends CommonInvoice
{ {
$action='create'; $action='create';
// Actions on extra fields (by external module or standard code) // Actions on extra fields
// 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
{*/
if (! $error) if (! $error)
{ {
$result=$this->insertExtraFields(); $result=$this->insertExtraFields();
if ($result < 0) $error++; if ($result < 0) $error++;
} }
/*}
}
else if ($reshook < 0) $error++;*/
if (! $error) if (! $error && ! $notrigger)
{ {
if (! $notrigger) // Call trigger
{ $result=$this->call_trigger('BILL_CREATE',$user);
// Call trigger if ($result < 0) $error++;
$result=$this->call_trigger('BILL_CREATE',$user); // End call triggers
if ($result < 0) $error++; }
// End call triggers
}
}
if (! $error) if (! $error)
{ {
@ -4697,7 +4682,7 @@ class FactureLigne extends CommonInvoiceLine
} }
} }
if (! $notrigger) if (! $error && ! $notrigger)
{ {
// Call trigger // Call trigger
$result=$this->call_trigger('LINEBILL_UPDATE',$user); $result=$this->call_trigger('LINEBILL_UPDATE',$user);

View File

@ -417,7 +417,8 @@ if (empty($reshook))
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none'));
if ($ret < 0) $error++; if ($ret < 0) $error++;
if (! $error) { if (! $error)
{
$result = $object->insertExtraFields('BILLREC_MODIFY'); $result = $object->insertExtraFields('BILLREC_MODIFY');
if ($result < 0) if ($result < 0)
{ {

View File

@ -366,11 +366,8 @@ class Contact extends CommonObject
$action='update'; $action='update';
// Actions on extra fields (by external module or standard code) // Actions on extra fields
$hookmanager->initHooks(array('contactdao')); if (! $error)
$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 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) if (! $error && $this->user_id > 0)
{ {

View File

@ -396,7 +396,7 @@ class Don extends CommonObject
} }
// Update extrafield // Update extrafield
if (!$error) { 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(); $result=$this->insertExtraFields();
@ -482,7 +482,7 @@ class Don extends CommonObject
} }
// Update extrafield // Update extrafield
if (!$error) 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
{ {

View File

@ -164,20 +164,13 @@ if (empty($reshook))
if (! $error) if (! $error)
{ {
// Actions on extra fields (by external module or standard code) // Actions on extra fields
// TODO le hook fait double emploi avec le trigger !! $result = $object->insertExtraFields('SHIPMENT_MODIFY');
$hookmanager->initHooks(array('expeditiondao')); if ($result < 0)
$parameters = array('id' => $object->id); {
$reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks setEventMessages($object->error, $object->errors, 'errors');
if (empty($reshook)) { $error++;
$result = $object->insertExtraFields('SHIPMENT_MODIFY'); }
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
} else if ($reshook < 0)
$error++;
} }
if ($error) if ($error)

View File

@ -311,23 +311,15 @@ class Expedition extends CommonObject
} }
} }
// Actions on extra fields (by external module or standard code) // Actions on extra fields
// TODO le hook fait double emploi avec le trigger !! if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
$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))
{ {
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used $result=$this->insertExtraFields();
if ($result < 0)
{ {
$result=$this->insertExtraFields(); $error++;
if ($result < 0)
{
$error++;
}
} }
} }
else if ($reshook < 0) $error++;
if (! $error && ! $notrigger) if (! $error && ! $notrigger)
{ {
@ -2690,19 +2682,21 @@ class ExpeditionLigne extends CommonObjectLine
$this->errors[]=$this->db->lasterror()." - sql=$sql"; $this->errors[]=$this->db->lasterror()." - sql=$sql";
$error++; $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(); $this->errors[]=$this->error;
if ($result < 0) $error++;
{
$this->errors[]=$this->error;
$error++;
}
} }
} }
} }
if (! $error && ! $notrigger) if (! $error && ! $notrigger)
{ {
// Call trigger // Call trigger

View File

@ -189,20 +189,13 @@ if (empty($reshook))
if (! $error) if (! $error)
{ {
// Actions on extra fields (by external module or standard code) // Actions on extra fields
$hookmanager->initHooks(array('orderdao')); $result = $object->insertExtraFields('SHIPMENT_MODIFY');
$parameters = array('id' => $object->id); if ($result < 0)
$reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by {
// some hooks setEventMessages($object->error, $object->errors, 'errors');
if (empty($reshook)) { $error++;
$result = $object->insertExtraFields('SHIPMENT_MODIFY'); }
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
} else if ($reshook < 0)
$error++;
} }
if ($error) if ($error)

View File

@ -288,20 +288,13 @@ if (empty($reshook))
if (! $error) if (! $error)
{ {
// Actions on extra fields (by external module or standard code) // Actions on extra fields
$hookmanager->initHooks(array('expensereportdao')); $result = $object->insertExtraFields('FICHINTER_MODIFY');
$parameters = array('id' => $object->id); if ($result < 0)
$reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by {
// some hooks setEventMessages($object->error, $object->errors, 'errors');
if (empty($reshook)) { $error++;
$result = $object->insertExtraFields('FICHINTER_MODIFY'); }
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
} else if ($reshook < 0)
$error++;
} }
if ($error) if ($error)

View File

@ -750,20 +750,12 @@ if (empty($reshook))
if (! $error) if (! $error)
{ {
// Actions on extra fields (by external module or standard code) // Actions on extra fields
// TODO le hook fait double emploi avec le trigger !! $result=$object->insertExtraFields('INTERVENTION_MODIFY');
$hookmanager->initHooks(array('interventiondao')); if ($result < 0)
$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('INTERVENTION_MODIFY'); $error++;
if ($result < 0)
{
$error++;
}
} }
else if ($reshook < 0) $error++;
} }
if ($error) $action = 'edit_extras'; if ($error) $action = 'edit_extras';

View File

@ -253,7 +253,7 @@ class Fichinter extends CommonObject
} }
if (! $notrigger) if (! $error && ! $notrigger)
{ {
// Call trigger // Call trigger
$result=$this->call_trigger('FICHINTER_CREATE',$user); $result=$this->call_trigger('FICHINTER_CREATE',$user);

View File

@ -121,11 +121,13 @@ if (empty($reshook))
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none')); $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none'));
if ($ret < 0) $error++; if ($ret < 0) $error++;
if (! $error) if (! $error)
{ {
$result = $object->insertExtraFields('COMPANY_MODIFY'); $result = $object->insertExtraFields('COMPANY_MODIFY');
if ($result < 0) $error++; if ($result < 0) $error++;
} }
if ($error) $action = 'edit_extras'; if ($error) $action = 'edit_extras';
} }
} }

View File

@ -3259,7 +3259,6 @@ class CommandeFournisseurLigne extends CommonOrderLine
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(); $result=$this->insertExtraFields();
if ($result < 0) if ($result < 0)
{ {
@ -3347,7 +3346,6 @@ class CommandeFournisseurLigne extends CommonOrderLine
{ {
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(); $result=$this->insertExtraFields();
if ($result < 0) if ($result < 0)
{ {

View File

@ -444,23 +444,15 @@ class FactureFournisseur extends CommonInvoice
{ {
$action='create'; $action='create';
// Actions on extra fields (by external module or standard code) // Actions on extra fields
// TODO le hook fait double emploi avec le trigger !! if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
$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))
{ {
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 $error++;
if ($result < 0)
{
$error++;
}
} }
} }
else if ($reshook < 0) $error++;
if (! $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 (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{ {
if ($this->insertExtraFields() < 0) { $result = $this->insertExtraFields();
if ($result < 0)
{
$error++; $error++;
} }
} }
@ -2976,7 +2970,7 @@ class SupplierInvoiceLine extends CommonObjectLine
} }
} }
if (! $notrigger) if (! $error && ! $notrigger)
{ {
// Call trigger // Call trigger
$result=$this->call_trigger('LINEBILL_SUPPLIER_CREATE',$user); $result=$this->call_trigger('LINEBILL_SUPPLIER_CREATE',$user);

View File

@ -955,32 +955,19 @@ if (empty($reshook))
if (! $error) if (! $error)
{ {
// Actions on extra fields (by external module or standard code) // Actions on extra fields
// TODO le hook fait double emploi avec le trigger !! if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
$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))
{ {
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'); $error++;
if ($result < 0)
{
$error++;
}
} }
} }
else if ($reshook < 0) $error++;
} }
else
{ if ($error)
$action = 'edit_extras'; $action = 'edit_extras';
}
} }
/* /*

View File

@ -1459,35 +1459,21 @@ if (empty($reshook))
$ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute', 'none')); $ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute', 'none'));
if ($ret < 0) $error++; if ($ret < 0) $error++;
if (!$error) if (! $error)
{ {
// Actions on extra fields (by external module or standard code) // Actions on extra fields
// TODO le hook fait double emploi avec le trigger !! if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
$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))
{ {
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used $result=$object->insertExtraFields('BILL_SUPPLIER_MODIFY');
if ($result < 0)
{ {
$error++;
$result=$object->insertExtraFields('BILL_SUPPLIER_MODIFY');
if ($result < 0)
{
$error++;
}
} }
} }
else if ($reshook < 0) $error++;
} }
else
{ if ($error)
$action = 'edit_extras'; $action = 'edit_extras';
}
} }
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->fournisseur->facture->creer) if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->fournisseur->facture->creer)

View File

@ -202,20 +202,13 @@ if ($action == 'update_extras')
if (! $error) if (! $error)
{ {
// Actions on extra fields (by external module or standard code) // Actions on extra fields
// TODO le hook fait double emploi avec le trigger !! $result = $object->insertExtraFields('DELIVERY_MODIFY');
$hookmanager->initHooks(array('livraisondao')); if ($result < 0)
$parameters = array('id' => $object->id); {
$reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks setEventMessages($object->error, $object->errors, 'errors');
if (empty($reshook)) {
$result = $object->insertExtraFields('DELIVERY_MODIFY');
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
} else if ($reshook < 0)
$error++; $error++;
}
} }
if ($error) if ($error)

View File

@ -540,7 +540,7 @@ class Livraison extends CommonObject
global $conf; global $conf;
$error = 0; $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 = new LivraisonLigne($this->db);
$livraisonline->array_options=$array_options; $livraisonline->array_options=$array_options;

View File

@ -926,22 +926,15 @@ class Product extends CommonObject
$action='update'; $action='update';
// Actions on extra fields (by external module or standard code) // Actions on extra fields
$hookmanager->initHooks(array('productdao')); if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
$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))
{ {
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used $result=$this->insertExtraFields();
if ($result < 0)
{ {
$result=$this->insertExtraFields(); $error++;
if ($result < 0)
{
$error++;
}
} }
} }
else if ($reshook < 0) $error++;
if (! $error && ! $notrigger) if (! $error && ! $notrigger)
{ {

View File

@ -131,20 +131,13 @@ if (empty($reshook))
if (! $error) if (! $error)
{ {
// Actions on extra fields (by external module or standard code) // Actions on extra fields
$hookmanager->initHooks(array('productlotdao')); $result = $object->insertExtraFields('PRODUCT_LOT_MODIFY');
$parameters = array('id' => $object->id); if ($result < 0)
$reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by {
// some hooks setEventMessages($object->error, $object->errors, 'errors');
if (empty($reshook)) { $error++;
$result = $object->insertExtraFields('PRODUCT_LOT_MODIFY'); }
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
} else if ($reshook < 0)
$error++;
} }
if ($error) if ($error)

View File

@ -223,7 +223,7 @@ class Project extends CommonObject
} }
// Update extrafield // Update extrafield
if (!$error) { 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(); $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); $res = $this->setValid($user);
if ($res < 0) $error++; if ($res < 0) $error++;
} }
if (!$error) if (! $error)
{ {
$this->db->commit(); $this->db->commit();
return $ret; return $ret;
@ -320,7 +320,7 @@ class Project extends CommonObject
} }
} }
if (! $error && !$notrigger) if (! $error && ! $notrigger)
{ {
// Call trigger // Call trigger
$result=$this->call_trigger('PROJECT_MODIFY',$user); $result=$this->call_trigger('PROJECT_MODIFY',$user);

View File

@ -333,6 +333,18 @@ class Task extends CommonObject
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } 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 (! $error)
{ {
if (! $notrigger) 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)) if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref))
{ {
// We remove directory // We remove directory

View File

@ -119,23 +119,15 @@ class Dolresource extends CommonObject
{ {
$action='create'; $action='create';
// Actions on extra fields (by external module or standard code) // Actions on extra fields
// TODO le hook fait double emploi avec le trigger !! if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
$hookmanager->initHooks(array('actioncommdao')); {
$parameters=array('actcomm'=>$this->id); $result=$this->insertExtraFields();
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks if ($result < 0)
if (empty($reshook)) {
{ $error++;
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) if (! $error)
@ -305,23 +297,15 @@ class Dolresource extends CommonObject
{ {
$action='update'; $action='update';
// Actions on extra fields (by external module or standard code) // Actions on extra fields
// TODO le hook fait double emploi avec le trigger !! if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
$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)
{ {
$result=$this->insertExtraFields(); $error++;
if ($result < 0)
{
$error++;
}
} }
} }
else if ($reshook < 0) $error++;
} }
// Commit or rollback // Commit or rollback

View File

@ -1056,23 +1056,15 @@ class Societe extends CommonObject
$action='update'; $action='update';
// Actions on extra fields (by external module or standard code) // Actions on extra fields
// TODO le hook fait double emploi avec le trigger !! if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
$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))
{ {
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used $result=$this->insertExtraFields();
if ($result < 0)
{ {
$result=$this->insertExtraFields(); $error++;
if ($result < 0)
{
$error++;
}
} }
} }
else if ($reshook < 0) $error++;
if (! $error && $call_trigger) if (! $error && $call_trigger)
{ {

View File

@ -960,24 +960,17 @@ class SupplierProposal extends CommonObject
{ {
$action='update'; $action='update';
// Actions on extra fields (by external module or standard code) // Actions on extra fields
$hookmanager->initHooks(array('supplier_proposaldao')); if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
$parameters=array('socid'=>$this->id); {
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks $result=$this->insertExtraFields();
if (empty($reshook)) if ($result < 0)
{ {
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used $error++;
{ }
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
} }
else if ($reshook < 0) $error++;
if (! $notrigger) if (! $erro && ! $notrigger)
{ {
// Call trigger // Call trigger
$result=$this->call_trigger('PROPAL_SUPPLIER_CREATE',$user); $result=$this->call_trigger('PROPAL_SUPPLIER_CREATE',$user);
@ -2885,7 +2878,7 @@ class SupplierProposalLine extends CommonObjectLine
} }
} }
if (! $notrigger) if (! $error && ! $notrigger)
{ {
// Call trigger // Call trigger
$result=$this->call_trigger('LINESUPPLIER_PROPOSAL_INSERT',$user); $result=$this->call_trigger('LINESUPPLIER_PROPOSAL_INSERT',$user);
@ -3061,7 +3054,7 @@ class SupplierProposalLine extends CommonObjectLine
} }
} }
if (! $notrigger) if (! $error && ! $notrigger)
{ {
// Call trigger // Call trigger
$result=$this->call_trigger('LINESUPPLIER_PROPOSAL_UPDATE',$user); $result=$this->call_trigger('LINESUPPLIER_PROPOSAL_UPDATE',$user);

View File

@ -400,7 +400,7 @@ class Ticketsup extends CommonObject
} }
//Update extrafield //Update extrafield
if (!$error) { 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(); $result = $this->insertExtraFields();
if ($result < 0) { if ($result < 0) {
@ -822,32 +822,25 @@ class Ticketsup extends CommonObject
$this->errors[] = "Error " . $this->db->lasterror(); $this->errors[] = "Error " . $this->db->lasterror();
} }
if (!$error) { if (! $error) {
// FIXME le hook fait double emploi avec le trigger !! // Update extrafields
$hookmanager->initHooks(array('TicketSupDao')); if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { // For avoid conflicts if trigger used
$parameters = array('ticketsupid' => $this->id); $result = $this->insertExtraFields();
$reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($result < 0) {
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) {
$error++; $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 // Commit or rollback
if ($error) { if ($error) {
foreach ($this->errors as $errmsg) { foreach ($this->errors as $errmsg) {

View File

@ -1572,7 +1572,7 @@ class User extends CommonObject
$action='update'; $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 if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{ {
$result=$this->insertExtraFields(); $result=$this->insertExtraFields();