rules.rules.inc 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. /**
  3. * @file Includes any rules integration provided by the module.
  4. */
  5. /**
  6. * Load all module includes as soon as this file gets included, which is done
  7. * automatically by module_implements().
  8. */
  9. foreach (rules_core_modules() as $module) {
  10. module_load_include('inc', 'rules', "modules/$module.rules");
  11. module_load_include('inc', 'rules', 'modules/events');
  12. }
  13. /**
  14. * Defines a list of core module on whose behalf we provide module integration.
  15. *
  16. * We also add a pseudo 'data' module, which will be used for providing generic
  17. * rules data integration, 'entity' for entity-related integration and 'rules'
  18. * for providing some general stuff.
  19. */
  20. function rules_core_modules() {
  21. $return = array('data', 'entity', 'node', 'system', 'user', 'rules_core');
  22. foreach (array('comment', 'taxonomy', 'php', 'path') as $module) {
  23. if (module_exists($module)) {
  24. $return[] = $module;
  25. }
  26. }
  27. return $return;
  28. }
  29. /**
  30. * Returns all items for a hook applying the right module defaults.
  31. */
  32. function _rules_rules_collect_items($hook) {
  33. $items = array();
  34. foreach (rules_core_modules() as $module) {
  35. if (function_exists($function = "rules_{$module}_{$hook}")) {
  36. $items += (array) $function();
  37. }
  38. }
  39. return $items;
  40. }
  41. /**
  42. * Implements hook_rules_file_info().
  43. */
  44. function rules_rules_file_info() {
  45. $items = array();
  46. foreach (rules_core_modules() as $module) {
  47. if (function_exists($function = "rules_{$module}_file_info")) {
  48. $items = array_merge($items, (array)$function());
  49. // Automatically add "$module.rules.inc" for each module.
  50. $items[] = 'modules/' . $module . '.rules';
  51. }
  52. }
  53. return $items;
  54. }
  55. /**
  56. * Implements hook_rules_action_info().
  57. */
  58. function rules_rules_action_info() {
  59. return _rules_rules_collect_items('action_info');
  60. }
  61. /**
  62. * Implements hook_rules_condition_info().
  63. */
  64. function rules_rules_condition_info() {
  65. return _rules_rules_collect_items('condition_info');
  66. }
  67. /**
  68. * Implements hook_rules_event_info().
  69. */
  70. function rules_rules_event_info() {
  71. return _rules_rules_collect_items('event_info');
  72. }
  73. /**
  74. * Implements hook_rules_data_info().
  75. */
  76. function rules_rules_data_info() {
  77. return _rules_rules_collect_items('data_info');
  78. }
  79. /**
  80. * Implements hook_rules_data_info_alter().
  81. */
  82. function rules_rules_data_info_alter(&$items) {
  83. // For now just invoke the rules core implementation manually.
  84. rules_rules_core_data_info_alter($items);
  85. }
  86. /**
  87. * Implements hook_rules_evaluator_info().
  88. */
  89. function rules_rules_evaluator_info() {
  90. return _rules_rules_collect_items('evaluator_info');
  91. }
  92. /**
  93. * Implements hook_rules_data_processor_info().
  94. */
  95. function rules_rules_data_processor_info() {
  96. return _rules_rules_collect_items('data_processor_info');
  97. }