forked from backdrop-contrib/rules
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrules.install
More file actions
236 lines (229 loc) · 7.77 KB
/
rules.install
File metadata and controls
236 lines (229 loc) · 7.77 KB
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
<?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
// http://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'),
),
);
$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;
}
/**
* Move book settings from variables to config.
*/
function rules_update_1000() {
// Migrate variables to config.
$config = config('rules.settings');
$config->set('rules_log_errors', update_variable_get('rules_log_errors', 'RulesLog::WARN'));
$config->set('rules_log_level', update_variable_get('rules_log_level', 'self::INFO'));
$config->set('rules_debug_log', update_variable_get('rules_debug_log', '0'));
$config->set('rules_debug', update_variable_get('rules_log_debug', 'RulesLog::WARN'));
$config->set('rules_debug_region', update_variable_get('rules_debug_region', ''));
$config->set('theme_default', update_variable_get('theme_default', 'bartik'));
$config->set('admin_theme', update_variable_get('admin_theme', 'seven'));
$config->set('language_content_type_page', update_variable_get('language_content_type_page', '1'));
$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\-_]+/", $replace)'));
$config->set('rules_path_transliteration', update_variable_get('rules_path_transliteration', 'TRUE'));
$config->set('site_mail', update_variable_get('site_mail', "ini_get('sendmail_from')"));
$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('language_content_type_page');
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');
}
/**
* Implements hook_update_last_removed().
*/
function rules_update_last_removed() {
return 7214;
}