rules_admin.module 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. /**
  3. * @file Rules Admin UI
  4. */
  5. /**
  6. * Implements hook_menu().
  7. */
  8. function rules_admin_menu() {
  9. // Reaction rules UI menu entries.
  10. $reaction_path = 'admin/config/workflow/rules/reaction';
  11. $items = rules_ui()->config_menu($reaction_path);
  12. $items[$reaction_path] = array(
  13. 'title' => 'Rules',
  14. 'type' => MENU_DEFAULT_LOCAL_TASK,
  15. 'weight' => -1,
  16. );
  17. $items[$reaction_path . '/add'] = array(
  18. 'title' => 'Add new rule',
  19. 'page callback' => 'drupal_get_form',
  20. 'page arguments' => array('rules_admin_add_reaction_rule', $reaction_path),
  21. 'access arguments' => array('administer rules'),
  22. 'type' => MENU_LOCAL_ACTION,
  23. 'file' => 'rules_admin.inc',
  24. 'weight' => 0,
  25. );
  26. $items[$reaction_path . '/import'] = array(
  27. 'title' => 'Import rule',
  28. 'page callback' => 'drupal_get_form',
  29. 'page arguments' => array('rules_ui_import_form', $reaction_path),
  30. 'access arguments' => array('administer rules'),
  31. 'file' => 'ui/ui.forms.inc',
  32. 'file path' => drupal_get_path('module', 'rules'),
  33. 'type' => MENU_LOCAL_ACTION,
  34. );
  35. // Components UI menu entries.
  36. $component_path = 'admin/config/workflow/rules/components';
  37. $items += rules_ui()->config_menu($component_path);
  38. $items[$component_path] = array(
  39. 'title' => 'Components',
  40. 'page callback' => 'drupal_get_form',
  41. 'page arguments' => array('rules_admin_components_overview', $component_path),
  42. 'access arguments' => array('administer rules'),
  43. 'type' => MENU_LOCAL_TASK,
  44. 'file' => 'rules_admin.inc',
  45. 'weight' => 0,
  46. );
  47. $items[$component_path . '/add'] = array(
  48. 'title' => 'Add new component',
  49. 'page callback' => 'drupal_get_form',
  50. 'page arguments' => array('rules_admin_add_component', $component_path),
  51. 'access arguments' => array('administer rules'),
  52. 'type' => MENU_LOCAL_ACTION,
  53. 'file' => 'rules_admin.inc',
  54. 'weight' => 0,
  55. );
  56. $items[$component_path . '/import'] = array(
  57. 'title' => 'Import component',
  58. 'page callback' => 'drupal_get_form',
  59. 'page arguments' => array('rules_ui_import_form', $component_path),
  60. 'access arguments' => array('administer rules'),
  61. 'file' => 'ui/ui.forms.inc',
  62. 'file path' => drupal_get_path('module', 'rules'),
  63. 'type' => MENU_LOCAL_ACTION,
  64. );
  65. // Some general rules admin menu items.
  66. $items['admin/config/workflow/rules'] = array(
  67. 'title' => 'Rules',
  68. 'position' => 'right',
  69. 'page callback' => 'drupal_get_form',
  70. 'page arguments' => array('rules_admin_reaction_overview', $reaction_path),
  71. 'description' => 'Manage reaction rules and rule components.',
  72. 'access arguments' => array('administer rules'),
  73. 'file' => 'rules_admin.inc',
  74. );
  75. $items['admin/config/workflow/rules/settings'] = array(
  76. 'title' => 'Settings',
  77. 'page callback' => 'drupal_get_form',
  78. 'page arguments' => array('rules_admin_settings'),
  79. 'access arguments' => array('administer rules'),
  80. 'type' => MENU_LOCAL_TASK,
  81. 'file' => 'rules_admin.inc',
  82. 'weight' => 1,
  83. );
  84. $items['admin/config/workflow/rules/settings/basic'] = array(
  85. 'title' => 'Basic',
  86. 'type' => MENU_DEFAULT_LOCAL_TASK,
  87. 'weight' => -10,
  88. );
  89. $items['admin/config/workflow/rules/settings/advanced'] = array(
  90. 'title' => 'Advanced',
  91. 'type' => MENU_LOCAL_TASK,
  92. 'page callback' => 'drupal_get_form',
  93. 'page arguments' => array('rules_admin_settings_advanced'),
  94. 'access arguments' => array('administer rules'),
  95. 'file' => 'rules_admin.inc',
  96. );
  97. return $items;
  98. }
  99. /**
  100. * Implements hook_form_alter().
  101. *
  102. * Since the overview forms are GET forms, we don't want them to send a wide
  103. * variety of information. We need to use hook_form_alter() because the
  104. * properties are added after form creation.
  105. */
  106. function rules_admin_form_alter(&$form, &$form_state, $form_id) {
  107. if ($form_id == 'rules_admin_reaction_overview' || $form_id == 'rules_admin_components_overview') {
  108. $form['form_build_id']['#access'] = FALSE;
  109. $form['form_token']['#access'] = FALSE;
  110. $form['form_id']['#access'] = FALSE;
  111. }
  112. }
  113. /**
  114. * Implements hook_system_info_alter().
  115. *
  116. * Adds configuration links for Rules and Rules Scheduler in the modules list.
  117. * (This is done by the Rules UI module, without which there would be no
  118. * configuration pages to visit.)
  119. */
  120. function rules_admin_system_info_alter(&$info, $file, $type) {
  121. if ($file->name == 'rules') {
  122. $info['configure'] = 'admin/config/workflow/rules';
  123. }
  124. if ($file->name == 'rules_scheduler') {
  125. $info['configure'] = 'admin/config/workflow/rules/schedule';
  126. }
  127. }