rules_test.test.inc 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * @file
  4. * Include file for testing file inclusion.
  5. */
  6. /**
  7. * Extender for the node data type.
  8. */
  9. function rules_test_custom_node_save($object) {
  10. throw new RulesEvaluationException('Custom save method invoked.');
  11. }
  12. /**
  13. * Custom help callback for the rules_node_publish_action().
  14. */
  15. function rules_test_custom_help() {
  16. return 'custom';
  17. }
  18. /**
  19. * Action callback.
  20. */
  21. function rules_action_test_reference($data) {
  22. $data['changed'] = TRUE;
  23. return array('arg' => $data);
  24. }
  25. /**
  26. * Condition: Check for selected content types.
  27. */
  28. function rules_condition_content_is_type($node, $type) {
  29. return in_array($node->type, $type);
  30. }
  31. /**
  32. * Condition: Check if the node is published.
  33. */
  34. function rules_condition_content_is_published($node, $settings) {
  35. return $node->status == 1;
  36. }
  37. /**
  38. * Loads a node.
  39. */
  40. function rules_action_load_node($nid, $vid = NULL) {
  41. return array('node_loaded' => node_load($nid, $vid ? $vid : NULL));
  42. }
  43. /**
  44. * Action "Delete a node".
  45. */
  46. function rules_action_delete_node($node) {
  47. node_delete($node->nid);
  48. }
  49. /**
  50. * An action making use of named parameters.
  51. */
  52. function rules_action_node_set_title($arguments) {
  53. // Make sure the data is unwrapped.
  54. if ($arguments['node'] instanceof EntityMetadataWrapper) {
  55. throw new Exception('Argument has not been correctly unwrapped.');
  56. }
  57. $arguments['node']->title = $arguments['title'];
  58. return $arguments;
  59. }
  60. /**
  61. * Action: Test saving - nothing to do here.
  62. */
  63. function rules_test_type_save($node) {
  64. }