31,024
edits
mNo edit summary Tag: 2017 source edit |
mNo edit summary Tag: 2017 source edit |
||
| Line 58: | Line 58: | ||
This function is called at each Dolibarr business event. Put your code according to events on which you want to run. Each event is identified by a code (see following chapter to get full list of codes). So you can react or no after an event by doing just a test on variable '''$action''': | This function is called at each Dolibarr business event. Put your code according to events on which you want to run. Each event is identified by a code (see following chapter to get full list of codes). So you can react or no after an event by doing just a test on variable '''$action''': | ||
< | <syntaxHighlight lang="php"> | ||
function run_trigger($action,$object,$user,$langs,$conf) | function run_trigger($action,$object,$user,$langs,$conf) | ||
{ | { | ||
| Line 76: | Line 76: | ||
... | ... | ||
} | } | ||
</ | </syntaxHighlight> | ||
You can do what you want into this coding part, if you check that function run_trigger returns a return code according to following rule: | You can do what you want into this coding part, if you check that function run_trigger returns a return code according to following rule: | ||
| Line 109: | Line 109: | ||
To manage events other than those above, you must modify the Dolibarr code to add the following sequence in the business methods of the classes of the objects handled: | To manage events other than those above, you must modify the Dolibarr code to add the following sequence in the business methods of the classes of the objects handled: | ||
< | <syntaxHighlight lang="php"> | ||
// Call trigger | // Call trigger | ||
//$this->context = array('paramX'=>$valueX); | //$this->context = array('paramX'=>$valueX); | ||
| Line 115: | Line 115: | ||
if ($result <0) $error++; | if ($result <0) $error++; | ||
// End call triggers | // End call triggers | ||
</ | </syntaxHighlight> | ||
It will then be possible to add in the run_trigger method of any trigger file, an if which allows you to manage this code. The run_trigger method would then be of the form: | It will then be possible to add in the run_trigger method of any trigger file, an if which allows you to manage this code. The run_trigger method would then be of the form: | ||
< | <syntaxHighlight lang="php"> | ||
function run_trigger($action,$object,$user,$lang,$conf) | function run_trigger($action,$object,$user,$lang,$conf) | ||
{ | { | ||
| Line 141: | Line 141: | ||
... | ... | ||
} | } | ||
</ | </syntaxHighlight> | ||
=Conclusion= | =Conclusion= | ||