Newer
Older
<?php
// $Id$
/**
* @file
Angie Byron
committed
* Install, update and uninstall functions for the block module.
Dries Buytaert
committed
* Implements hook_schema().
*/
function block_schema() {
Dries Buytaert
committed
$schema['block'] = array(
Angie Byron
committed
'description' => 'Stores block settings, such as region and visibility settings.',
'fields' => array(
'bid' => array(
'type' => 'serial',
'not null' => TRUE,
Angie Byron
committed
'description' => 'Primary Key: Unique block ID.',
),
'module' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
Angie Byron
committed
'description' => "The module from which the block originates; for example, 'user' for the Who's Online block, and 'block' for any custom blocks.",
),
'delta' => array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '0',
Angie Byron
committed
'description' => 'Unique ID for block within a module.',
),
'theme' => array(
'type' => 'varchar',
Dries Buytaert
committed
'length' => 64,
'not null' => TRUE,
'default' => '',
Angie Byron
committed
'description' => 'The theme under which the block settings apply.',
),
'status' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
Angie Byron
committed
'description' => 'Block enabled status. (1 = enabled, 0 = disabled)',
),
'weight' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
Angie Byron
committed
'description' => 'Block weight within region.',
),
'region' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
Dries Buytaert
committed
'default' => '',
Angie Byron
committed
'description' => 'Theme region within which the block is set.',
),
'custom' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
Angie Byron
committed
'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)',
),
'visibility' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
Angie Byron
committed
'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)',
),
'pages' => array(
'type' => 'text',
'not null' => TRUE,
Angie Byron
committed
'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.',
),
'title' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
'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.)',
Dries Buytaert
committed
'translatable' => TRUE,
),
'cache' => array(
'type' => 'int',
'not null' => TRUE,
Gábor Hojtsy
committed
'default' => 1,
'size' => 'tiny',
Angie Byron
committed
'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.',
),
'primary key' => array('bid'),
Dries Buytaert
committed
'unique keys' => array(
'tmd' => array('theme', 'module', 'delta'),
),
'indexes' => array(
'list' => array('theme', 'status', 'region', 'weight', 'module'),
),
Dries Buytaert
committed
$schema['block_role'] = array(
Angie Byron
committed
'description' => 'Sets up access permissions for blocks based on user roles',
'fields' => array(
'module' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
Angie Byron
committed
'description' => "The block's origin module, from {block}.module.",
'delta' => array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
Angie Byron
committed
'description' => "The block's unique delta within module, from {block}.delta.",
),
'rid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
Angie Byron
committed
'description' => "The user's role ID from {users_roles}.rid.",
'primary key' => array('module', 'delta', 'rid'),
Dries Buytaert
committed
'indexes' => array(
'rid' => array('rid'),
),
Dries Buytaert
committed
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
$schema['block_node_type'] = array(
'description' => 'Sets up display criteria for blocks based on content types',
'fields' => array(
'module' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'description' => "The block's origin module, from {block}.module.",
),
'delta' => array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'description' => "The block's unique delta within module, from {block}.delta.",
),
'type' => array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'description' => "The machine-readable name of this type from {node_type}.type.",
),
),
'primary key' => array('module', 'delta', 'type'),
'indexes' => array(
'type' => array('type'),
),
);
$schema['block_custom'] = array(
Angie Byron
committed
'description' => 'Stores contents of custom-made blocks.',
'fields' => array(
'bid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
Angie Byron
committed
'description' => "The block's {block}.bid.",
),
'body' => array(
'type' => 'text',
'not null' => FALSE,
'size' => 'big',
Angie Byron
committed
'description' => 'Block contents.',
Dries Buytaert
committed
'translatable' => TRUE,
),
'info' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
Angie Byron
committed
'description' => 'Block description.',
),
'format' => array(
'type' => 'int',
'size' => 'small',
'not null' => TRUE,
'default' => 0,
Dries Buytaert
committed
'description' => "Block body's {filter_format}.format; for example, 1 = Filtered HTML.",
'unique keys' => array(
'info' => array('info'),
),
'primary key' => array('bid'),
);
$schema['cache_block'] = drupal_get_schema_unprocessed('system', 'cache');
Dries Buytaert
committed
$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.';
return $schema;
Dries Buytaert
committed
}
Dries Buytaert
committed
* Implements hook_install().
*/
function block_install() {
// Block should go first so that other modules can alter its output
Dries Buytaert
committed
// during hook_page_alter(). Almost everything on the page is a block,
// so before block module runs, there will not be much to alter.
db_update('system')
Dries Buytaert
committed
->fields(array('weight' => -5))
Dries Buytaert
committed
->condition('name', 'block')
->execute();
Dries Buytaert
committed
/**
* Set system.weight to a low value for block module.
*
* Block should go first so that other modules can alter its output
Dries Buytaert
committed
* during hook_page_alter(). Almost everything on the page is a block,
* so before block module runs, there will not be much to alter.
*/
function block_update_7000() {
Dries Buytaert
committed
db_update('system')
->fields(array('weight', '-5'))
->condition('name', 'block')
->execute();
Dries Buytaert
committed
}
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
/**
* Add the block_node_type table.
*/
function block_update_7001() {
$schema['block_node_type'] = array(
'description' => 'Sets up display criteria for blocks based on content types',
'fields' => array(
'module' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'description' => "The block's origin module, from {block}.module.",
),
'delta' => array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'description' => "The block's unique delta within module, from {block}.delta.",
),
'type' => array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'description' => "The machine-readable name of this type from {node_type}.type.",
),
),
'primary key' => array('module', 'delta', 'type'),
'indexes' => array(
'type' => array('type'),
),
);
Dries Buytaert
committed
db_create_table('block_node_type', $schema['block_node_type']);