workflow_rules.module 1020 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. * @file
  4. * Provide rules for workflows.
  5. * Why it's own module? Some sites prefer rules, some prefer actions,
  6. * all prefer a lower code footprint and better performance.
  7. * Additional creadit to gcassie ( http://drupal.org/user/80260 ) for
  8. * the initial push to split rules out of core workflow.
  9. */
  10. /**
  11. * Implements hook_workflow().
  12. *
  13. * @param $op
  14. * The current workflow operation: 'transition pre' or 'transition post'.
  15. * @param $old_state
  16. * The state ID of the current state.
  17. * @param $new_state
  18. * The state ID of the new state.
  19. * @param $node
  20. * The node whose workflow state is changing.
  21. */
  22. function workflow_rules_workflow($op, $old_state, $new_state, $node) {
  23. switch ($op) {
  24. case 'transition post':
  25. // Rules are updated on after the transition.
  26. if ($old_state == $new_state) {
  27. rules_invoke_event('workflow_comment_added', $node, $old_state, $new_state);
  28. return;
  29. }
  30. rules_invoke_event('workflow_state_changed', $node);
  31. break;
  32. }
  33. }