| 1 |
<?php
|
| 2 |
// $Id: path_redirect.install,v 1.2.2.6.2.18 2009/02/28 00:16:08 davereid Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Install and uninstall schema and functions for the path_redirect module.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implementation of hook_install().
|
| 11 |
*/
|
| 12 |
function path_redirect_install() {
|
| 13 |
drupal_install_schema('path_redirect');
|
| 14 |
}
|
| 15 |
|
| 16 |
/**
|
| 17 |
* Implementation of hook_uninstall().
|
| 18 |
*/
|
| 19 |
function path_redirect_uninstall() {
|
| 20 |
// Remove tables.
|
| 21 |
drupal_uninstall_schema('path_redirect');
|
| 22 |
|
| 23 |
// Remove variables.
|
| 24 |
drupal_load('module', 'path_redirect');
|
| 25 |
$variables = array_keys(path_redirect_variables());
|
| 26 |
foreach ($variables as $variable) {
|
| 27 |
variable_del($variable);
|
| 28 |
}
|
| 29 |
}
|
| 30 |
|
| 31 |
/**
|
| 32 |
* Implementation of hook_schema().
|
| 33 |
*/
|
| 34 |
function path_redirect_schema() {
|
| 35 |
$schema['path_redirect'] = array(
|
| 36 |
'description' => 'Stores information on redirects.',
|
| 37 |
'fields' => array(
|
| 38 |
'rid' => array(
|
| 39 |
'type' => 'serial',
|
| 40 |
'not null' => TRUE,
|
| 41 |
'description' => 'Primary Key: Unique path redirect ID.',
|
| 42 |
),
|
| 43 |
'path' => array(
|
| 44 |
'type' => 'varchar',
|
| 45 |
'length' => 255,
|
| 46 |
'not null' => TRUE,
|
| 47 |
'description' => 'The source path to redirect from.',
|
| 48 |
),
|
| 49 |
'redirect' => array(
|
| 50 |
'type' => 'varchar',
|
| 51 |
'length' => 255,
|
| 52 |
'not null' => TRUE,
|
| 53 |
'description' => 'The destination path to redirect to.',
|
| 54 |
),
|
| 55 |
'query' => array(
|
| 56 |
'type' => 'varchar',
|
| 57 |
'length' => 255,
|
| 58 |
'not null' => FALSE,
|
| 59 |
'description' => 'The query string to send to the destination.',
|
| 60 |
),
|
| 61 |
'fragment' => array(
|
| 62 |
'type' => 'varchar',
|
| 63 |
'length' => 50,
|
| 64 |
'not null' => FALSE,
|
| 65 |
'description' => 'An internal page anchor append to the destination.',
|
| 66 |
),
|
| 67 |
'language' => array(
|
| 68 |
'description' => 'The language this redirect is for; if blank, the alias will be used for unknown languages.',
|
| 69 |
'type' => 'varchar',
|
| 70 |
'length' => 12,
|
| 71 |
'not null' => TRUE,
|
| 72 |
'default' => '',
|
| 73 |
),
|
| 74 |
'type' => array(
|
| 75 |
'type' => 'int',
|
| 76 |
'size' => 'small',
|
| 77 |
'not null' => TRUE,
|
| 78 |
'description' => 'The HTTP status code to use for the redirect.',
|
| 79 |
),
|
| 80 |
'last_used' => array(
|
| 81 |
'type' => 'int',
|
| 82 |
'unsigned' => TRUE,
|
| 83 |
'not null' => TRUE,
|
| 84 |
'default' => 0,
|
| 85 |
'description' => 'The timestamp of when the redirect was last used.',
|
| 86 |
),
|
| 87 |
),
|
| 88 |
'primary key' => array('rid'),
|
| 89 |
'unique keys' => array('path_language' => array('path', 'language')),
|
| 90 |
);
|
| 91 |
|
| 92 |
return $schema;
|
| 93 |
}
|
| 94 |
|
| 95 |
// 6.x-extra updates
|
| 96 |
|
| 97 |
/**
|
| 98 |
* Add a last used timestamp field.
|
| 99 |
*/
|
| 100 |
function path_redirect_update_6100() {
|
| 101 |
$ret = array();
|
| 102 |
db_add_field($ret, 'path_redirect', 'last_used', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
|
| 103 |
$ret[] = update_sql("UPDATE {path_redirect} SET last_used = " . REQUEST_TIME);
|
| 104 |
return $ret;
|
| 105 |
}
|
| 106 |
|
| 107 |
/**
|
| 108 |
* Add a language field.
|
| 109 |
*/
|
| 110 |
function path_redirect_update_6101() {
|
| 111 |
$ret = array();
|
| 112 |
db_drop_unique_key($ret, 'path_redirect', 'path');
|
| 113 |
db_add_field($ret, 'path_redirect', 'language', array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => ''));
|
| 114 |
db_add_unique_key($ret, 'path_redirect', 'path_language', array('path', 'language'));
|
| 115 |
return $ret;
|
| 116 |
}
|
| 117 |
|