twitter_block.install in Twitter Block 6
Same filename and directory in other branches
Install, update and uninstall functions for the twitter_block module.
File
twitter_block.installView source
<?php
/**
* @file
* Install, update and uninstall functions for the twitter_block module.
*/
/**
* Implementation of hook_schema().
*/
function twitter_block_schema() {
$schema['twitter_block'] = array(
'description' => 'The table for storing twitter blocks.',
'fields' => array(
'delta' => array(
'description' => 'The machine identifier for a twitter block.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'search_type' => array(
'description' => 'The search type for this block. ie. mention, reply',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => 'search',
),
'include_rts' => array(
'description' => 'Whether retweets should be included in the search results. (1 = enabled, 0 = disabled)',
'type' => 'int',
'not null' => TRUE,
'default' => 1,
'size' => 'tiny',
),
'search_string' => array(
'description' => 'The search string.',
'type' => 'varchar',
'length' => 140,
'not null' => TRUE,
'default' => '',
),
'default_title' => array(
'description' => 'The title of this block in plain text.',
'type' => 'varchar',
'length' => 140,
'not null' => TRUE,
'default' => '',
),
'results_per_page' => array(
'description' => '"Returns per page" from the Twitter Search API.',
'type' => 'varchar',
'length' => 8,
),
'lang' => array(
'description' => 'Optional Twitter language filter.',
'type' => 'varchar',
'length' => 2,
),
),
'unique keys' => array(
'delta' => array(
'delta',
),
),
'foreign keys' => array(
'block' => array(
'table' => 'block',
'columns' => array(
'bid' => 'bid',
),
),
),
'primary key' => array(
'delta',
),
);
return $schema;
}
/**
* Implementation of hook_install().
*/
function twitter_block_install() {
drupal_install_schema('twitter_block');
$result = db_query("INSERT INTO {twitter_block} (delta, search_type, search_string, default_title) VALUES ('default', 'searchHashtag', 'Drupal', 'Discussions on Twitter')");
}
/**
* Implementation of hook_uninstall().
*/
function twitter_block_uninstall() {
drupal_uninstall_schema('twitter_block');
variable_del('twitter_block_default_results_per_page');
}
Functions
Name | Description |
---|---|
twitter_block_install | Implementation of hook_install(). |
twitter_block_schema | Implementation of hook_schema(). |
twitter_block_uninstall | Implementation of hook_uninstall(). |