/[drupal]/drupal/modules/block/block.install
ViewVC logotype

Contents of /drupal/modules/block/block.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.34 - (show annotations) (download) (as text)
Fri Oct 16 19:06:22 2009 UTC (6 weeks ago) by dries
Branch: MAIN
CVS Tags: DRUPAL-7-0-UNSTABLE-10, HEAD
Changes since 1.33: +3 -1 lines
File MIME type: text/x-php
- Patch #593746 by #593746 by sun, andypost: prepare Drupal core for dynamic data translation.
1 <?php
2 // $Id: block.install,v 1.33 2009/09/29 15:13:54 dries Exp $
3
4 /**
5 * @file
6 * Install, update and uninstall functions for the block module.
7 */
8
9 /**
10 * Implement hook_schema().
11 */
12 function block_schema() {
13 $schema['block'] = array(
14 'description' => 'Stores block settings, such as region and visibility settings.',
15 'fields' => array(
16 'bid' => array(
17 'type' => 'serial',
18 'not null' => TRUE,
19 'description' => 'Primary Key: Unique block ID.',
20 ),
21 'module' => array(
22 'type' => 'varchar',
23 'length' => 64,
24 'not null' => TRUE,
25 'default' => '',
26 'description' => "The module from which the block originates; for example, 'user' for the Who's Online block, and 'block' for any custom blocks.",
27 ),
28 'delta' => array(
29 'type' => 'varchar',
30 'length' => 32,
31 'not null' => TRUE,
32 'default' => '0',
33 'description' => 'Unique ID for block within a module.',
34 ),
35 'theme' => array(
36 'type' => 'varchar',
37 'length' => 64,
38 'not null' => TRUE,
39 'default' => '',
40 'description' => 'The theme under which the block settings apply.',
41 ),
42 'status' => array(
43 'type' => 'int',
44 'not null' => TRUE,
45 'default' => 0,
46 'size' => 'tiny',
47 'description' => 'Block enabled status. (1 = enabled, 0 = disabled)',
48 ),
49 'weight' => array(
50 'type' => 'int',
51 'not null' => TRUE,
52 'default' => 0,
53 'size' => 'tiny',
54 'description' => 'Block weight within region.',
55 ),
56 'region' => array(
57 'type' => 'varchar',
58 'length' => 64,
59 'not null' => TRUE,
60 'default' => '',
61 'description' => 'Theme region within which the block is set.',
62 ),
63 'custom' => array(
64 'type' => 'int',
65 'not null' => TRUE,
66 'default' => 0,
67 'size' => 'tiny',
68 'description' => 'Flag to indicate how users may control visibility of the block. (0 = Users cannot control, 1 = On by default, but can be hidden, 2 = Hidden by default, but can be shown)',
69 ),
70 'visibility' => array(
71 'type' => 'int',
72 'not null' => TRUE,
73 'default' => 0,
74 'size' => 'tiny',
75 'description' => 'Flag to indicate how to show blocks on pages. (0 = Show on all pages except listed pages, 1 = Show only on listed pages, 2 = Use custom PHP code to determine visibility)',
76 ),
77 'pages' => array(
78 'type' => 'text',
79 'not null' => TRUE,
80 'description' => 'Contents of the "Pages" block; contains either a list of paths on which to include/exclude the block or PHP code, depending on "visibility" setting.',
81 ),
82 'title' => array(
83 'type' => 'varchar',
84 'length' => 64,
85 'not null' => TRUE,
86 'default' => '',
87 'description' => 'Custom title for the block. (Empty string will use block default title, <none> will remove the title, text will cause block to use specified title.)',
88 'translatable' => TRUE,
89 ),
90 'cache' => array(
91 'type' => 'int',
92 'not null' => TRUE,
93 'default' => 1,
94 'size' => 'tiny',
95 'description' => 'Binary flag to indicate block cache mode. (-1: Do not cache, 1: Cache per role, 2: Cache per user, 4: Cache per page, 8: Block cache global) See BLOCK_CACHE_* constants in block.module for more detailed information.',
96 ),
97 ),
98 'primary key' => array('bid'),
99 'unique keys' => array(
100 'tmd' => array('theme', 'module', 'delta'),
101 ),
102 'indexes' => array(
103 'list' => array('theme', 'status', 'region', 'weight', 'module'),
104 ),
105 );
106
107 $schema['block_role'] = array(
108 'description' => 'Sets up access permissions for blocks based on user roles',
109 'fields' => array(
110 'module' => array(
111 'type' => 'varchar',
112 'length' => 64,
113 'not null' => TRUE,
114 'description' => "The block's origin module, from {block}.module.",
115 ),
116 'delta' => array(
117 'type' => 'varchar',
118 'length' => 32,
119 'not null' => TRUE,
120 'description' => "The block's unique delta within module, from {block}.delta.",
121 ),
122 'rid' => array(
123 'type' => 'int',
124 'unsigned' => TRUE,
125 'not null' => TRUE,
126 'description' => "The user's role ID from {users_roles}.rid.",
127 ),
128 ),
129 'primary key' => array('module', 'delta', 'rid'),
130 'indexes' => array(
131 'rid' => array('rid'),
132 ),
133 );
134
135 $schema['block_node_type'] = array(
136 'description' => 'Sets up display criteria for blocks based on content types',
137 'fields' => array(
138 'module' => array(
139 'type' => 'varchar',
140 'length' => 64,
141 'not null' => TRUE,
142 'description' => "The block's origin module, from {block}.module.",
143 ),
144 'delta' => array(
145 'type' => 'varchar',
146 'length' => 32,
147 'not null' => TRUE,
148 'description' => "The block's unique delta within module, from {block}.delta.",
149 ),
150 'type' => array(
151 'type' => 'varchar',
152 'length' => 32,
153 'not null' => TRUE,
154 'description' => "The machine-readable name of this type from {node_type}.type.",
155 ),
156 ),
157 'primary key' => array('module', 'delta', 'type'),
158 'indexes' => array(
159 'type' => array('type'),
160 ),
161 );
162
163 $schema['block_custom'] = array(
164 'description' => 'Stores contents of custom-made blocks.',
165 'fields' => array(
166 'bid' => array(
167 'type' => 'serial',
168 'unsigned' => TRUE,
169 'not null' => TRUE,
170 'description' => "The block's {block}.bid.",
171 ),
172 'body' => array(
173 'type' => 'text',
174 'not null' => FALSE,
175 'size' => 'big',
176 'description' => 'Block contents.',
177 'translatable' => TRUE,
178 ),
179 'info' => array(
180 'type' => 'varchar',
181 'length' => 128,
182 'not null' => TRUE,
183 'default' => '',
184 'description' => 'Block description.',
185 ),
186 'format' => array(
187 'type' => 'int',
188 'size' => 'small',
189 'not null' => TRUE,
190 'default' => 0,
191 'description' => "Block body's {filter_format}.format; for example, 1 = Filtered HTML.",
192 )
193 ),
194 'unique keys' => array(
195 'info' => array('info'),
196 ),
197 'primary key' => array('bid'),
198 );
199
200 $schema['cache_block'] = drupal_get_schema_unprocessed('system', 'cache');
201 $schema['cache_block']['description'] = 'Cache table for the Block module to store already built blocks, identified by module, delta, and various contexts which may change the block, such as theme, locale, and caching mode defined for the block.';
202
203 return $schema;
204 }
205
206 /**
207 * Implement hook_install().
208 */
209 function block_install() {
210
211 // Block should go first so that other modules can alter its output
212 // during hook_page_alter(). Almost everything on the page is a block,
213 // so before block module runs, there will not be much to alter.
214 db_update('system')
215 ->fields(array('weight' => -5))
216 ->condition('name', 'block')
217 ->execute();
218 }
219
220 /**
221 * Set system.weight to a low value for block module.
222 *
223 * Block should go first so that other modules can alter its output
224 * during hook_page_alter(). Almost everything on the page is a block,
225 * so before block module runs, there will not be much to alter.
226 */
227 function block_update_7000() {
228 db_update('system')
229 ->fields(array('weight', '-5'))
230 ->condition('name', 'block')
231 ->execute();
232 }
233
234
235 /**
236 * Add the block_node_type table.
237 */
238 function block_update_7001() {
239 $schema['block_node_type'] = array(
240 'description' => 'Sets up display criteria for blocks based on content types',
241 'fields' => array(
242 'module' => array(
243 'type' => 'varchar',
244 'length' => 64,
245 'not null' => TRUE,
246 'description' => "The block's origin module, from {block}.module.",
247 ),
248 'delta' => array(
249 'type' => 'varchar',
250 'length' => 32,
251 'not null' => TRUE,
252 'description' => "The block's unique delta within module, from {block}.delta.",
253 ),
254 'type' => array(
255 'type' => 'varchar',
256 'length' => 32,
257 'not null' => TRUE,
258 'description' => "The machine-readable name of this type from {node_type}.type.",
259 ),
260 ),
261 'primary key' => array('module', 'delta', 'type'),
262 'indexes' => array(
263 'type' => array('type'),
264 ),
265 );
266
267 db_create_table('block_node_type', $schema['block_node_type']);
268 }

  ViewVC Help
Powered by ViewVC 1.1.2