From 5e7c0639b0aa00d0d0c4cda3283819c94517103e Mon Sep 17 00:00:00 2001 From: KreizIT Date: Fri, 11 Jul 2014 16:02:27 +0200 Subject: [PATCH] Refactor: various trigger --- htdocs/fourn/class/paiementfourn.class.php | 10 ++++------ htdocs/fourn/commande/dispatch.php | 9 +++------ htdocs/imports/class/import.class.php | 10 ++++------ .../class/opensurveysondage.class.php | 20 ++++++++----------- .../stock/class/mouvementstock.class.php | 12 +++++------ 5 files changed, 25 insertions(+), 36 deletions(-) diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index 6fff76e2ca0ef..02010d1e2e883 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -201,12 +201,10 @@ function create($user,$closepaidinvoices=0) if (! $error) { - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('PAYMENT_SUPPLIER_CREATE',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers + // Call trigger + $result=$this->call_trigger('PAYMENT_SUPPLIER_CREATE',$user); + if ($result < 0) $error++; + // End call triggers } } else diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 02666e1c855c9..bea467340e657 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -120,12 +120,9 @@ if (! $notrigger) { global $conf, $langs, $user; - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($db); - $result_trigger=$interface->run_triggers('ORDER_SUPPLIER_DISPATCH',$commande,$user,$langs,$conf); - if ($result_trigger < 0) { $error++; $commande->errors=$interface->errors; } - // Fin appel triggers + // Call trigger + $result=$commande->call_trigger('ORDER_SUPPLIER_DISPATCH',$user); + // End call triggers } if ($result > 0) diff --git a/htdocs/imports/class/import.class.php b/htdocs/imports/class/import.class.php index e4acc733a85fe..58a1bf3e9315d 100644 --- a/htdocs/imports/class/import.class.php +++ b/htdocs/imports/class/import.class.php @@ -313,12 +313,10 @@ function delete($user, $notrigger=0) { if (! $notrigger) { - // Call triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('IMPORT_DELETE',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // End call triggers + // Call trigger + $result=$this->call_trigger('IMPORT_DELETE',$user); + if ($result < 0) $error++; + // End call triggers } } diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index 8f3f3fccff897..58351527e6e41 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -142,12 +142,10 @@ function create($user, $notrigger=0) { global $langs, $conf; - //// Call triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('OPENSURVEY_CREATE',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers + // Call trigger + $result=$this->call_trigger('OPENSURVEY_CREATE',$user); + if ($result < 0) $error++; + // End call triggers } } @@ -338,12 +336,10 @@ function delete($user, $notrigger, $numsondage) { if (! $notrigger) { - //// Call triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('OPENSURVEY_DELETE',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers + // Call trigger + $result=$this->call_trigger('OPENSURVEY_DELETE',$user); + if ($result < 0) $error++; + // End call triggers } } diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 747a737f389c2..8219da2b81469 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -245,17 +245,17 @@ function _create($user, $fk_product, $entrepot_id, $qty, $type, $price=0, $label if ($movestock && ! $error) { - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); $this->product_id = $fk_product; $this->entrepot_id = $entrepot_id; $this->qty = $qty; - $result=$interface->run_triggers('STOCK_MOVEMENT',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers + // Call trigger + $result=$this->call_trigger('STOCK_MOVEMENT',$user); + if ($result < 0) $error++; + // End call triggers + + //FIXME: Restore previous value of product_id, entrepot_id, qty if trigger fail } if (! $error)