block.install 5.72 KB
Newer Older
1 2 3 4 5 6 7 8
<?php
// $Id$

/**
 * Implementation of hook_schema().
 */
function block_schema() {
  $schema['blocks'] = array(
9
    'description' => t('Stores block settings, such as region and visibility settings.'),
10
    'fields' => array(
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
      'bid' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => t('Primary Key: Unique block ID.'),
      ),
      'module' => array(
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
        'description' => t("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',
        'description' => t('Unique ID for block within a module.'),
      ),
      'theme' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => t('The theme under which the block settings apply.'),
      ),
      'status' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => t('Block enabled status. (1 = enabled, 0 = disabled)'),
      ),
      'weight' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => t('Block weight within region.'),
      ),
      'region' => array(
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
55
        'default' => '',
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
        'description' => t('Theme region within which the block is set.'),
      ),
      'custom' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => t('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)'),
      ),
      'throttle' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => t('Flag to indicate whether or not to remove block when website traffic is high. (1 = throttle, 0 = do not throttle)'),
      ),
      'visibility' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => t('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,
82
        'description' => t('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.'),
83 84 85 86 87 88 89 90 91 92 93
      ),
      'title' => array(
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
        'description' => t('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.)'),
      ),
      'cache' => array(
        'type' => 'int',
        'not null' => TRUE,
94
        'default' => 1,
95 96 97
        'size' => 'tiny',
        'description' => t('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.'),
      ),
98 99 100 101 102
    ),
    'primary key' => array('bid'),
  );

  $schema['blocks_roles'] = array(
103
    'description' => t('Sets up access permissions for blocks based on user roles'),
104
    'fields' => array(
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
      'module' => array(
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'description' => t("The block's origin module, from {blocks}.module."),
      ),
      'delta'  => array(
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'description' => t("The block's unique delta within module, from {blocks}.delta."),
      ),
      'rid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
121
        'description' => t("The user's role ID from {users_roles}.rid."),
122
      ),
123 124 125 126 127 128 129 130 131
    ),
    'primary key' => array(
      'module',
      'delta',
      'rid'
    ),
  );

  $schema['boxes'] = array(
132
    'description' => t('Stores contents of custom-made blocks.'),
133
    'fields' => array(
134 135
      'bid' => array(
        'type' => 'serial',
136
  'unsigned' => TRUE,
137
        'not null' => TRUE,
138
        'description' => t("The block's {blocks}.bid."),
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
      ),
      'body' => array(
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'big',
        'description' => t('Block contents.'),
      ),
      'info' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => t('Block description.'),
      ),
      'format' => array(
        'type' => 'int',
        'size' => 'small',
        'not null' => TRUE,
        'default' => 0,
        'description' => t("Block body's {filter_formats}.format; for example, 1 = Filtered HTML."),
      )
160 161 162 163 164 165
    ),
    'unique keys' => array('info' => array('info')),
    'primary key' => array('bid'),
  );

  $schema['cache_block'] = drupal_get_schema_unprocessed('system', 'cache');
166
  $schema['cache_block']['description'] = t('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.');
167 168 169 170

  return $schema;
}