workflow_rules.workflow.inc 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * @file
  4. * Provide rules for workflows via hook_workflow.
  5. */
  6. /**
  7. * Implements hook_workflow().
  8. *
  9. * Invokes events, as defined in hook_rules_event_info().
  10. *
  11. * @param string $op
  12. * The current workflow operation: 'transition pre' or 'transition post'.
  13. * @param int $old_sid
  14. * The state ID of the current state.
  15. * @param int $new_sid
  16. * The state ID of the new state.
  17. * @param object $entity
  18. * The entity whose workflow state is changing.
  19. * @param bool $force
  20. */
  21. function workflow_rules_workflow($op, $old_sid, $new_sid, $entity, $force = FALSE, $entity_type = '', $field_name = '', $transition = NULL) {
  22. switch ($op) {
  23. case 'transition post':
  24. // Rules are updated only after a transition of a Workflow Node status.
  25. // When using Workflow Field, this hook is not called. Use default Rules
  26. // data instead.
  27. if ($old_sid == $new_sid) {
  28. rules_invoke_event('workflow_comment_added', $entity, $entity_type, $old_sid, $new_sid);
  29. }
  30. else {
  31. rules_invoke_event('workflow_state_changed', $entity, $entity_type, $old_sid, $new_sid);
  32. }
  33. break;
  34. default:
  35. break;
  36. }
  37. }