shoutbox_tags.install in Shoutbox 6.2
File
shoutbox_tags/shoutbox_tags.install
View source
<?php
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;
}
function shoutbox_tags_install() {
drupal_install_schema('shoutbox_tags');
module_load_include('module', 'shoutbox_tags');
$shouts = db_query("SELECT * FROM {shoutbox}");
while ($shout = db_fetch_object($shouts)) {
$tags = shoutbox_tags_extract($shout);
foreach ($tags as $tag) {
db_query("INSERT INTO {shoutbox_tags} (shout_id, tag) VALUES (%d, '%s')", $shout->shout_id, $tag);
}
}
}
function shoutbox_tags_uninstall() {
drupal_uninstall_schema('shoutbox_tags');
}