Call trigger added in commonobjectline

This commit is contained in:
Maxime Kohlhaas 2014-08-01 08:59:08 +02:00
parent b2ad8c74a5
commit 94fee7af70
2 changed files with 30 additions and 1 deletions

View File

@ -28,6 +28,34 @@
*/
abstract class CommonObjectLine
{
/**
* Call trigger based on this instance
* NB: Error from trigger are stacked in interface->errors
* NB2: If return code of triggers are < 0, action calling trigger should cancel all transaction.
*
* @param string $trigger_name trigger's name to execute
* @param User $user Object user
* @return int Result of run_triggers
*/
function call_trigger($trigger_name, $user)
{
global $langs,$conf;
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers($trigger_name,$this,$user,$langs,$conf);
if ($result < 0)
{
if (!empty($this->errors))
{
$this->errors=array_merge($this->errors,$interface->errors);
}
else
{
$this->errors=$interface->errors;
}
}
return $result;
}
}

View File

@ -24,6 +24,7 @@
* \brief Fichier de la classe des gestion des fiches interventions
*/
require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
require_once DOL_DOCUMENT_ROOT .'/core/class/commonobjectline.class.php';
/**
@ -998,7 +999,7 @@ class Fichinter extends CommonObject
/**
* Classe permettant la gestion des lignes d'intervention
*/
class FichinterLigne extends CommonObject
class FichinterLigne extends CommonObjectLine
{
var $db;
var $error;