workflow.api.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * @file
  4. * Hooks provided by the workflow module.
  5. */
  6. /**
  7. * Implements hook_workflow().
  8. *
  9. * @param $op
  10. * The current workflow operation: 'transition permitted', 'transition pre' or 'transition post'.
  11. * @param $old_state
  12. * The state ID of the current state.
  13. * @param $new_state
  14. * The state ID of the new state.
  15. * @param $node
  16. * The node whose workflow state is changing.
  17. * @param $force
  18. * The caller indicated that the transition should be forced. (bool).
  19. * This is only available on the "pre" and "post" calls.
  20. */
  21. function hook_workflow($op, $old_state, $new_state, $node, $force = FALSE) {
  22. switch ($op) {
  23. case 'transition permitted':
  24. // The workflow module does nothing during this operation.
  25. // This operation occurs when the list of available transitions
  26. // is built. Your module's implementation could return FALSE
  27. // here and disallow the presentation of the choice.
  28. break;
  29. case 'transition pre':
  30. // The workflow module does nothing during this operation.
  31. // But your module's implementation of the workflow hook could
  32. // return FALSE here and veto the transition.
  33. break;
  34. case 'transition post':
  35. break;
  36. case 'transition delete':
  37. break;
  38. }
  39. }
  40. /**
  41. * Implements hook_workflow_history_alter().
  42. * Add an 'undo' operation for the most recent history change.
  43. *
  44. * @param $variables
  45. * The current workflow history information as an array.
  46. * 'old_sid' - The state ID of the previous state.
  47. * 'old_state_name' - The state name of the previous state.
  48. * 'sid' - The state ID of the current state.
  49. * 'state_name' - The state name of the current state.
  50. * 'history' - The row from the workflow_node_history table.
  51. *
  52. * If you want to add additional data, such as an operation link,
  53. * place it in the 'extra' value.
  54. */
  55. function hook_workflow_history_alter(&$variables) {
  56. // The Worflow module does nothing with this hook.
  57. // For an example implementation, see the Workflow Revert add-on.
  58. }