1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Contains install and update functions for ctools.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Use requirements to ensure that the CTools CSS cache directory can be
|
10
|
* created and that the PHP version requirement is met.
|
11
|
*/
|
12
|
function ctools_requirements($phase) {
|
13
|
$requirements = array();
|
14
|
if ($phase == 'runtime') {
|
15
|
$requirements['ctools_css_cache'] = array(
|
16
|
'title' => t('CTools CSS Cache'),
|
17
|
'severity' => REQUIREMENT_OK,
|
18
|
'value' => t('Exists'),
|
19
|
);
|
20
|
|
21
|
$path = 'public://ctools/css';
|
22
|
if (!file_prepare_directory($path, FILE_CREATE_DIRECTORY)) {
|
23
|
$requirements['ctools_css_cache']['description'] = t('The CTools CSS cache directory, %path could not be created due to a misconfigured files directory. Please ensure that the files directory is correctly configured and that the webserver has permission to create directories.', array('%path' => file_uri_target($path)));
|
24
|
$requirements['ctools_css_cache']['severity'] = REQUIREMENT_ERROR;
|
25
|
$requirements['ctools_css_cache']['value'] = t('Unable to create');
|
26
|
}
|
27
|
|
28
|
if (!function_exists('error_get_last')) {
|
29
|
$requirements['ctools_php_52']['title'] = t('CTools PHP requirements');
|
30
|
$requirements['ctools_php_52']['description'] = t('CTools requires certain features only available in PHP 5.2.0 or higher.');
|
31
|
$requirements['ctools_php_52']['severity'] = REQUIREMENT_WARNING;
|
32
|
$requirements['ctools_php_52']['value'] = t('PHP !version', array('!version' => phpversion()));
|
33
|
}
|
34
|
}
|
35
|
|
36
|
return $requirements;
|
37
|
}
|
38
|
|
39
|
/**
|
40
|
* Implements hook_schema().
|
41
|
*/
|
42
|
function ctools_schema() {
|
43
|
return ctools_schema_3();
|
44
|
}
|
45
|
|
46
|
/**
|
47
|
* Version 3 of the CTools schema.
|
48
|
*/
|
49
|
function ctools_schema_3() {
|
50
|
$schema = ctools_schema_2();
|
51
|
|
52
|
// update the 'obj' field to be 128 bytes long:
|
53
|
$schema['ctools_object_cache']['fields']['obj']['length'] = 128;
|
54
|
|
55
|
return $schema;
|
56
|
}
|
57
|
|
58
|
/**
|
59
|
* Version 2 of the CTools schema.
|
60
|
*/
|
61
|
function ctools_schema_2() {
|
62
|
$schema = ctools_schema_1();
|
63
|
|
64
|
// update the 'name' field to be 128 bytes long:
|
65
|
$schema['ctools_object_cache']['fields']['name']['length'] = 128;
|
66
|
|
67
|
// Update the 'data' field to be type 'blob'.
|
68
|
$schema['ctools_object_cache']['fields']['data'] = array(
|
69
|
'type' => 'blob',
|
70
|
'size' => 'big',
|
71
|
'description' => 'Serialized data being stored.',
|
72
|
'serialize' => TRUE,
|
73
|
);
|
74
|
|
75
|
// DO NOT MODIFY THIS TABLE -- this definition is used to create the table.
|
76
|
// Changes to this table must be made in schema_3 or higher.
|
77
|
$schema['ctools_css_cache'] = array(
|
78
|
'description' => 'A special cache used to store CSS that must be non-volatile.',
|
79
|
'fields' => array(
|
80
|
'cid' => array(
|
81
|
'type' => 'varchar',
|
82
|
'length' => '128',
|
83
|
'description' => 'The CSS ID this cache object belongs to.',
|
84
|
'not null' => TRUE,
|
85
|
),
|
86
|
'filename' => array(
|
87
|
'type' => 'varchar',
|
88
|
'length' => '255',
|
89
|
'description' => 'The filename this CSS is stored in.',
|
90
|
),
|
91
|
'css' => array(
|
92
|
'type' => 'text',
|
93
|
'size' => 'big',
|
94
|
'description' => 'CSS being stored.',
|
95
|
'serialize' => TRUE,
|
96
|
),
|
97
|
'filter' => array(
|
98
|
'type' => 'int',
|
99
|
'size' => 'tiny',
|
100
|
'description' => 'Whether or not this CSS needs to be filtered.',
|
101
|
),
|
102
|
),
|
103
|
'primary key' => array('cid'),
|
104
|
);
|
105
|
|
106
|
return $schema;
|
107
|
}
|
108
|
|
109
|
/**
|
110
|
* CTools' initial schema; separated for the purposes of updates.
|
111
|
*
|
112
|
* DO NOT MAKE CHANGES HERE. This schema version is locked.
|
113
|
*/
|
114
|
function ctools_schema_1() {
|
115
|
$schema['ctools_object_cache'] = array(
|
116
|
'description' => t('A special cache used to store objects that are being edited; it serves to save state in an ordinarily stateless environment.'),
|
117
|
'fields' => array(
|
118
|
'sid' => array(
|
119
|
'type' => 'varchar',
|
120
|
'length' => '64',
|
121
|
'not null' => TRUE,
|
122
|
'description' => 'The session ID this cache object belongs to.',
|
123
|
),
|
124
|
'name' => array(
|
125
|
'type' => 'varchar',
|
126
|
'length' => '32',
|
127
|
'not null' => TRUE,
|
128
|
'description' => 'The name of the object this cache is attached to.',
|
129
|
),
|
130
|
'obj' => array(
|
131
|
'type' => 'varchar',
|
132
|
'length' => '32',
|
133
|
'not null' => TRUE,
|
134
|
'description' => 'The type of the object this cache is attached to; this essentially represents the owner so that several sub-systems can use this cache.',
|
135
|
),
|
136
|
'updated' => array(
|
137
|
'type' => 'int',
|
138
|
'unsigned' => TRUE,
|
139
|
'not null' => TRUE,
|
140
|
'default' => 0,
|
141
|
'description' => 'The time this cache was created or updated.',
|
142
|
),
|
143
|
'data' => array(
|
144
|
'type' => 'text',
|
145
|
'size' => 'big',
|
146
|
'description' => 'Serialized data being stored.',
|
147
|
'serialize' => TRUE,
|
148
|
),
|
149
|
),
|
150
|
'primary key' => array('sid', 'obj', 'name'),
|
151
|
'indexes' => array('updated' => array('updated')),
|
152
|
);
|
153
|
return $schema;
|
154
|
}
|
155
|
|
156
|
/**
|
157
|
* Implements hook_install().
|
158
|
*/
|
159
|
function ctools_install() {
|
160
|
// Activate our custom cache handler for the CSS cache.
|
161
|
variable_set('cache_class_cache_ctools_css', 'CToolsCssCache');
|
162
|
}
|
163
|
|
164
|
/**
|
165
|
* Implements hook_uninstall().
|
166
|
*/
|
167
|
function ctools_uninstall() {
|
168
|
variable_del('cache_class_cache_ctools_css');
|
169
|
}
|
170
|
|
171
|
/**
|
172
|
* Enlarge the ctools_object_cache.name column to prevent truncation and weird
|
173
|
* errors.
|
174
|
*/
|
175
|
function ctools_update_6001() {
|
176
|
// Perform updates like this to reduce code duplication.
|
177
|
$schema = ctools_schema_2();
|
178
|
|
179
|
db_change_field('ctools_object_cache', 'name', 'name', $schema['ctools_object_cache']['fields']['name']);
|
180
|
}
|
181
|
|
182
|
/**
|
183
|
* Add the new css cache table.
|
184
|
*/
|
185
|
function ctools_update_6002() {
|
186
|
// Schema 2 is locked and should not be changed.
|
187
|
$schema = ctools_schema_2();
|
188
|
|
189
|
db_create_table('ctools_css_cache', $schema['ctools_css_cache']);
|
190
|
}
|
191
|
|
192
|
/**
|
193
|
* Take over for the panels_views module if it was on.
|
194
|
*/
|
195
|
function ctools_update_6003() {
|
196
|
$result = db_query('SELECT status FROM {system} WHERE name = :name', array(':name' => 'panels_views'))->fetchField();
|
197
|
if ($result) {
|
198
|
db_delete('system')->condition('name', 'panels_views')->execute();
|
199
|
module_enable(array('views_content'), TRUE);
|
200
|
}
|
201
|
}
|
202
|
|
203
|
/**
|
204
|
* Add primary key to the ctools_object_cache table.
|
205
|
*/
|
206
|
function ctools_update_6004() {
|
207
|
db_add_primary_key('ctools_object_cache', array('sid', 'obj', 'name'));
|
208
|
db_drop_index('ctools_object_cache', 'sid_obj_name');
|
209
|
}
|
210
|
|
211
|
/**
|
212
|
* Removed update.
|
213
|
*/
|
214
|
function ctools_update_6005() {
|
215
|
return array();
|
216
|
}
|
217
|
|
218
|
/**
|
219
|
* ctools_custom_content table was originally here, but is now moved to
|
220
|
* its own module.
|
221
|
*/
|
222
|
function ctools_update_6007() {
|
223
|
$ret = array();
|
224
|
if (db_table_exists('ctools_custom_content')) {
|
225
|
// Enable the module to make everything as seamless as possible.
|
226
|
module_enable(array('ctools_custom_content'), TRUE);
|
227
|
}
|
228
|
|
229
|
return $ret;
|
230
|
}
|
231
|
|
232
|
/**
|
233
|
* ctools_object_cache needs to be defined as a blob.
|
234
|
*/
|
235
|
function ctools_update_6008() {
|
236
|
db_delete('ctools_object_cache')
|
237
|
->execute();
|
238
|
|
239
|
db_change_field('ctools_object_cache', 'data', 'data', array(
|
240
|
'type' => 'blob',
|
241
|
'size' => 'big',
|
242
|
'description' => 'Serialized data being stored.',
|
243
|
'serialize' => TRUE,
|
244
|
)
|
245
|
);
|
246
|
}
|
247
|
|
248
|
/**
|
249
|
* Enable the custom CSS cache handler.
|
250
|
*/
|
251
|
function ctools_update_7000() {
|
252
|
variable_set('cache_class_cache_ctools_css', 'CToolsCssCache');
|
253
|
}
|
254
|
|
255
|
/**
|
256
|
* Increase the length of the ctools_object_cache.obj column.
|
257
|
*/
|
258
|
function ctools_update_7001() {
|
259
|
db_change_field('ctools_object_cache', 'obj', 'obj', array(
|
260
|
'type' => 'varchar',
|
261
|
'length' => '128',
|
262
|
'not null' => TRUE,
|
263
|
'description' => 'The type of the object this cache is attached to; this essentially represents the owner so that several sub-systems can use this cache.',
|
264
|
));
|
265
|
}
|