1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Rules Scheduler - Installation file.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Implements hook_schema().
|
10 |
|
|
*/
|
11 |
|
|
function rules_scheduler_schema() {
|
12 |
|
|
$schema['rules_scheduler'] = array(
|
13 |
|
|
'description' => 'Stores scheduled tasks.',
|
14 |
|
|
'fields' => array(
|
15 |
|
|
'tid' => array(
|
16 |
|
|
'type' => 'serial',
|
17 |
|
|
'unsigned' => TRUE,
|
18 |
|
|
'not null' => TRUE,
|
19 |
|
|
'description' => "The scheduled task's id.",
|
20 |
|
|
),
|
21 |
|
|
'config' => array(
|
22 |
|
|
'type' => 'varchar',
|
23 |
|
|
'length' => '64',
|
24 |
|
|
'default' => '',
|
25 |
|
|
'not null' => TRUE,
|
26 |
|
|
'description' => "The scheduled configuration's name.",
|
27 |
|
|
),
|
28 |
|
|
'date' => array(
|
29 |
|
|
'description' => 'The Unix timestamp of when the task is to be scheduled.',
|
30 |
|
|
'type' => 'int',
|
31 |
|
|
'not null' => TRUE,
|
32 |
|
|
),
|
33 |
|
|
'data' => array(
|
34 |
|
|
'type' => 'text',
|
35 |
|
|
'not null' => FALSE,
|
36 |
|
|
'serialize' => TRUE,
|
37 |
|
|
'description' => 'The whole, serialized evaluation data.',
|
38 |
|
|
),
|
39 |
|
|
'identifier' => array(
|
40 |
|
|
'type' => 'varchar',
|
41 |
|
|
'length' => '255',
|
42 |
|
|
'default' => '',
|
43 |
|
|
'not null' => FALSE,
|
44 |
|
|
'description' => 'The user defined string identifying this task.',
|
45 |
|
|
),
|
46 |
|
|
'handler' => array(
|
47 |
|
|
'type' => 'varchar',
|
48 |
|
|
'length' => '255',
|
49 |
|
|
'not null' => FALSE,
|
50 |
|
|
'description' => 'The fully qualified class name of a the queue item handler.',
|
51 |
|
|
),
|
52 |
|
|
),
|
53 |
|
|
'primary key' => array('tid'),
|
54 |
|
|
'indexes' => array(
|
55 |
|
|
'date' => array('date'),
|
56 |
|
|
),
|
57 |
|
|
'unique key' => array(
|
58 |
|
|
'id' => array('config', 'identifier'),
|
59 |
|
|
),
|
60 |
|
|
);
|
61 |
|
|
return $schema;
|
62 |
|
|
}
|
63 |
|
|
|
64 |
|
|
/**
|
65 |
|
|
* Upgrade from Rules scheduler 6.x-1.x to 7.x.
|
66 |
|
|
*/
|
67 |
|
|
function rules_scheduler_update_7200() {
|
68 |
|
|
// Rename the old table so we can keep its content and start over with a
|
69 |
|
|
// fresh one.
|
70 |
|
|
db_rename_table('rules_scheduler', 'rules_scheduler_d6');
|
71 |
|
|
// Create the d7 table.
|
72 |
|
|
$schema['rules_scheduler'] = array(
|
73 |
|
|
'description' => 'Stores scheduled tasks.',
|
74 |
|
|
'fields' => array(
|
75 |
|
|
'tid' => array(
|
76 |
|
|
'type' => 'serial',
|
77 |
|
|
'unsigned' => TRUE,
|
78 |
|
|
'not null' => TRUE,
|
79 |
|
|
'description' => "The scheduled task's id.",
|
80 |
|
|
),
|
81 |
|
|
'config' => array(
|
82 |
|
|
'type' => 'varchar',
|
83 |
|
|
'length' => '255',
|
84 |
|
|
'default' => '',
|
85 |
|
|
'not null' => TRUE,
|
86 |
|
|
'description' => "The scheduled configuration's name.",
|
87 |
|
|
),
|
88 |
|
|
'date' => array(
|
89 |
|
|
'description' => 'The Unix timestamp of when the task is to be scheduled.',
|
90 |
|
|
'type' => 'int',
|
91 |
|
|
'not null' => TRUE,
|
92 |
|
|
),
|
93 |
|
|
'data' => array(
|
94 |
|
|
'type' => 'text',
|
95 |
|
|
'not null' => FALSE,
|
96 |
|
|
'serialize' => TRUE,
|
97 |
|
|
'description' => 'The whole, serialized evaluation data.',
|
98 |
|
|
),
|
99 |
|
|
'identifier' => array(
|
100 |
|
|
'type' => 'varchar',
|
101 |
|
|
'length' => '255',
|
102 |
|
|
'default' => '',
|
103 |
|
|
'not null' => FALSE,
|
104 |
|
|
'description' => 'The user defined string identifying this task.',
|
105 |
|
|
),
|
106 |
|
|
),
|
107 |
|
|
'primary key' => array('tid'),
|
108 |
|
|
'indexes' => array('date' => array('date')),
|
109 |
|
|
);
|
110 |
|
|
db_create_table('rules_scheduler', $schema['rules_scheduler']);
|
111 |
|
|
}
|
112 |
|
|
|
113 |
|
|
/**
|
114 |
|
|
* Fix the length of the rules_scheduler.name column.
|
115 |
|
|
*/
|
116 |
|
|
function rules_scheduler_update_7202() {
|
117 |
|
|
// Note that update 7201 (add the 'id' unique key') has been removed as it is
|
118 |
|
|
// incorporated by 7202. For anyone that has already run the previous update
|
119 |
|
|
// 7201, we have to first drop the unique key.
|
120 |
|
|
db_drop_unique_key('rules_scheduler', 'id');
|
121 |
|
|
db_change_field('rules_scheduler', 'config', 'config', array(
|
122 |
|
|
'type' => 'varchar',
|
123 |
|
|
'length' => '64',
|
124 |
|
|
'default' => '',
|
125 |
|
|
'not null' => TRUE,
|
126 |
|
|
'description' => "The scheduled configuration's name.",
|
127 |
|
|
));
|
128 |
|
|
db_add_unique_key('rules_scheduler', 'id', array('config', 'identifier'));
|
129 |
|
|
}
|
130 |
|
|
|
131 |
|
|
/**
|
132 |
|
|
* Add a database column for specifying a queue item handler.
|
133 |
|
|
*/
|
134 |
|
|
function rules_scheduler_update_7203() {
|
135 |
|
|
db_add_field('rules_scheduler', 'handler', array(
|
136 |
|
|
'type' => 'varchar',
|
137 |
|
|
'length' => '255',
|
138 |
|
|
'not null' => FALSE,
|
139 |
|
|
'description' => 'The fully qualified class name of a the queue item handler.',
|
140 |
|
|
));
|
141 |
|
|
}
|
142 |
|
|
|
143 |
|
|
/**
|
144 |
|
|
* Rename rules_scheduler.state into rules_scheduler.data.
|
145 |
|
|
*/
|
146 |
|
|
function rules_scheduler_update_7204() {
|
147 |
76e2e7c3
|
Assos Assos
|
if (db_field_exists('rules_scheduler', 'state')) {
|
148 |
|
|
db_change_field('rules_scheduler', 'state', 'data', array(
|
149 |
|
|
'type' => 'text',
|
150 |
|
|
'not null' => FALSE,
|
151 |
|
|
'serialize' => TRUE,
|
152 |
|
|
'description' => 'The whole, serialized evaluation data.',
|
153 |
|
|
));
|
154 |
|
|
}
|
155 |
85ad3d82
|
Assos Assos
|
}
|
156 |
|
|
|
157 |
|
|
/**
|
158 |
|
|
* Rules upgrade callback for mapping the action name.
|
159 |
|
|
*/
|
160 |
|
|
function rules_scheduler_action_upgrade_map_name($element) {
|
161 |
|
|
return 'schedule';
|
162 |
|
|
}
|
163 |
|
|
|
164 |
|
|
/**
|
165 |
|
|
* Rules upgrade callback.
|
166 |
|
|
*/
|
167 |
|
|
function rules_scheduler_action_upgrade($element, $target) {
|
168 |
|
|
$target->settings['component'] = $element['#info']['set'];
|
169 |
|
|
$target->settings['date'] = $element['#settings']['task_date'];
|
170 |
|
|
$target->settings['identifier'] = $element['#settings']['task_identifier'];
|
171 |
|
|
|
172 |
|
|
unset($element['#info']['arguments']['task_date'], $element['#info']['arguments']['task_identifier']);
|
173 |
|
|
foreach ($element['#info']['arguments'] as $name => $info) {
|
174 |
|
|
rules_upgrade_element_parameter_settings($element, $target, $name, $info, 'param_' . $name);
|
175 |
|
|
}
|
176 |
|
|
}
|
177 |
|
|
|
178 |
|
|
/**
|
179 |
|
|
* Rules upgrade callback for mapping the action name.
|
180 |
|
|
*/
|
181 |
|
|
function rules_action_delete_scheduled_set_upgrade_map_name($element) {
|
182 |
|
|
return 'schedule_delete';
|
183 |
|
|
}
|
184 |
|
|
|
185 |
|
|
/**
|
186 |
|
|
* Rules upgrade callback.
|
187 |
|
|
*/
|
188 |
|
|
function rules_action_delete_scheduled_set_upgrade($element, $target) {
|
189 |
|
|
$target->settings['component'] = $element['#settings']['ruleset'];
|
190 |
|
|
$target->settings['task'] = $element['#settings']['task_identifier'];
|
191 |
|
|
} |