rules_test.test.inc 1.5 KB

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