shoutbox_tags.install in Shoutbox 7.2
Same filename and directory in other branches
Install, update and uninstall functions for the shoutbox_tags module.
File
shoutbox_tags/shoutbox_tags.installView source
<?php
/**
* @file
* Install, update and uninstall functions for the shoutbox_tags module.
*/
/**
* Implements hook_schema().
*/
function shoutbox_tags_schema() {
$schema['shoutbox_tags'] = array(
'description' => 'Link shouts to their tags',
'fields' => array(
'shout_id' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'The shout id',
),
'tag' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'description' => 'The shout tag',
),
),
'primary key' => array(
'shout_id',
),
);
return $schema;
}
/**
* Implements hook_install().
*/
function shoutbox_tags_install() {
// Load the module.
module_load_include('module', 'shoutbox_tags');
// Index all available shouts.
$result = db_query("SELECT * FROM {shoutbox}");
foreach ($result as $shout) {
// Get the tags.
$tags = shoutbox_tags_extract($shout);
// Save the tags.
foreach ($tags as $tag) {
$id = db_insert('shoutbox_tags')
->fields(array(
'shout_id' => $shout->shout_id,
'tag' => $tag,
))
->execute();
}
}
}
/**
* Implements hook_uninstall().
*/
function shoutbox_tags_uninstall() {
}
/**
* Update for Drupal 7.0.
*
* Drop the primary key so that a shout can have
* multiple tags.
*/
function shoutbox_tags_update_7000() {
db_drop_primary_key('shoutbox_tags');
}
Functions
Name | Description |
---|---|
shoutbox_tags_install | Implements hook_install(). |
shoutbox_tags_schema | Implements hook_schema(). |
shoutbox_tags_uninstall | Implements hook_uninstall(). |
shoutbox_tags_update_7000 | Update for Drupal 7.0. |