#999302 by troky: Fix jump menu. Apparently this wasn't actually committed the last...
[project/ctools.git] / ctools.install
CommitLineData
4f8d821f
EM
1<?php
2// $Id$
5b52254b 3
4f8d821f
EM
4/**
5 * @file
6 * Contains install and update functions for ctools.
7 */
8
9/**
a5f36bd1 10 * Use requirements to ensure that the CTools CSS cache directory can be
aeed3fef 11 * created and that the PHP version requirement is met.
a5f36bd1
EM
12 */
13function ctools_requirements($phase) {
14 $requirements = array();
15 if ($phase == 'runtime') {
a5f36bd1
EM
16 $requirements['ctools_css_cache'] = array(
17 'title' => t('CTools CSS Cache'),
18 'severity' => REQUIREMENT_OK,
19 'value' => t('Exists'),
20 );
21
0da7776f
SB
22 $path = 'public://ctools/css';
23 if (!file_prepare_directory($path, FILE_CREATE_DIRECTORY)) {
24 $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)));
a5f36bd1
EM
25 $requirements['ctools_css_cache']['severity'] = REQUIREMENT_ERROR;
26 $requirements['ctools_css_cache']['value'] = t('Unable to create');
27 }
aeed3fef
SB
28
29 if (!function_exists('error_get_last')) {
30 $requirements['ctools_php_52']['title'] = t('CTools PHP requirements');
31 $requirements['ctools_php_52']['description'] = t('CTools requires certain features only available in PHP 5.2.0 or higher.');
32 $requirements['ctools_php_52']['severity'] = REQUIREMENT_WARNING;
33 $requirements['ctools_php_52']['value'] = t('PHP !version', array('!version' => phpversion()));
34 }
a5f36bd1
EM
35 }
36
37 return $requirements;
38}
39
40/**
0da7776f 41 * Implements hook_schemea
4f8d821f
EM
42 */
43function ctools_schema() {
2fefa7a7
EM
44 return ctools_schema_2();
45}
46
47/**
48 * Version 2 of the CTools schema.
49 */
50function ctools_schema_2() {
51 $schema = ctools_schema_1();
52
53 // update the 'name' field to be 128 bytes long:
54 $schema['ctools_object_cache']['fields']['name']['length'] = 128;
55
f427f87f
EM
56 // DO NOT MODIFY THIS TABLE -- this definition is used to create the table.
57 // Changes to this table must be made in schema_3 or higher.
58 $schema['ctools_css_cache'] = array(
f2171c94 59 'description' => 'A special cache used to store CSS that must be non-volatile.',
f427f87f
EM
60 'fields' => array(
61 'cid' => array(
62 'type' => 'varchar',
63 'length' => '128',
f2171c94 64 'description' => 'The CSS ID this cache object belongs to.',
005e9f97 65 'not null' => TRUE,
f427f87f
EM
66 ),
67 'filename' => array(
68 'type' => 'varchar',
69 'length' => '255',
f2171c94 70 'description' => 'The filename this CSS is stored in.',
f427f87f
EM
71 ),
72 'css' => array(
73 'type' => 'text',
74 'size' => 'big',
f2171c94 75 'description' => 'CSS being stored.',
f427f87f
EM
76 'serialize' => TRUE,
77 ),
78 'filter' => array(
79 'type' => 'int',
80 'size' => 'tiny',
f2171c94 81 'description' => 'Whether or not this CSS needs to be filtered.',
f427f87f
EM
82 ),
83 ),
84 'primary key' => array('cid'),
85 );
86
2fefa7a7 87 return $schema;
4f8d821f
EM
88}
89
90/**
f427f87f
EM
91 * CTools' initial schema; separated for the purposes of updates.
92 *
93 * DO NOT MAKE CHANGES HERE. This schema version is locked.
4f8d821f
EM
94 */
95function ctools_schema_1() {
96 $schema['ctools_object_cache'] = array(
97 'description' => t('A special cache used to store objects that are being edited; it serves to save state in an ordinarily stateless environment.'),
98 'fields' => array(
99 'sid' => array(
100 'type' => 'varchar',
101 'length' => '64',
37a303d4 102 'not null' => TRUE,
f2171c94 103 'description' => 'The session ID this cache object belongs to.',
4f8d821f
EM
104 ),
105 'name' => array(
106 'type' => 'varchar',
107 'length' => '32',
37a303d4 108 'not null' => TRUE,
f2171c94 109 'description' => 'The name of the object this cache is attached to.',
4f8d821f
EM
110 ),
111 'obj' => array(
112 'type' => 'varchar',
113 'length' => '32',
37a303d4 114 'not null' => TRUE,
f2171c94 115 '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.',
4f8d821f
EM
116 ),
117 'updated' => array(
118 'type' => 'int',
119 'unsigned' => TRUE,
120 'not null' => TRUE,
121 'default' => 0,
f2171c94 122 'description' => 'The time this cache was created or updated.',
4f8d821f
EM
123 ),
124 'data' => array(
f427f87f 125 'type' => 'text',
23755e33 126 'size' => 'big',
f2171c94 127 'description' => 'Serialized data being stored.',
4f8d821f
EM
128 'serialize' => TRUE,
129 ),
130 ),
ca3a09cb
EM
131 'primary key' => array('sid', 'obj', 'name'),
132 'indexes' => array('updated' => array('updated')),
4f8d821f
EM
133 );
134 return $schema;
135}
2fefa7a7
EM
136
137/**
138 * Enlarge the ctools_object_cache.name column to prevent truncation and weird
139 * errors.
140 */
141function ctools_update_6001() {
2fefa7a7
EM
142 // Perform updates like this to reduce code duplication.
143 $schema = ctools_schema_2();
144
0da7776f 145 db_change_field('ctools_object_cache', 'name', 'name', $schema['ctools_object_cache']['fields']['name']);
2fefa7a7 146}
f427f87f
EM
147
148/**
149 * Add the new css cache table.
150 */
151function ctools_update_6002() {
f427f87f
EM
152 // Schema 2 is locked and should not be changed.
153 $schema = ctools_schema_2();
154
0da7776f 155 db_create_table('ctools_css_cache', $schema['ctools_css_cache']);
f427f87f 156}
5c05eb20
EM
157
158/**
159 * Take over for the panels_views module if it was on.
160 */
161function ctools_update_6003() {
0da7776f 162 $result = db_query('SELECT status FROM {system} WHERE name = :name', array(':name' => 'panels_views'))->fetchField();
5c05eb20 163 if ($result) {
0da7776f 164 db_delete('system')->condition('name', 'panels_views')->execute();
5c05eb20
EM
165 drupal_install_modules(array('views_content'));
166 }
5c05eb20 167}
ca3a09cb
EM
168
169/**
170 * Add primary key to the ctools_object_cache table.
171 */
172function ctools_update_6004() {
0da7776f
SB
173 db_add_primary_key('ctools_object_cache', array('sid', 'obj', 'name'));
174 db_drop_index('ctools_object_cache', 'sid_obj_name');
ca3a09cb 175}
aeed3fef
SB
176
177/**
178 * Removed update.
179 */
180function ctools_update_6005() {
181 return array();
182}
183
184/**
185 * ctools_custom_content table was originally here, but is now moved to
186 * its own module.
187 */
188function ctools_update_6007() {
189 $ret = array();
190 if (db_table_exists('ctools_custom_content')) {
191 // Enable the module to make everything as seamless as possible.
192 drupal_install_modules(array('ctools_custom_content'));
193 }
194
195 return $ret;
196}
197
198