31,029
edits
| Line 142: | Line 142: | ||
= Manage new events = | = Manage new events = | ||
To manage other events on objects than the one defined before, you mist edit the Dolibarr code to add the following code inside the business method of the class file of the object: | |||
<source lang="php"> | <source lang="php"> | ||
// | // Call triggers | ||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); | include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); | ||
$interface=new Interfaces($this->db); | $interface=new Interfaces($this->db); | ||
$interface->run_triggers('XXXXX_YYYYYY',$this,$user,$lang,$conf); | $interface->run_triggers('XXXXX_YYYYYY',$this,$user,$lang,$conf); | ||
// | // End call triggers | ||
</source> | </source> | ||
Here, $this contains the business class with all information to send to the trigger functions. Replace 'XXXXX_YYYYYY' by an event code not already used. | |||
Then you will be able to add inside the run_trigger method, a "if" to manage this code. The run_trigger method will contains a part of code like this : | |||
<source lang="php"> | <source lang="php"> | ||
function run_trigger($action,$object,$user,$lang,$conf) | function run_trigger($action,$object,$user,$lang,$conf) | ||
{ | { | ||
// | // Put here the code to execute | ||
// | // Type of Dolibarr business event is stored in $action | ||
// Les données de l'action sont stockées dans $object | // Les données de l'action sont stockées dans $object | ||
// La configuration, utilisateur et langage sont dans $conf,$user et $lang | // La configuration, utilisateur et langage sont dans $conf,$user et $lang | ||