rules.rules.inc 2.8 KB

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