123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493 |
- <?php
- function block_schema() {
- $schema['block'] = array(
- 'description' => 'Stores block settings, such as region and visibility settings.',
- 'fields' => array(
- 'bid' => array(
- 'type' => 'serial',
- 'not null' => TRUE,
- 'description' => 'Primary Key: Unique block ID.',
- ),
- 'module' => array(
- 'type' => 'varchar',
- 'length' => 64,
- 'not null' => TRUE,
- 'default' => '',
- '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',
- 'description' => 'Unique ID for block within a module.',
- ),
- 'theme' => array(
- 'type' => 'varchar',
- 'length' => 64,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'The theme under which the block settings apply.',
- ),
- 'status' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'size' => 'tiny',
- 'description' => 'Block enabled status. (1 = enabled, 0 = disabled)',
- ),
- 'weight' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => 'Block weight within region.',
- ),
- 'region' => array(
- 'type' => 'varchar',
- 'length' => 64,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Theme region within which the block is set.',
- ),
- 'custom' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'size' => 'tiny',
- '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',
- '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,
- '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' => 255,
- '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.)',
- 'translatable' => TRUE,
- ),
- 'cache' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 1,
- 'size' => 'tiny',
- 'description' => 'Binary flag to indicate block cache mode. (-2: Custom cache, -1: Do not cache, 1: Cache per role, 2: Cache per user, 4: Cache per page, 8: Block cache global) See DRUPAL_CACHE_* constants in ../includes/common.inc for more detailed information.',
- ),
- ),
- 'primary key' => array('bid'),
- 'unique keys' => array(
- 'tmd' => array('theme', 'module', 'delta'),
- ),
- 'indexes' => array(
- 'list' => array('theme', 'status', 'region', 'weight', 'module'),
- ),
- );
- $schema['block_role'] = array(
- 'description' => 'Sets up access permissions for blocks based on user roles',
- '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.",
- ),
- 'rid' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'description' => "The user's role ID from {users_roles}.rid.",
- ),
- ),
- 'primary key' => array('module', 'delta', 'rid'),
- 'indexes' => array(
- 'rid' => array('rid'),
- ),
- );
- $schema['block_custom'] = array(
- 'description' => 'Stores contents of custom-made blocks.',
- 'fields' => array(
- 'bid' => array(
- 'type' => 'serial',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'description' => "The block's {block}.bid.",
- ),
- 'body' => array(
- 'type' => 'text',
- 'not null' => FALSE,
- 'size' => 'big',
- 'description' => 'Block contents.',
- 'translatable' => TRUE,
- ),
- 'info' => array(
- 'type' => 'varchar',
- 'length' => 128,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Block description.',
- ),
- 'format' => array(
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => FALSE,
- 'description' => 'The {filter_format}.format of the block body.',
- ),
- ),
- 'unique keys' => array(
- 'info' => array('info'),
- ),
- 'primary key' => array('bid'),
- );
- $schema['cache_block'] = drupal_get_schema_unprocessed('system', 'cache');
- $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;
- }
- function block_install() {
-
-
-
- db_update('system')
- ->fields(array('weight' => -5))
- ->condition('name', 'block')
- ->execute();
- }
- function block_update_dependencies() {
-
-
-
- $dependencies['block'][7005] = array(
- 'filter' => 7000,
- );
- return $dependencies;
- }
- function block_update_7000() {
- db_update('system')
- ->fields(array('weight' => '-5'))
- ->condition('name', 'block')
- ->execute();
- }
- function block_update_7002() {
- db_drop_index('blocks', 'list');
- db_rename_table('blocks', 'block');
- db_rename_table('blocks_roles', 'block_role');
- db_rename_table('boxes', 'block_custom');
- }
- function block_update_7003() {
- db_change_field('block', 'weight', 'weight', array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => 'Block weight within region.',
- ), array(
- 'indexes' => array(
- 'list' => array('theme', 'status', 'region', 'weight', 'module'),
- ),
- ));
- }
- function block_update_7004() {
-
- $themes_with_blocks = array();
- $result = db_query("SELECT s.name FROM {system} s INNER JOIN {block} b ON s.name = b.theme WHERE s.type = 'theme' GROUP by s.name");
- $insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
- foreach ($result as $theme) {
- $themes_with_blocks[] = $theme->name;
-
- $insert->values(array(
- 'module' => 'system',
- 'delta' => 'help',
- 'theme' => $theme->name,
- 'status' => 1,
- 'weight' => 0,
- 'region' => 'help',
- 'pages' => '',
- 'cache' => DRUPAL_CACHE_PER_ROLE,
- ));
-
- $insert->values(array(
- 'module' => 'system',
- 'delta' => 'main',
- 'theme' => $theme->name,
- 'status' => 1,
- 'weight' => 0,
- 'region' => 'content',
- 'pages' => '',
- 'cache' => DRUPAL_NO_CACHE,
- ));
- }
- $insert->execute();
-
- db_update('block')
- ->fields(array('region' => 'sidebar_first'))
- ->condition('region', 'left')
- ->execute();
- db_update('block')
- ->fields(array('region' => 'sidebar_second'))
- ->condition('region', 'right')
- ->execute();
-
- $default_format = variable_get('filter_default_format', 1);
- if ($contact_help = variable_get('contact_form_information', '')) {
- $bid = db_insert('block_custom')
- ->fields(array(
- 'body' => $contact_help,
- 'info' => 'Contact page help',
- 'format' => $default_format,
- ))
- ->execute();
- $insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'visibility', 'pages', 'cache'));
- foreach ($themes_with_blocks as $theme) {
-
- $insert->values(array(
- 'module' => 'block',
- 'delta' => $bid,
- 'theme' => $theme,
- 'status' => 1,
- 'weight' => 5,
- 'region' => 'help',
- 'visibility' => BLOCK_VISIBILITY_LISTED,
- 'pages' => 'contact',
- 'cache' => DRUPAL_NO_CACHE,
- ));
- }
- drupal_set_message('The contact form information setting was migrated to <a href="' . url('admin/structure/block/manage/block/' . $bid . '/configure') . '">a custom block</a> and set up to only show on the site-wide contact page. The block was set to use the default text format, which might differ from the HTML based format used before. Check the block and ensure that the output is right.');
- }
- $insert->execute();
-
- if ($user_help = variable_get('user_registration_help', '')) {
- $bid = db_insert('block_custom')->fields(array('body' => $user_help, 'info' => 'User registration guidelines', 'format' => $default_format))->execute();
- $insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'visibility', 'pages', 'cache'));
- foreach ($themes_with_blocks as $theme) {
-
- $insert->values(array(
- 'module' => 'block',
- 'delta' => $bid,
- 'theme' => $theme,
- 'status' => 1,
- 'weight' => 5,
- 'region' => 'help',
- 'visibility' => BLOCK_VISIBILITY_LISTED,
- 'pages' => 'user/register',
- 'cache' => DRUPAL_NO_CACHE,
- ));
- }
- drupal_set_message('The user registration guidelines were migrated to <a href="' . url('admin/structure/block/manage/block/' . $bid . '/configure') . '">a custom block</a> and set up to only show on the user registration page. The block was set to use the default text format, which might differ from the HTML based format used before. Check the block and ensure that the output is right.');
- $insert->execute();
- }
-
- if ($mission = variable_get('site_mission')) {
- $bid = db_insert('block_custom')->fields(array('body' => $mission, 'info' => 'Site mission', 'format' => $default_format))->execute();
- $insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'visibility', 'pages', 'cache'));
- foreach ($themes_with_blocks as $theme) {
-
- $insert->values(array(
- 'module' => 'block',
- 'delta' => $bid,
- 'theme' => $theme,
- 'status' => 1,
- 'weight' => 0,
- 'region' => 'highlighted',
- 'visibility' => BLOCK_VISIBILITY_LISTED,
- 'pages' => '<front>',
- 'cache' => DRUPAL_NO_CACHE,
- ));
- }
- drupal_set_message('The site mission was migrated to <a href="' . url('admin/structure/block/manage/block/' . $bid . '/configure') . '">a custom block</a> and set up to only show on the front page in the highlighted content region. The block was set to use the default text format, which might differ from the HTML based format used before. Check the block and ensure that the output is right. If your theme does not have a highlighted content region, you might need to <a href="' . url('admin/structure/block') . '">relocate the block</a>.');
- $insert->execute();
-
- variable_set('feed_description', $mission);
- }
-
- if ($footer_message = variable_get('site_footer', '')) {
- $bid = db_insert('block_custom')->fields(array('body' => $footer_message, 'info' => 'Footer message', 'format' => $default_format))->execute();
- $insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
- foreach ($themes_with_blocks as $theme) {
-
-
-
- $insert->values(array(
- 'module' => 'block',
- 'delta' => $bid,
- 'theme' => $theme,
- 'status' => 1,
- 'weight' => -10,
- 'region' => 'footer',
- 'pages' => '',
- 'cache' => DRUPAL_NO_CACHE,
- ));
- }
- drupal_set_message('The footer message was migrated to <a href="' . url('admin/structure/block/manage/block/' . $bid . '/configure') . '">a custom block</a> and set up to appear in the footer. The block was set to use the default text format, which might differ from the HTML based format used before. Check the block and ensure that the output is right. If your theme does not have a footer region, you might need to <a href="' . url('admin/structure/block') . '">relocate the block</a>.');
- $insert->execute();
- }
-
-
- variable_del('contact_form_information');
- variable_del('user_registration_help');
- variable_del('site_mission');
- variable_del('site_footer');
-
- system_rebuild_theme_data();
- }
- function block_update_7005() {
-
-
- db_change_field('block_custom', 'format', 'format', array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => FALSE,
- 'description' => 'The {filter_format}.format of the block body.',
- ));
- db_update('block_custom')
- ->fields(array('format' => NULL))
- ->condition('body', '')
- ->condition('format', 0)
- ->execute();
- $existing_formats = db_query("SELECT format FROM {filter_format}")->fetchCol();
- $default_format = variable_get('filter_default_format', 1);
- db_update('block_custom')
- ->fields(array('format' => $default_format))
- ->isNotNull('format')
- ->condition('format', $existing_formats, 'NOT IN')
- ->execute();
- }
- function block_update_7006() {
- $schema = system_schema_cache_7054();
- db_drop_table('cache_block');
- db_create_table('cache_block', $schema);
- }
- function block_update_7007() {
- db_change_field('block_custom', 'format', 'format', array(
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => FALSE,
- 'description' => 'The {filter_format}.format of the block body.',
- ));
- }
- function block_update_7008() {
- db_drop_field('block', 'throttle');
- }
- function block_update_7009() {
- db_change_field('block', 'title', 'title',
- array(
- 'type' => 'varchar',
- 'length' => 255,
- '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.)',
- 'translatable' => TRUE,
- )
- );
- }
|