rules_admin.module 4.5 KB

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