actions_documentfollower.class.php.back 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. class ActionsDocumentFollower
  3. {
  4. /**
  5. * Overriding the doActions function : replacing the parent function with the one below
  6. *
  7. * @param array() $parameters Hook metadatas (context, etc...)
  8. * @param CommonObject &$object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
  9. * @param string &$action Current action (if set). Generally create or edit or null
  10. * @param HookManager $hookmanager Hook manager propagated to allow calling another hook
  11. * @return int < 0 on error, 0 on success, 1 to replace standard code
  12. */
  13. function doActions($parameters, &$object, &$action, $hookmanager)
  14. {
  15. $error = 0; // Error counter
  16. $myvalue = 'test'; // A result value
  17. print_r($parameters);
  18. echo "action: " . $action;
  19. print_r($object);
  20. die;
  21. if (in_array('somecontext', explode(':', $parameters['context'])))
  22. {
  23. // do something only for the context 'somecontext'
  24. }
  25. if (! $error)
  26. {
  27. $this->results = array('myreturn' => $myvalue);
  28. $this->resprints = 'A text to show';
  29. return 0; // or return 1 to replace standard code
  30. }
  31. else
  32. {
  33. $this->errors[] = 'Error message';
  34. return -1;
  35. }
  36. }
  37. }