| 1 |
<?php
|
| 2 |
/**
|
| 3 |
* $Id: $
|
| 4 |
* @author Bruno Massa
|
| 5 |
* @file address.install
|
| 6 |
* Installation / uninstallation routines.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implementation of hook_install().
|
| 11 |
*/
|
| 12 |
function address_install() {
|
| 13 |
// Install the necessary Database tables
|
| 14 |
drupal_install_schema('address');
|
| 15 |
}
|
| 16 |
|
| 17 |
/**
|
| 18 |
* Implementation of hook_schema().
|
| 19 |
*/
|
| 20 |
function address_schema() {
|
| 21 |
$schema['address'] = array(
|
| 22 |
'description' => t('Products-specific fields'),
|
| 23 |
'fields' => array(
|
| 24 |
'aid' => array(
|
| 25 |
'type' => 'serial',
|
| 26 |
'not null' => TRUE,
|
| 27 |
'description' => t('Address ID'),
|
| 28 |
),
|
| 29 |
'eid' => array(
|
| 30 |
'type' => 'int',
|
| 31 |
'unsigned' => TRUE,
|
| 32 |
'not null' => TRUE,
|
| 33 |
'description' => t('Element ID can be the User ID from {user}.uid or Node ID from {node}.nid'),
|
| 34 |
),
|
| 35 |
'atype' => array(
|
| 36 |
'type' => 'varchar',
|
| 37 |
'length' => 5,
|
| 38 |
'description' => t('Identify what type of address is this: "user" and "node" addresses are the most common'),
|
| 39 |
),
|
| 40 |
'aname' => array(
|
| 41 |
'type' => 'varchar',
|
| 42 |
'length' => 75,
|
| 43 |
'description' => t('The nickname of this address, like "Home", "Office", "Annas appartment"'),
|
| 44 |
),
|
| 45 |
'street' => array(
|
| 46 |
'type' => 'varchar',
|
| 47 |
'length' => 255,
|
| 48 |
'description' => t('Street, number...'),
|
| 49 |
),
|
| 50 |
'additional' => array(
|
| 51 |
'type' => 'varchar',
|
| 52 |
'length' => 255,
|
| 53 |
'description' => t('More info like appartment block, number or address reference'),
|
| 54 |
),
|
| 55 |
'city' => array(
|
| 56 |
'type' => 'varchar',
|
| 57 |
'length' => 255,
|
| 58 |
'description' => t('Name of the city'),
|
| 59 |
),
|
| 60 |
'province' => array(
|
| 61 |
'type' => 'varchar',
|
| 62 |
'length' => 16,
|
| 63 |
'description' => t('Name of the state/province/county/territory'),
|
| 64 |
),
|
| 65 |
'country' => array(
|
| 66 |
'type' => 'varchar',
|
| 67 |
'length' => 2,
|
| 68 |
'description' => t('The ISO alpha 3 code of each country (its a 2-digit code)'),
|
| 69 |
),
|
| 70 |
'postal_code' => array(
|
| 71 |
'type' => 'varchar',
|
| 72 |
'length' => 16,
|
| 73 |
'description' => t('The address postal code (ZIP code for US people)'),
|
| 74 |
),
|
| 75 |
'is_primary' => array(
|
| 76 |
'type' => 'int',
|
| 77 |
'size' => 'tiny',
|
| 78 |
'default' => 0,
|
| 79 |
'description' => t('Mark it as the primary address or not (default is not)'),
|
| 80 |
)
|
| 81 |
),
|
| 82 |
'primary key' => array('aid'),
|
| 83 |
'indexes' => array(
|
| 84 |
'eid' => array('eid'),
|
| 85 |
),
|
| 86 |
);
|
| 87 |
$schema['address_zipcodes'] = array(
|
| 88 |
'description' => t('Products-specific fields'),
|
| 89 |
'fields' => array(
|
| 90 |
'country' => array(
|
| 91 |
'type' => 'varchar',
|
| 92 |
'length' => 2,
|
| 93 |
'not null' => TRUE,
|
| 94 |
'description' => t('The ISO alpha 3 code of each country (its a 2-digit code)'),
|
| 95 |
),
|
| 96 |
'postal_code' => array(
|
| 97 |
'type' => 'varchar',
|
| 98 |
'length' => 2,
|
| 99 |
'not null' => TRUE,
|
| 100 |
'description' => t('The address postal code (ZIP code for US people)'),
|
| 101 |
),
|
| 102 |
'city' => array(
|
| 103 |
'type' => 'varchar',
|
| 104 |
'length' => 255,
|
| 105 |
'description' => t('Name of the city'),
|
| 106 |
),
|
| 107 |
'province' => array(
|
| 108 |
'type' => 'varchar',
|
| 109 |
'length' => 16,
|
| 110 |
'description' => t('Name of the state/province/county/territory'),
|
| 111 |
),
|
| 112 |
'latitude' => array(
|
| 113 |
'type' => 'float',
|
| 114 |
'description' => t('The place Latitute, if available'),
|
| 115 |
),
|
| 116 |
'longitude' => array(
|
| 117 |
'type' => 'float',
|
| 118 |
'description' => t('The place Longitude, if available'),
|
| 119 |
),
|
| 120 |
'timezone' => array(
|
| 121 |
'type' => 'int',
|
| 122 |
'size' => 'small',
|
| 123 |
'description' => t('How much hours (more or less) than Greenwich time'),
|
| 124 |
),
|
| 125 |
'dst' => array(
|
| 126 |
'type' => 'int',
|
| 127 |
'size' => 'small',
|
| 128 |
'description' => t('????'),
|
| 129 |
)
|
| 130 |
),
|
| 131 |
'primary key' => array('country', 'postal_code'),
|
| 132 |
'indexes' => array(
|
| 133 |
'country' => array('country'),
|
| 134 |
'postal_code' => array('postal_code'),
|
| 135 |
),
|
| 136 |
);
|
| 137 |
return $schema;
|
| 138 |
}
|
| 139 |
|
| 140 |
/**
|
| 141 |
* Implentation of hook_uninstall().
|
| 142 |
*/
|
| 143 |
function address_uninstall() {
|
| 144 |
// Delete tables
|
| 145 |
drupal_uninstall_schema('address');
|
| 146 |
}
|