taxonomy_redirect.install in Taxonomy Redirect 6
Same filename and directory in other branches
Taxonomy Redirect installation and update information
File
taxonomy_redirect.installView source
<?php
/**
* @file
* Taxonomy Redirect installation and update information
*/
/**
* Implementation of hook_schema().
*/
function taxonomy_redirect_schema() {
$schema['taxonomy_redirect'] = array(
'description' => t('The base table for taxonomy redirect.'),
'fields' => array(
'vid' => array(
'description' => t('The taxonomy vocabulary ID'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'module' => array(
'description' => t('The module that owns the vocabulary'),
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'path' => array(
'description' => t('The new path to be used'),
'type' => 'text',
'not null' => TRUE,
),
'tid' => array(
'description' => t('The taxonomy term ID'),
'type' => 'int',
'unsigned' => TRUE,
'default' => NULL,
),
'separator_replace' => array(
'description' => t('A character which is used to replace spaces and + characters in the path string'),
'type' => 'varchar',
'length' => 1,
'default' => '',
),
'remove_text' => array(
'description' => t('A carriage return, newline separated list of strings that is to be deleted from the path'),
'type' => 'varchar',
'length' => 250,
'default' => NULL,
),
'filter' => array(
'description' => t('The filter type for the path field, eg: Filtered HTML or PHP Code'),
'type' => 'int',
'default' => NULL,
),
'path_case' => array(
'description' => t('A setting to change the path case'),
'type' => 'varchar',
'length' => 25,
'not null' => TRUE,
'default' => 'No transform',
),
),
'unique keys' => array(
'vid_tid' => array(
'vid',
'tid',
),
),
);
return $schema;
}
/**
* Implementation of hook_install().
*/
function taxonomy_redirect_install() {
// Create my tables.
drupal_install_schema('taxonomy_redirect');
}
/**
* Implementation of hook_enable().
*/
function taxonomy_redirect_enable() {
// Add any redirects back from a previous install
$result = db_query("SELECT * FROM {taxonomy_redirect}");
$redir = array();
while ($redir = db_fetch_object($result)) {
db_query("UPDATE {vocabulary} SET module='taxonomy_redirect' WHERE vid='%d'", $redir->vid);
}
}
/**
* Implementation of hook_disable().
*/
function taxonomy_redirect_disable() {
// Revert vocabs back to their original modules
$result = db_query("SELECT * FROM {taxonomy_redirect}");
$redir = array();
while ($redir = db_fetch_object($result)) {
db_query("UPDATE {vocabulary} SET module='%s' WHERE vid='%d'", $redir->module, $redir->vid);
}
}
/**
* Implementation of hook_uninstall().
*/
function taxonomy_redirect_uninstall() {
// Drop my tables.
drupal_uninstall_schema('taxonomy_redirect');
}
/**
* Hook_update #1
*/
function taxonomy_redirect_update_1() {
$ret = array();
db_change_field($ret, 'taxonomy_redirect', 'path', 'path', array(
'type' => 'text',
'not null' => TRUE,
'description' => t('The new path to be used'),
));
db_add_field($ret, 'taxonomy_redirect', 'tid', array(
'type' => 'int',
'unsigned' => TRUE,
'default' => NULL,
'description' => t('The taxonomy term ID'),
));
db_add_field($ret, 'taxonomy_redirect', 'separator_replace', array(
'type' => 'varchar',
'length' => 1,
'default' => '',
'description' => t('A character which is used to replace spaces and + characters in the path string'),
));
db_add_field($ret, 'taxonomy_redirect', 'remove_text', array(
'type' => 'varchar',
'length' => 250,
'default' => NULL,
'description' => t('A carriage return, newline separated list of strings that is to be deleted from the path'),
));
db_add_field($ret, 'taxonomy_redirect', 'filter', array(
'type' => 'int',
'default' => NULL,
'description' => t('The filter type for the path field, eg: Filtered HTML or PHP Code'),
));
db_drop_primary_key($ret, 'taxonomy_redirect');
db_add_unique_key($ret, 'taxonomy_redirect', 'vid_tid', array(
'vid',
'tid',
));
return $ret;
}
/**
* Hook_update #2
*/
function taxonomy_redirect_update_2() {
$ret = array();
db_add_field($ret, 'taxonomy_redirect', 'path_case', array(
'type' => 'varchar',
'default' => 'No transform',
'length' => 25,
'not null' => TRUE,
'description' => t('A setting to change the path case'),
));
return $ret;
}
Functions
Name![]() |
Description |
---|---|
taxonomy_redirect_disable | Implementation of hook_disable(). |
taxonomy_redirect_enable | Implementation of hook_enable(). |
taxonomy_redirect_install | Implementation of hook_install(). |
taxonomy_redirect_schema | Implementation of hook_schema(). |
taxonomy_redirect_uninstall | Implementation of hook_uninstall(). |
taxonomy_redirect_update_1 | Hook_update #1 |
taxonomy_redirect_update_2 | Hook_update #2 |