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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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';
}
}
/*

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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