View source
<?php
function borealis_sb_schema() {
$schema['borealis_sb'] = array(
'description' => 'Stores Semantic settings for blocks.',
'fields' => array(
'uid' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
'description' => "Generated UID for module_delta combo.",
),
'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.',
),
'semantics' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
'description' => 'The semantic wrapper to apply.',
),
),
'primary key' => array(
'uid',
),
'export' => array(
'key' => 'uid',
'identifier' => 'semantic_wrapper',
'default hook' => 'default_semantic_wrapper',
'api' => array(
'owner' => 'borealis_sb',
'api' => 'borealis_sb_default',
'minimum_version' => 1,
'current_version' => 1,
),
),
);
return $schema;
}
function borealis_sb_install() {
drupal_install_schema('boralis_sb');
borealis_sb_update_7100();
borealis_sb_update_7101();
borealis_sb_update_7102();
}
function borealis_sb_uninstall() {
drupal_uninstall_schema('borealis_sb');
}
function borealis_sb_update_7100() {
db_update('system')
->fields(array(
'weight' => 99999,
))
->condition('name', 'borealis_sb')
->execute();
}
function borealis_sb_update_7101() {
db_drop_field('borealis_sb', 'bid');
}
function borealis_sb_update_7102() {
if (!db_field_exists('borealis_sb', 'uid')) {
$schema = array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
'description' => "Generated UID for module_delta combo",
);
db_add_field('borealis_sb', 'uid', $schema);
}
$block_query = db_select('borealis_sb', 'b')
->fields('b');
$block_result = $block_query
->execute();
foreach ($block_result as $block) {
$uid = $block->module . '_' . $block->delta;
db_update('borealis_sb')
->fields(array(
'uid' => $uid,
))
->condition('module', $block->module)
->condition('delta', $block->delta)
->execute();
}
}