| 1 |
<?php
|
| 2 |
// $Id: ddblock.install,v 1.2 2008/08/31 04:37:11 ppblaauw Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Installation file to implement the dynamic display block schema
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implementation of hook_schema().
|
| 11 |
*/
|
| 12 |
function ddblock_schema() {
|
| 13 |
$schema['ddblock_block'] = array(
|
| 14 |
'description' => t('The base tables for ddblocks.'),
|
| 15 |
'fields' => array(
|
| 16 |
'delta' => array(
|
| 17 |
'description' => t('Number of the block.'),
|
| 18 |
'type' => 'serial',
|
| 19 |
'unsigned' => TRUE,
|
| 20 |
'not null' => TRUE,
|
| 21 |
),
|
| 22 |
'title' => array(
|
| 23 |
'description' => t('Title of the block.'),
|
| 24 |
'type' => 'varchar',
|
| 25 |
'length' => 64,
|
| 26 |
'not null' => TRUE,
|
| 27 |
'default' => '',
|
| 28 |
),
|
| 29 |
'module' => array(
|
| 30 |
'description' => t('The name of the module that provided the original block.'),
|
| 31 |
'type' => 'varchar',
|
| 32 |
'length' => 64,
|
| 33 |
'not null' => TRUE,
|
| 34 |
'default' => '',
|
| 35 |
),
|
| 36 |
'delta_original' => array(
|
| 37 |
'description' => t('The delta of the original block.'),
|
| 38 |
'type' => 'varchar',
|
| 39 |
'length' => 32,
|
| 40 |
'not null' => TRUE,
|
| 41 |
'default' => '0',
|
| 42 |
),
|
| 43 |
'enabled' => array(
|
| 44 |
'description' => t('Support for dynamic display block enabled.'),
|
| 45 |
'type' => 'int',
|
| 46 |
'size' => 'tiny',
|
| 47 |
'unsigned' => TRUE,
|
| 48 |
'not null' => TRUE,
|
| 49 |
'default' => 0,
|
| 50 |
),
|
| 51 |
),
|
| 52 |
'primary key' => array('delta'),
|
| 53 |
);
|
| 54 |
|
| 55 |
return $schema;
|
| 56 |
}
|
| 57 |
|
| 58 |
/**
|
| 59 |
* Implementation of hook_install().
|
| 60 |
*/
|
| 61 |
function ddblock_install() {
|
| 62 |
if (drupal_install_schema('ddblock')) {
|
| 63 |
drupal_set_message(t('Dynamic display block module installed successfully. Module settings are available under !link',
|
| 64 |
array( '!link' => l('Administer > Site configuration > ddblock ', 'admin/settings/ddblock/settings' ))));
|
| 65 |
}
|
| 66 |
else {
|
| 67 |
drupal_set_message(t('The installation of the dynamic display block module was unsuccessful.'), 'error');
|
| 68 |
}
|
| 69 |
}
|
| 70 |
|
| 71 |
/**
|
| 72 |
* Implementation of hook_uninstall().
|
| 73 |
*/
|
| 74 |
function ddblock_uninstall() {
|
| 75 |
//Drop tables
|
| 76 |
drupal_uninstall_schema('ddblock');
|
| 77 |
// Remove variables
|
| 78 |
db_query("DELETE FROM {variable} WHERE name LIKE 'ddblock_%%'");
|
| 79 |
cache_clear_all('variables', 'cache');
|
| 80 |
drupal_set_message(t("Dynamic display block module uninstalled successfully."));
|
| 81 |
}
|
| 82 |
|
| 83 |
/**
|
| 84 |
* Set BLOCK_NO_CACHE for all declared ddblocks
|
| 85 |
*/
|
| 86 |
function ddblock_update_6001() {
|
| 87 |
$ret = array();
|
| 88 |
|
| 89 |
// set BLOCK_NO_CACHE
|
| 90 |
db_query('UPDATE {blocks} SET cache=-1 WHERE module=\'ddblock\'');
|
| 91 |
|
| 92 |
return $ret;
|
| 93 |
}
|