comparison modules/rules/rules_scheduler/rules_scheduler.install @ 4:ce11bbd8f642

added modules
author danieleb <danielebarchiesi@me.com>
date Thu, 19 Sep 2013 10:38:44 +0100
parents
children
comparison
equal deleted inserted replaced
3:b28be78d8160 4:ce11bbd8f642
1 <?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 db_change_field('rules_scheduler', 'state', 'data', array(
148 'type' => 'text',
149 'not null' => FALSE,
150 'serialize' => TRUE,
151 'description' => 'The whole, serialized evaluation data.',
152 ));
153 }
154
155 /**
156 * Rules upgrade callback for mapping the action name.
157 */
158 function rules_scheduler_action_upgrade_map_name($element) {
159 return 'schedule';
160 }
161
162 /**
163 * Rules upgrade callback.
164 */
165 function rules_scheduler_action_upgrade($element, $target) {
166 $target->settings['component'] = $element['#info']['set'];
167 $target->settings['date'] = $element['#settings']['task_date'];
168 $target->settings['identifier'] = $element['#settings']['task_identifier'];
169
170 unset($element['#info']['arguments']['task_date'], $element['#info']['arguments']['task_identifier']);
171 foreach ($element['#info']['arguments'] as $name => $info) {
172 rules_upgrade_element_parameter_settings($element, $target, $name, $info, 'param_' . $name);
173 }
174 }
175
176 /**
177 * Rules upgrade callback for mapping the action name.
178 */
179 function rules_action_delete_scheduled_set_upgrade_map_name($element) {
180 return 'schedule_delete';
181 }
182
183 /**
184 * Rules upgrade callback.
185 */
186 function rules_action_delete_scheduled_set_upgrade($element, $target) {
187 $target->settings['component'] = $element['#settings']['ruleset'];
188 $target->settings['task'] = $element['#settings']['task_identifier'];
189 }