From 84cda962c1271eed78faaa95f122016e64bd5730 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Apr 2020 12:03:29 +0200 Subject: [PATCH] Clean dead code --- .../class/accountancycategory.class.php | 48 ------------ .../class/accountingaccount.class.php | 26 ++----- htdocs/accountancy/class/lettering.class.php | 13 ---- .../mailing/class/advtargetemailing.class.php | 45 ----------- .../facture/class/paymentterm.class.php | 34 -------- .../class/paymentsocialcontribution.class.php | 32 -------- htdocs/core/actions_massactions.inc.php | 10 +-- htdocs/core/actions_sendmails.inc.php | 15 ++-- htdocs/core/class/ccountry.class.php | 45 ----------- htdocs/core/class/commonobject.class.php | 12 +-- htdocs/core/class/cstate.class.php | 44 ----------- htdocs/core/class/ctypent.class.php | 45 ----------- htdocs/core/class/cunits.class.php | 45 ----------- ...terface_50_modAgenda_ActionsAuto.class.php | 3 +- htdocs/cron/class/cronjob.class.php | 26 ------- htdocs/ecm/class/ecmdirectory.class.php | 9 ++- .../class/paymentexpensereport.class.php | 32 -------- htdocs/exports/class/export.class.php | 16 ---- htdocs/loan/class/loanschedule.class.php | 32 -------- htdocs/loan/class/paymentloan.class.php | 32 -------- htdocs/main.inc.php | 58 +++++--------- .../class/opensurveysondage.class.php | 15 ++-- htdocs/product/class/product.class.php | 15 ++-- htdocs/product/class/productbatch.class.php | 44 ----------- .../class/productcustomerprice.class.php | 41 ++-------- .../class/propalmergepdfproduct.class.php | 77 ------------------- htdocs/public/payment/paymentko.php | 10 +-- htdocs/public/payment/paymentok.php | 22 ++---- htdocs/resource/class/dolresource.class.php | 15 ++-- htdocs/user/logout.php | 8 +- 30 files changed, 89 insertions(+), 780 deletions(-) diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 2f0cf264529..eed3bb60e67 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -199,24 +199,6 @@ class AccountancyCategory // extends CommonObject $resql=$this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - if (! $error) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_accounting_category"); - - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - //if (! $notrigger) - //{ - - // // Call triggers - // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - // $interface=new Interfaces($this->db); - // $result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); - // if ($result < 0) { $error++; $this->errors=$interface->errors; } - // // End call triggers - //} - } - // Commit or rollback if ($error) { @@ -343,21 +325,6 @@ class AccountancyCategory // extends CommonObject $resql = $this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - //if (! $error) - //{ - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - //if (! $notrigger) - //{ - // // Call triggers - // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - // $interface=new Interfaces($this->db); - // $result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); - // if ($result < 0) { $error++; $this->errors=$interface->errors; } - // // End call triggers - //} - //} - // Commit or rollback if ($error) { @@ -398,21 +365,6 @@ class AccountancyCategory // extends CommonObject $resql = $this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - //if (! $error) - //{ - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - //if (! $notrigger) - //{ - // // Call triggers - // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - // $interface=new Interfaces($this->db); - // $result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); - // if ($result < 0) { $error++; $this->errors=$interface->errors; } - // // End call triggers - //} - //} - // Commit or rollback if ($error) { diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 58e6bd600f6..794ce3c8e7c 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -295,17 +295,15 @@ class AccountingAccount extends CommonObject if (! $error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_account"); - // if (! $notrigger) { // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. + // want this action to call a trigger. + //if (! $error && ! $notrigger) { // // Call triggers - // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - // $interface=new Interfaces($this->db); - // $result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); - // if ($result < 0) { $error++; $this->errors=$interface->errors; } + // $result=$this->call_trigger('MYOBJECT_CREATE',$user); + // if ($result < 0) $error++; // // End call triggers - // } + //} } // Commit or rollback @@ -411,20 +409,6 @@ class AccountingAccount extends CommonObject if ($result > 0) { $this->db->begin(); - // if (! $error) { - // if (! $notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - // // Call triggers - // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - // $interface=new Interfaces($this->db); - // $result=$interface->run_triggers('ACCOUNTANCY_ACCOUNT_DELETE',$this,$user,$langs,$conf); - // if ($result < 0) { $error++; $this->errors=$interface->errors; } - // // End call triggers - // } - // } - if (! $error) { $sql = "DELETE FROM " . MAIN_DB_PREFIX . "accounting_account"; $sql .= " WHERE rowid=" . $this->id; diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index 97d62ebb5dc..88136ddea29 100644 --- a/htdocs/accountancy/class/lettering.class.php +++ b/htdocs/accountancy/class/lettering.class.php @@ -287,19 +287,6 @@ class Lettering extends BookKeeping } } - if (! $error) { - if (! $notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - // // Call triggers - // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - // $interface=new Interfaces($this->db); - // $result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); - // if ($result < 0) { $error++; $this->errors=$interface->errors; } - // // End call triggers - } - } // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index da1775955b7..f9602cdeed4 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -153,19 +153,6 @@ class AdvanceTargetingMailing extends CommonObject if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."advtargetemailing"); - - if (!$notrigger) - { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - } } // Commit or rollback @@ -414,22 +401,6 @@ class AdvanceTargetingMailing extends CommonObject $this->errors[] = "Error ".$this->db->lasterror(); } - //if (! $error) - //{ - // if (! $notrigger) - // { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - // } - //} - // Commit or rollback if ($error) { @@ -462,22 +433,6 @@ class AdvanceTargetingMailing extends CommonObject $this->db->begin(); - if (!$error) - { - if (!$notrigger) - { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - } - } - if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."advtargetemailing"; diff --git a/htdocs/compta/facture/class/paymentterm.class.php b/htdocs/compta/facture/class/paymentterm.class.php index 58d4b7e0387..c8ba0d41725 100644 --- a/htdocs/compta/facture/class/paymentterm.class.php +++ b/htdocs/compta/facture/class/paymentterm.class.php @@ -133,18 +133,6 @@ class PaymentTerm // extends CommonObject if (! $error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_payment_term"); - - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - //if (! $notrigger) { - - // // Call triggers - // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - // $interface=new Interfaces($this->db); - // $result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); - // if ($result < 0) { $error++; $this->errors=$interface->errors; } - // // End call triggers - //} } // Commit or rollback @@ -307,17 +295,6 @@ class PaymentTerm // extends CommonObject $resql = $this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - //if (! $error && ! $notrigger) { - // Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - // End call triggers - //} - // Commit or rollback if ($error) { @@ -358,17 +335,6 @@ class PaymentTerm // extends CommonObject $resql = $this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - //if (! $error && ! $notrigger) { - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - //} - // Commit or rollback if ($error) { diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 02c15b099b9..00f7354c20b 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -348,22 +348,6 @@ class PaymentSocialContribution extends CommonObject $resql = $this->db->query($sql); if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - //if (! $error) - //{ - // if (! $notrigger) - // { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - // } - //} - // Commit or rollback if ($error) { @@ -420,22 +404,6 @@ class PaymentSocialContribution extends CommonObject if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } } - //if (! $error) - //{ - // if (! $notrigger) - // { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - // } - //} - // Commit or rollback if ($error) { diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 419296b7341..5e08559e056 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -550,12 +550,10 @@ if (!$error && $massaction == 'confirm_presend') if (!empty($triggername)) { - // Appel des triggers - include_once DOL_DOCUMENT_ROOT."/core/class/interfaces.class.php"; - $interface = new Interfaces($db); - $result = $interface->run_triggers($triggername, $objectobj2, $user, $langs, $conf); - if ($result < 0) { $error++; $errors = $interface->errors; } - // Fin appel triggers + // Call trigger + $result = $objectobj2->call_trigger($triggername, $user); + if ($result < 0) $error++; + // End call triggers if ($error) { diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 0a8ed21da14..e23d2ce01a9 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -455,16 +455,19 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST $object->email_subject = $subject; $object->email_msgid = $mailfile->msgid; - // Call of triggers (you should have set $triggersendname to execute trigger. $trigger_name is deprcated) + // Call of triggers (you should have set $triggersendname to execute trigger. $trigger_name is deprecated) if (!empty($triggersendname) || !empty($trigger_name)) { - include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; - $interface = new Interfaces($db); - $result = $interface->run_triggers(empty($triggersendname) ? $trigger_name : $triggersendname, $object, $user, $langs, $conf); - if ($result < 0) { - setEventMessages($interface->error, $interface->errors, 'errors'); + // Call trigger + $result = $object->call_trigger(empty($triggersendname) ? $trigger_name : $triggersendname, $user); + if ($result < 0) $error++; + // End call triggers + + if ($error) { + setEventMessages($object->error, $object->errors, 'errors'); } } + // End call of triggers } // Redirect here diff --git a/htdocs/core/class/ccountry.class.php b/htdocs/core/class/ccountry.class.php index e117f99488a..15a8c82b11e 100644 --- a/htdocs/core/class/ccountry.class.php +++ b/htdocs/core/class/ccountry.class.php @@ -126,19 +126,6 @@ class Ccountry // extends CommonObject if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_country"); - - if (!$notrigger) - { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - } } // Commit or rollback @@ -247,22 +234,6 @@ class Ccountry // extends CommonObject $resql = $this->db->query($sql); if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (!$error) - { - if (!$notrigger) - { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - } - } - // Commit or rollback if ($error) { @@ -303,22 +274,6 @@ class Ccountry // extends CommonObject $resql = $this->db->query($sql); if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (!$error) - { - if (!$notrigger) - { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - } - } - // Commit or rollback if ($error) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 2352450e770..b6f1a22eea6 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3629,14 +3629,10 @@ abstract class CommonObject if ($trigkey) { - // Appel des triggers - include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; - $interface = new Interfaces($this->db); - $result = $interface->run_triggers($trigkey, $this, $user, $langs, $conf); - if ($result < 0) { - $error++; $this->errors = $interface->errors; - } - // Fin appel triggers + // Call trigger + $result = $this->call_trigger($trigkey, $user); + if ($result < 0) $error++; + // End call triggers } if (!$error) diff --git a/htdocs/core/class/cstate.class.php b/htdocs/core/class/cstate.class.php index b571858cc84..8fcbdaa6fa3 100644 --- a/htdocs/core/class/cstate.class.php +++ b/htdocs/core/class/cstate.class.php @@ -120,18 +120,6 @@ class Cstate // extends CommonObject if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_departements"); - - //if (! $notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - //} } // Commit or rollback @@ -231,22 +219,6 @@ class Cstate // extends CommonObject $resql = $this->db->query($sql); if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - //if (! $error) - //{ - // if (! $notrigger) - // { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - // } - //} - // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { @@ -282,22 +254,6 @@ class Cstate // extends CommonObject $resql = $this->db->query($sql); if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - //if (! $error) - //{ - // if (! $notrigger) - // { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - // } - //} - // Commit or rollback if ($error) { diff --git a/htdocs/core/class/ctypent.class.php b/htdocs/core/class/ctypent.class.php index 376210f472f..88c0518babf 100644 --- a/htdocs/core/class/ctypent.class.php +++ b/htdocs/core/class/ctypent.class.php @@ -124,19 +124,6 @@ class Ctypent // extends CommonObject if (! $error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_typent"); - - if (! $notrigger) - { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - } } // Commit or rollback @@ -243,22 +230,6 @@ class Ctypent // extends CommonObject $resql = $this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - if (! $error) - { - if (! $notrigger) - { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - } - } - // Commit or rollback if ($error) { @@ -299,22 +270,6 @@ class Ctypent // extends CommonObject $resql = $this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - //if (! $error) - //{ - // if (! $notrigger) - // { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - // } - //} - // Commit or rollback if ($error) { diff --git a/htdocs/core/class/cunits.class.php b/htdocs/core/class/cunits.class.php index a4d7b742d51..c48d57d31f3 100644 --- a/htdocs/core/class/cunits.class.php +++ b/htdocs/core/class/cunits.class.php @@ -123,19 +123,6 @@ class CUnits // extends CommonObject if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_units"); - - //if (! $notrigger) - //{ - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - //} } // Commit or rollback @@ -342,22 +329,6 @@ class CUnits // extends CommonObject $resql = $this->db->query($sql); if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - //if (! $error) - //{ - // if (! $notrigger) - // { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - // } - //} - // Commit or rollback if ($error) { @@ -398,22 +369,6 @@ class CUnits // extends CommonObject $resql = $this->db->query($sql); if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - //if (! $error) - //{ - // if (! $notrigger) - // { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - // } - //} - // Commit or rollback if ($error) { diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 3fe9d63c380..3206e9377d3 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -831,7 +831,8 @@ class InterfaceActionsAuto extends DolibarrTriggers // TODO Merge all previous cases into this generic one else // $action = BILL_DELETE, TICKET_CREATE, TICKET_MODIFY, TICKET_DELETE, ... { - // Note: We are here only if $conf->global->MAIN_AGENDA_ACTIONAUTO_action is on (tested at begining of this function). Key can be set in agenda setup if defined into c_action_trigger + // Note: We are here only if $conf->global->MAIN_AGENDA_ACTIONAUTO_action is on (tested at begining of this function). + // Note that these key can be set in agenda setup, only if defined into c_action_trigger // Load translation files required by the page $langs->loadLangs(array("agenda", "other")); diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 6d7b17f7fe0..92a132a6789 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -267,19 +267,6 @@ class Cronjob extends CommonObject if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."cronjob"); - - //if (! $notrigger) - //{ - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - //} } // Commit or rollback @@ -657,19 +644,6 @@ class Cronjob extends CommonObject $resql = $this->db->query($sql); if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - //if (! $error && ! $notrigger) - //{ - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - //} - // Commit or rollback if ($error) { diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php index 7471b3d30a4..c8c67f82b9c 100644 --- a/htdocs/ecm/class/ecmdirectory.class.php +++ b/htdocs/ecm/class/ecmdirectory.class.php @@ -789,11 +789,12 @@ class EcmDirectory // extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Call trigger based on this instance + * Call trigger based on this instance. + * We implement it here because this class doe not extend CommonObject. * - * NB: Error from trigger are stacked in errors - * NB2: if trigger fail, action should be canceled. - * NB3: Should be deleted if EcmDirectory extend CommonObject + * NB1: Error from trigger are stacked in errors + * NB2: if trigger fail, action should be canceled. + * NB3: Should be deleted if EcmDirectory extend CommonObject * * @param string $triggerName trigger's name to execute * @param User $user Object user diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index 156bd329d49..0cab2a5122c 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -301,22 +301,6 @@ class PaymentExpenseReport extends CommonObject $resql = $this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - if (! $error) - { - if (! $notrigger) - { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - } - } - // Commit or rollback if ($error) { @@ -374,22 +358,6 @@ class PaymentExpenseReport extends CommonObject } } - //if (! $error) - //{ - // if (! $notrigger) - // { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - // } - //} - // Commit or rollback if ($error) { diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index bf00027b58a..978a3059ace 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -812,22 +812,6 @@ class Export $resql = $this->db->query($sql); if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (!$error) - { - if (!$notrigger) - { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - } - } - // Commit or rollback if ($error) { diff --git a/htdocs/loan/class/loanschedule.class.php b/htdocs/loan/class/loanschedule.class.php index 2d4ae196bb6..8d0cf38af59 100644 --- a/htdocs/loan/class/loanschedule.class.php +++ b/htdocs/loan/class/loanschedule.class.php @@ -316,22 +316,6 @@ class LoanSchedule extends CommonObject $resql = $this->db->query($sql); if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (!$error) - { - if (!$notrigger) - { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - } - } - // Commit or rollback if ($error) { @@ -369,22 +353,6 @@ class LoanSchedule extends CommonObject if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } } - if (!$error) - { - if (!$notrigger) - { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - } - } - // Commit or rollback if ($error) { diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php index 9dd4a9ac284..1bd0f874949 100644 --- a/htdocs/loan/class/paymentloan.class.php +++ b/htdocs/loan/class/paymentloan.class.php @@ -316,22 +316,6 @@ class PaymentLoan extends CommonObject $resql = $this->db->query($sql); if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (!$error) - { - if (!$notrigger) - { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - } - } - // Commit or rollback if ($error) { @@ -385,22 +369,6 @@ class PaymentLoan extends CommonObject if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } } - //if (! $error) - //{ - // if (! $notrigger) - // { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - // } - //} - // Commit or rollback if ($error) { diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 400ad73fad2..f28a701e566 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -510,14 +510,11 @@ if (!defined('NOLOGIN')) // Call trigger for the "security events" log $user->trigger_mesg = 'ErrorBadValueForCode - login='.GETPOST("username", "alpha", 2); - // Call of triggers - include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; - $interface = new Interfaces($db); - $result = $interface->run_triggers('USER_LOGIN_FAILED', $user, $user, $langs, $conf); - if ($result < 0) { - $error++; - } - // End Call of triggers + + // Call trigger + $result = $user->call_trigger('USER_LOGIN_FAILED', $user); + if ($result < 0) $error++; + // End call triggers // Hooks on failed login $action = ''; @@ -590,14 +587,11 @@ if (!defined('NOLOGIN')) // Call trigger for the "security events" log $user->trigger_mesg = $langs->trans("ErrorBadLoginPassword").' - login='.GETPOST("username", "alpha", 2); - // Call of triggers - include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; - $interface = new Interfaces($db); - $result = $interface->run_triggers('USER_LOGIN_FAILED', $user, $user, $langs, $conf, GETPOST("username", "alpha", 2)); - if ($result < 0) { - $error++; - } - // End Call of triggers + + // Call trigger + $result = $user->call_trigger('USER_LOGIN_FAILED', $user); + if ($result < 0) $error++; + // End call triggers // Hooks on failed login $action = ''; @@ -645,15 +639,12 @@ if (!defined('NOLOGIN')) $user->trigger_mesg = $user->error; } - // Call triggers for the "security events" log - include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; - $interface = new Interfaces($db); - $result = $interface->run_triggers('USER_LOGIN_FAILED', $user, $user, $langs, $conf); - if ($result < 0) { - $error++; - } + // Call trigger + $result = $user->call_trigger('USER_LOGIN_FAILED', $user); + if ($result < 0) $error++; // End call triggers + // Hooks on failed login $action = ''; $hookmanager->initHooks(array('login')); @@ -702,13 +693,9 @@ if (!defined('NOLOGIN')) $user->trigger_mesg = $user->error; } - // Call triggers for the "security events" log - include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; - $interface = new Interfaces($db); - $result = $interface->run_triggers('USER_LOGIN_FAILED', $user, $user, $langs, $conf); - if ($result < 0) { - $error++; - } + // Call trigger + $result = $user->call_trigger('USER_LOGIN_FAILED', $user); + if ($result < 0) $error++; // End call triggers // Hooks on failed login @@ -809,13 +796,10 @@ if (!defined('NOLOGIN')) // Call triggers for the "security events" log $user->trigger_mesg = $loginfo; - // Call triggers - include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; - $interface = new Interfaces($db); - $result = $interface->run_triggers('USER_LOGIN', $user, $user, $langs, $conf); - if ($result < 0) { - $error++; - } + + // Call trigger + $result = $user->call_trigger('USER_LOGIN', $user); + if ($result < 0) $error++; // End call triggers // Hooks on successfull login diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index 65eae44c2c0..7c1263904fc 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -320,17 +320,12 @@ class Opensurveysondage extends CommonObject $resql = $this->db->query($sql); if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (!$error) + if (!$error && !$notrigger) { - if (!$notrigger) - { - // Call triggers - include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; - $interface = new Interfaces($this->db); - $result = $interface->run_triggers('OPENSURVEY_MODIFY', $this, $user, $langs, $conf); - if ($result < 0) { $error++; $this->errors = $interface->errors; } - // End call triggers - } + // Call trigger + $result = $this->call_trigger('OPENSURVEY_MODIFY', $user); + if ($result < 0) $error++; + // End call triggers } // Commit or rollback diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index a4b2f5524de..d7bb434c0f6 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1452,6 +1452,8 @@ class Product extends CommonObject { global $user, $langs, $conf; + $error = 0; + $this->db->begin(); if ($type == 'buy') { @@ -1478,16 +1480,15 @@ class Product extends CommonObject $resql = $this->db->query($sql); if ($resql) { - // Call triggers - include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; - $interface = new Interfaces($this->db); - $result = $interface->run_triggers('PRODUCT_MODIFY', $this, $user, $langs, $conf); - if ($result < 0) { - $this->errors = $interface->errors; + // Call trigger + $result = $this->call_trigger('PRODUCT_MODIFY', $user); + if ($result < 0) $error++; + // End call triggers + + if ($error) { $this->db->rollback(); return -1; } - // End call triggers $this->$field = $value; diff --git a/htdocs/product/class/productbatch.class.php b/htdocs/product/class/productbatch.class.php index 843bf2aa139..4df4eb2e974 100644 --- a/htdocs/product/class/productbatch.class.php +++ b/htdocs/product/class/productbatch.class.php @@ -112,19 +112,6 @@ class Productbatch extends CommonObject if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.self::$_table_element); - - if (!$notrigger) - { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - } } // Commit or rollback @@ -234,21 +221,6 @@ class Productbatch extends CommonObject dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - if (! $error) - { - if (! $notrigger) - { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - } - } // Commit or rollback if ($error) @@ -282,22 +254,6 @@ class Productbatch extends CommonObject $this->db->begin(); - if (!$error) - { - if (!$notrigger) - { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - } - } - if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.self::$_table_element.""; diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 6c8cc269eba..bc6d6ef28f9 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -217,18 +217,6 @@ class Productcustomerprice extends CommonObject if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_customer_price"); - - if (!$notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - // // Call triggers - // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - // $interface=new Interfaces($this->db); - // $result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); - // if ($result < 0) { $error++; $this->errors=$interface->errors; } - // // End call triggers - } } if (!$error) { @@ -708,15 +696,12 @@ class Productcustomerprice extends CommonObject $this->errors [] = "Error ".$this->db->lasterror(); } - if (!$error) { - if (!$notrigger) { - // Call triggers - include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; - $interface = new Interfaces($this->db); - $result = $interface->run_triggers('PRODUCT_CUSTOMER_PRICE_UPDATE', $this, $user, $langs, $conf); - if ($result < 0) { $error++; $this->errors = $interface->errors; } - // End call triggers - } + if (!$error && !$notrigger) + { + // Call trigger + $result = $this->call_trigger('PRODUCT_CUSTOMER_PRICE_UPDATE', $user); + if ($result < 0) $error++; + // End call triggers } if (!$error) { @@ -849,20 +834,6 @@ class Productcustomerprice extends CommonObject $this->db->begin(); - if (!$error) { - if (!$notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - // // Call triggers - // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - // $interface=new Interfaces($this->db); - // $result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); - // if ($result < 0) { $error++; $this->errors=$interface->errors; } - // // End call triggers - } - } - if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_customer_price"; $sql .= " WHERE rowid=".$this->id; diff --git a/htdocs/product/class/propalmergepdfproduct.class.php b/htdocs/product/class/propalmergepdfproduct.class.php index 2a2eaa86d23..9ca53d167cf 100644 --- a/htdocs/product/class/propalmergepdfproduct.class.php +++ b/htdocs/product/class/propalmergepdfproduct.class.php @@ -127,19 +127,6 @@ class Propalmergepdfproduct extends CommonObject if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."propal_merge_pdf_product"); - - if (!$notrigger) - { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - } } // Commit or rollback @@ -336,22 +323,6 @@ class Propalmergepdfproduct extends CommonObject $resql = $this->db->query($sql); if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - //if (! $error) - //{ - // if (! $notrigger) - // { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - // } - //} - // Commit or rollback if ($error) { @@ -385,22 +356,6 @@ class Propalmergepdfproduct extends CommonObject $this->db->begin(); - if (!$error) - { - if (!$notrigger) - { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - } - } - if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product"; @@ -447,22 +402,6 @@ class Propalmergepdfproduct extends CommonObject $this->db->begin(); - //if (! $error) - //{ - // if (! $notrigger) - // { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - // } - //} - if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product"; @@ -510,22 +449,6 @@ class Propalmergepdfproduct extends CommonObject $this->db->begin(); - //if (! $error) - //{ - // if (! $notrigger) - // { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - // } - //} - if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product"; diff --git a/htdocs/public/payment/paymentko.php b/htdocs/public/payment/paymentko.php index eac2fdf9f47..f61026a0eca 100644 --- a/htdocs/public/payment/paymentko.php +++ b/htdocs/public/payment/paymentko.php @@ -129,12 +129,10 @@ if (!empty($_SESSION['ipaddress'])) // To avoid to make action twice $ipaddress = $_SESSION['ipaddress']; $errormessage = $_SESSION['errormessage']; - // Appel des triggers - include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; - $interface = new Interfaces($db); - $result = $interface->run_triggers('PAYMENTONLINE_PAYMENT_KO', $object, $user, $langs, $conf); - if ($result < 0) { $error++; $errors = $interface->errors; } - // Fin appel triggers + // Call trigger + $result = $object->call_trigger('PAYMENTONLINE_PAYMENT_KO', $user); + if ($result < 0) $error++; + // End call triggers // Send an email $sendemail = ''; diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 28060a6d71e..cd73d2b21d2 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -748,13 +748,10 @@ if ($ispaymentok) $currencyCodeType = $_SESSION['currencyCodeType']; $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"]; - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($db); - $result=$interface->run_triggers('PAYMENTONLINE_PAYMENT_OK', $object, $user, $langs, $conf); - if ($result < 0) { $error++; $errors=$interface->errors; } - // Fin appel triggers - + // Call trigger + $result = $object->call_trigger('PAYMENTONLINE_PAYMENT_OK', $user); + if ($result < 0) $error++; + // End call triggers print $langs->trans("YourPaymentHasBeenRecorded")."
\n"; if ($TRANSACTIONID) print $langs->trans("ThisIsTransactionId", $TRANSACTIONID)."

\n"; @@ -885,13 +882,10 @@ else $currencyCodeType = $_SESSION['currencyCodeType']; $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"]; - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($db); - $result=$interface->run_triggers('PAYMENTONLINE_PAYMENT_KO', $object, $user, $langs, $conf); - if ($result < 0) { $error++; $errors=$interface->errors; } - // Fin appel triggers - + // Call trigger + $result = $object->call_trigger('PAYMENTONLINE_PAYMENT_KO', $user); + if ($result < 0) $error++; + // End call triggers print $langs->trans('DoExpressCheckoutPaymentAPICallFailed') . "
\n"; print $langs->trans('DetailedErrorMessage') . ": " . $ErrorLongMsg."
\n"; diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 3a079d4cca6..75c6e50dec3 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -146,17 +146,12 @@ class Dolresource extends CommonObject } } - if (!$error) + if (!$error && !$notrigger) { - if (!$notrigger) - { - //// Call triggers - include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; - $interface = new Interfaces($this->db); - $result = $interface->run_triggers('RESOURCE_CREATE', $this, $user, $langs, $conf); - if ($result < 0) { $error++; $this->errors = $interface->errors; } - //// End call triggers - } + // Call trigger + $result = $this->call_trigger('RESOURCE_CREATE', $user); + if ($result < 0) $error++; + // End call triggers } // Commit or rollback diff --git a/htdocs/user/logout.php b/htdocs/user/logout.php index 02992eafa04..5cb03af224f 100644 --- a/htdocs/user/logout.php +++ b/htdocs/user/logout.php @@ -41,11 +41,9 @@ if (!empty($_SESSION["dol_authmode"]) && ($_SESSION["dol_authmode"] == 'forceuse global $conf, $langs, $user; -// Call triggers for the "security events" log -include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; -$interface = new Interfaces($db); -$result = $interface->run_triggers('USER_LOGOUT', $user, $user, $langs, $conf); -if ($result < 0) { $error++; } +// Call trigger +$result = $user->call_trigger('USER_LOGOUT', $user); +if ($result < 0) $error++; // End call triggers // Hooks on logout