rules.rules.inc 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. /**
  3. * @file
  4. * Includes any rules integration provided by the module.
  5. */
  6. /**
  7. * Load all module includes as soon as this file gets included, which is done
  8. * automatically by module_implements().
  9. */
  10. foreach (rules_core_modules() as $module) {
  11. module_load_include('inc', 'rules', "modules/$module.rules");
  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. // Make use of the fast, advanced drupal static pattern.
  22. static $drupal_static_fast;
  23. if (!isset($drupal_static_fast)) {
  24. $drupal_static_fast = &drupal_static(__FUNCTION__);
  25. }
  26. $modules = &$drupal_static_fast;
  27. if (!isset($modules)) {
  28. $modules = array('data', 'entity', 'node', 'system', 'user', 'rules_core');
  29. foreach (array('comment', 'taxonomy', 'php', 'path') as $module) {
  30. if (module_exists($module)) {
  31. $modules[] = $module;
  32. }
  33. }
  34. }
  35. return $modules;
  36. }
  37. /**
  38. * Returns all items for a hook applying the right module defaults.
  39. */
  40. function _rules_rules_collect_items($hook) {
  41. $items = array();
  42. foreach (rules_core_modules() as $module) {
  43. if (function_exists($function = "rules_{$module}_{$hook}")) {
  44. $items += (array) $function();
  45. }
  46. }
  47. return $items;
  48. }
  49. /**
  50. * Implements hook_rules_file_info().
  51. */
  52. function rules_rules_file_info() {
  53. // Make use of the fast, advanced drupal static pattern.
  54. static $drupal_static_fast;
  55. if (!isset($drupal_static_fast)) {
  56. $drupal_static_fast = &drupal_static(__FUNCTION__);
  57. }
  58. $items = &$drupal_static_fast;
  59. if (!isset($items)) {
  60. $items = array();
  61. foreach (rules_core_modules() as $module) {
  62. if (function_exists($function = "rules_{$module}_file_info")) {
  63. $items = array_merge($items, (array) $function());
  64. // Automatically add "$module.rules.inc" for each module.
  65. $items[] = 'modules/' . $module . '.rules';
  66. }
  67. }
  68. }
  69. return $items;
  70. }
  71. /**
  72. * Implements hook_rules_category_info().
  73. */
  74. function rules_rules_category_info() {
  75. return _rules_rules_collect_items('category_info');
  76. }
  77. /**
  78. * Implements hook_rules_action_info().
  79. */
  80. function rules_rules_action_info() {
  81. return _rules_rules_collect_items('action_info');
  82. }
  83. /**
  84. * Implements hook_rules_condition_info().
  85. */
  86. function rules_rules_condition_info() {
  87. return _rules_rules_collect_items('condition_info');
  88. }
  89. /**
  90. * Implements hook_rules_event_info().
  91. */
  92. function rules_rules_event_info() {
  93. return _rules_rules_collect_items('event_info');
  94. }
  95. /**
  96. * Implements hook_rules_data_info().
  97. */
  98. function rules_rules_data_info() {
  99. return _rules_rules_collect_items('data_info');
  100. }
  101. /**
  102. * Implements hook_rules_data_info_alter().
  103. */
  104. function rules_rules_data_info_alter(&$items) {
  105. // For now just invoke the rules core implementation manually.
  106. rules_rules_core_data_info_alter($items);
  107. }
  108. /**
  109. * Implements hook_rules_evaluator_info().
  110. */
  111. function rules_rules_evaluator_info() {
  112. return _rules_rules_collect_items('evaluator_info');
  113. }
  114. /**
  115. * Implements hook_rules_data_processor_info().
  116. */
  117. function rules_rules_data_processor_info() {
  118. return _rules_rules_collect_items('data_processor_info');
  119. }