-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathrules.install
267 lines (257 loc) · 8.24 KB
/
rules.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<?php
/**
* @file
* Rules - Installation file.
*/
/**
* Implements hook_enable().
*/
function rules_enable() {
// Enable evaluation of Rules right after enabling the module.
rules_event_invocation_enabled(TRUE);
}
/**
* Implements hook_install().
*/
function rules_install() {
module_load_include('inc', 'rules', 'modules/events');
// Set the modules' weight to 20, see
// https://www.drupal.org/node/445084#comment-1533280 for the reasoning.
db_query("UPDATE {system} SET weight = 20 WHERE name = 'rules'");
}
/**
* Implements hook_schema().
*/
function rules_schema() {
$schema['rules_config'] = array(
'fields' => array(
'id' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'The internal identifier for any configuration.',
),
'name' => array(
'type' => 'varchar',
'length' => '64',
'not null' => TRUE,
'description' => 'The name of the configuration.',
),
'label' => array(
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
'description' => 'The label of the configuration.',
'default' => 'unlabeled',
),
'plugin' => array(
'type' => 'varchar',
'length' => 127,
'not null' => TRUE,
'description' => 'The name of the plugin of this configuration.',
),
'active' => array(
'description' => 'Boolean indicating whether the configuration is active. Usage depends on how the using module makes use of it.',
'type' => 'int',
'not null' => TRUE,
'default' => 1,
),
'weight' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => 'Weight of the configuration. Usage depends on how the using module makes use of it.',
),
'status' => array(
'type' => 'int',
'not null' => TRUE,
// Set the default to ENTITY_CUSTOM without using the constant as it is
// not safe to use it at this point.
'default' => 0x01,
'size' => 'tiny',
'description' => 'The exportable status of the entity.',
),
'dirty' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => 'Dirty configurations fail the integrity check, e.g. due to missing dependencies.',
),
'module' => array(
'description' => 'The name of the providing module if the entity has been defined in code.',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
),
'owner' => array(
'description' => 'The name of the module via which the rule has been configured.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => 'rules',
),
'access_exposed' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => 'Whether to use a permission to control access for using components.',
),
'data' => array(
'type' => 'blob',
'size' => 'big',
'not null' => FALSE,
'serialize' => TRUE,
'description' => 'Everything else, serialized.',
),
),
'primary key' => array('id'),
'unique keys' => array(
'name' => array('name'),
),
'indexes' => array(
'plugin' => array('plugin', 'active'),
),
);
$schema['rules_trigger'] = array(
'fields' => array(
'id' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'The primary identifier of the configuration.',
),
'event' => array(
'type' => 'varchar',
'length' => '127',
'not null' => TRUE,
'default' => '',
'description' => 'The name of the event on which the configuration should be triggered.',
),
),
'primary key' => array('id', 'event'),
'foreign keys' => array(
'table' => 'rules_config',
'columns' => array('id' => 'id'),
),
);
$schema['rules_tags'] = array(
'fields' => array(
'id' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'The primary identifier of the configuration.',
),
'tag' => array(
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
'description' => 'The tag string associated with this configuration',
),
),
'primary key' => array('id', 'tag'),
'foreign keys' => array(
'table' => 'rules_config',
'columns' => array('id' => 'id'),
),
);
$schema['rules_dependencies'] = array(
'fields' => array(
'id' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'The primary identifier of the configuration.',
),
'module' => array(
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
'description' => 'The name of the module that is required for the configuration.',
),
),
'primary key' => array('id', 'module'),
'indexes' => array(
'module' => array('module'),
),
'foreign keys' => array(
'table' => 'rules_config',
'columns' => array('id' => 'id'),
),
);
$schema['cache_rules'] = backdrop_get_schema_unprocessed('system', 'cache');
$schema['cache_rules']['description'] = 'Cache table for the rules engine to store configured items.';
return $schema;
}
/**
* Implements hook_update_last_removed().
*/
function rules_update_last_removed() {
return 7214;
}
/**
* Move Rules settings from variables to config.
*/
function rules_update_1000() {
$info = 1;
$warning = 2;
// Migrate variables to config.
$config = config('rules.settings');
$config->set('rules_log_errors', update_variable_get('rules_log_errors', $warning));
$config->set('rules_log_level', update_variable_get('rules_log_level', $info));
$config->set('rules_debug_log', update_variable_get('rules_debug_log', 0));
$config->set('rules_debug', update_variable_get('rules_log_debug', $warning));
$config->set('rules_path_cleaning_callback', update_variable_get('rules_path_cleaning_callback', 'rules_path_default_cleaning_method'));
$config->set('rules_path_replacement_char', update_variable_get('rules_path_replacement_char', '-'));
$config->set('rules_path_lower_case', update_variable_get('rules_path_lower_case', TRUE));
$config->set('rules_clean_path', update_variable_get('rules_clean_path', array('/[^a-zA-Z0-9\-_]+/', '-')));
$config->set('rules_path_transliteration', update_variable_get('rules_path_transliteration', TRUE));
$config->save();
// Delete variables.
update_variable_del('rules_log_errors');
update_variable_del('rules_log_level');
update_variable_del('rules_debug_log');
update_variable_del('rules_debug');
update_variable_del('rules_debug_region');
update_variable_del('theme_default');
update_variable_del('admin_theme');
update_variable_del('rules_path_cleaning_callback');
update_variable_del('rules_path_replacement_char');
update_variable_del('rules_path_lower_case');
update_variable_del('rules_clean_path');
update_variable_del('rules_path_transliteration');
update_variable_del('site_mail');
}
/**
* Remove settings that are now obtained from system.core.
*/
function rules_update_1001() {
$config = config('rules.settings');
$config->clear('theme_default');
$config->clear('admin_theme');
$config->clear('site_mail');
$config->save();
}
/**
* Deprecate 'rules_clean_path' config variable in favor of 'rules_path_regex'.
*/
function rules_update_1002() {
$rules_clean_path = config_get('rules.settings', 'rules_clean_path');
if (is_array($rules_clean_path) && count($rules_clean_path) == 2) {
config_set('rules.settings', 'rules_path_regex', $rules_clean_path[0]);
}
else {
config_set('rules.settings', 'rules_path_regex', '/[^a-zA-Z0-9\-_]+/');
}
config_clear('rules.settings', 'rules_clean_path');
}
/**
* Remove superfluous config variable 'language_content_type_page'.
*/
function rules_update_1003() {
$config = config('rules.settings');
$config->clear('language_content_type_page');
$config->save();
}