Projet

Général

Profil

Paste
Télécharger (4,48 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / rules / rules_admin / rules_admin.module @ 950416da

1
<?php
2

    
3
/**
4
 * @file
5
 * Rules Admin User Interface.
6
 */
7

    
8
/**
9
 * Implements hook_menu().
10
 */
11
function rules_admin_menu() {
12
  // Reaction rules UI menu entries.
13
  $reaction_path = 'admin/config/workflow/rules/reaction';
14
  $items = rules_ui()->config_menu($reaction_path);
15

    
16
  $items[$reaction_path] = array(
17
    'title' => 'Rules',
18
    'type' => MENU_DEFAULT_LOCAL_TASK,
19
    'weight' => -1,
20
  );
21
  $items[$reaction_path . '/add'] = array(
22
    'title' => 'Add new rule',
23
    'page callback' => 'drupal_get_form',
24
    'page arguments' => array('rules_admin_add_reaction_rule', $reaction_path),
25
    'access arguments' => array('administer rules'),
26
    'type' => MENU_LOCAL_ACTION,
27
    'file' => 'rules_admin.inc',
28
    'weight' => 0,
29
  );
30
  $items[$reaction_path . '/import'] = array(
31
    'title' => 'Import rule',
32
    'page callback' => 'drupal_get_form',
33
    'page arguments' => array('rules_ui_import_form', $reaction_path),
34
    'access arguments' => array('administer rules'),
35
    'file' => 'ui/ui.forms.inc',
36
    'file path' => drupal_get_path('module', 'rules'),
37
    'type' => MENU_LOCAL_ACTION,
38
  );
39

    
40
  // Components UI menu entries.
41
  $component_path = 'admin/config/workflow/rules/components';
42
  $items += rules_ui()->config_menu($component_path);
43
  $items[$component_path] = array(
44
    'title' => 'Components',
45
    'page callback' => 'drupal_get_form',
46
    'page arguments' => array('rules_admin_components_overview', $component_path),
47
    'access arguments' => array('administer rules'),
48
    'type' => MENU_LOCAL_TASK,
49
    'file' => 'rules_admin.inc',
50
    'weight' => 0,
51
  );
52
  $items[$component_path . '/add'] = array(
53
    'title' => 'Add new component',
54
    'page callback' => 'drupal_get_form',
55
    'page arguments' => array('rules_admin_add_component', $component_path),
56
    'access arguments' => array('administer rules'),
57
    'type' => MENU_LOCAL_ACTION,
58
    'file' => 'rules_admin.inc',
59
    'weight' => 0,
60
  );
61
  $items[$component_path . '/import'] = array(
62
    'title' => 'Import component',
63
    'page callback' => 'drupal_get_form',
64
    'page arguments' => array('rules_ui_import_form', $component_path),
65
    'access arguments' => array('administer rules'),
66
    'file' => 'ui/ui.forms.inc',
67
    'file path' => drupal_get_path('module', 'rules'),
68
    'type' => MENU_LOCAL_ACTION,
69
  );
70

    
71
  // Some general rules admin menu items.
72
  $items['admin/config/workflow/rules'] = array(
73
    'title' => 'Rules',
74
    'position' => 'right',
75
    'page callback' => 'drupal_get_form',
76
    'page arguments' => array('rules_admin_reaction_overview', $reaction_path),
77
    'description' => 'Manage reaction rules and rule components.',
78
    'access arguments' => array('administer rules'),
79
    'file' => 'rules_admin.inc',
80
  );
81
  $items['admin/config/workflow/rules/settings'] = array(
82
    'title' => 'Settings',
83
    'page callback' => 'drupal_get_form',
84
    'page arguments' => array('rules_admin_settings'),
85
    'access arguments' => array('administer rules'),
86
    'type' => MENU_LOCAL_TASK,
87
    'file' => 'rules_admin.inc',
88
    'weight' => 1,
89
  );
90
  $items['admin/config/workflow/rules/settings/basic'] = array(
91
    'title' => 'Basic',
92
    'type' => MENU_DEFAULT_LOCAL_TASK,
93
    'weight' => -10,
94
  );
95
  $items['admin/config/workflow/rules/settings/advanced'] = array(
96
    'title' => 'Advanced',
97
    'type' => MENU_LOCAL_TASK,
98
    'page callback' => 'drupal_get_form',
99
    'page arguments' => array('rules_admin_settings_advanced'),
100
    'access arguments' => array('administer rules'),
101
    'file' => 'rules_admin.inc',
102
  );
103
  return $items;
104
}
105

    
106
/**
107
 * Implements hook_form_alter().
108
 *
109
 * Since the overview forms are GET forms, we don't want them to send a wide
110
 * variety of information. We need to use hook_form_alter() because the
111
 * properties are added after form creation.
112
 */
113
function rules_admin_form_alter(&$form, &$form_state, $form_id) {
114
  if ($form_id == 'rules_admin_reaction_overview' || $form_id == 'rules_admin_components_overview') {
115
    $form['form_build_id']['#access'] = FALSE;
116
    $form['form_token']['#access'] = FALSE;
117
    $form['form_id']['#access'] = FALSE;
118
  }
119
}
120

    
121
/**
122
 * Implements hook_system_info_alter().
123
 *
124
 * Adds configuration links for Rules and Rules Scheduler in the modules list.
125
 * (This is done by the Rules UI module, without which there would be no
126
 * configuration pages to visit.)
127
 */
128
function rules_admin_system_info_alter(&$info, $file, $type) {
129
  if ($file->name == 'rules') {
130
    $info['configure'] = 'admin/config/workflow/rules';
131
  }
132
  if ($file->name == 'rules_scheduler') {
133
    $info['configure'] = 'admin/config/workflow/rules/schedule';
134
  }
135
}