hosting_alias.install in Hosting 6.2
Same filename and directory in other branches
Install, update and uninstall for the site aliases module.
File
alias/hosting_alias.installView source
<?php
/**
* @file
* Install, update and uninstall for the site aliases module.
*/
/**
* Implementation of hook_schema().
*/
function hosting_alias_schema() {
$schema['hosting_site_alias'] = array(
'fields' => array(
'vid' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'alias' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
),
'automatic' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'redirection' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
),
'indexes' => array(
'vid' => array(
'vid',
),
'alias' => array(
'alias',
),
),
);
return $schema;
}
/**
* Implementation of hook_install().
*/
function hosting_alias_install() {
// Create tables.
drupal_install_schema('hosting_alias');
}
/**
* Implementation of hook_uninstall().
*/
function hosting_alias_uninstall() {
// Remove tables.
drupal_uninstall_schema('hosting_alias');
}
/**
* This removes dodgy data created by an import bug.
*/
function hosting_alias_update_1() {
$ret = array();
$ret[] = update_sql("DELETE FROM {hosting_site_alias} WHERE alias='Array'");
return $ret;
}
/**
* Add the redirection field.
*/
function hosting_alias_update_2() {
$ret = array();
db_add_field($ret, 'hosting_site_alias', 'redirection', array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
));
return $ret;
}
/**
* Alter the redirection field to a varchar
*/
function hosting_alias_update_6203() {
$ret = array();
$spec = array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
);
db_change_field($ret, 'hosting_site_alias', 'redirection', 'redirection', $spec);
return $ret;
}
/**
* Fixup redirection data after table change in hosting_alias_update_6203()
*/
function hosting_alias_update_6204() {
$ret = array();
$result = db_query("SELECT alias.nid FROM {hosting_site_alias} alias INNER JOIN {hosting_site} site ON site.nid = alias.nid WHERE redirection=1 AND site.status>-2");
while ($obj = db_fetch_object($result)) {
$node = node_load($obj->nid);
if (is_object($node)) {
$node->redirection = $node->title;
hosting_alias_update($node);
// Run a verify task to update the vhost
hosting_add_task($node->nid, 'verify');
}
}
return $ret;
}
Functions
Name | Description |
---|---|
hosting_alias_install | Implementation of hook_install(). |
hosting_alias_schema | Implementation of hook_schema(). |
hosting_alias_uninstall | Implementation of hook_uninstall(). |
hosting_alias_update_1 | This removes dodgy data created by an import bug. |
hosting_alias_update_2 | Add the redirection field. |
hosting_alias_update_6203 | Alter the redirection field to a varchar |
hosting_alias_update_6204 | Fixup redirection data after table change in hosting_alias_update_6203() |