| 1 |
<?php
|
| 2 |
// $Id: aggregator.install,v 1.26 2009/09/10 06:38:17 dries Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Install, update and uninstall functions for the aggregator module.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implement hook_uninstall().
|
| 11 |
*/
|
| 12 |
function aggregator_uninstall() {
|
| 13 |
variable_del('aggregator_allowed_html_tags');
|
| 14 |
variable_del('aggregator_summary_items');
|
| 15 |
variable_del('aggregator_clear');
|
| 16 |
variable_del('aggregator_category_selector');
|
| 17 |
variable_del('aggregator_fetcher');
|
| 18 |
variable_del('aggregator_parser');
|
| 19 |
variable_del('aggregator_processors');
|
| 20 |
variable_del('aggregator_teaser_length');
|
| 21 |
}
|
| 22 |
|
| 23 |
/**
|
| 24 |
* Implement hook_schema().
|
| 25 |
*/
|
| 26 |
function aggregator_schema() {
|
| 27 |
$schema['aggregator_category'] = array(
|
| 28 |
'description' => 'Stores categories for aggregator feeds and feed items.',
|
| 29 |
'fields' => array(
|
| 30 |
'cid' => array(
|
| 31 |
'type' => 'serial',
|
| 32 |
'not null' => TRUE,
|
| 33 |
'description' => 'Primary Key: Unique aggregator category ID.',
|
| 34 |
),
|
| 35 |
'title' => array(
|
| 36 |
'type' => 'varchar',
|
| 37 |
'length' => 255,
|
| 38 |
'not null' => TRUE,
|
| 39 |
'default' => '',
|
| 40 |
'description' => 'Title of the category.',
|
| 41 |
),
|
| 42 |
'description' => array(
|
| 43 |
'type' => 'text',
|
| 44 |
'not null' => TRUE,
|
| 45 |
'size' => 'big',
|
| 46 |
'description' => 'Description of the category',
|
| 47 |
),
|
| 48 |
'block' => array(
|
| 49 |
'type' => 'int',
|
| 50 |
'not null' => TRUE,
|
| 51 |
'default' => 0,
|
| 52 |
'size' => 'tiny',
|
| 53 |
'description' => 'The number of recent items to show within the category block.',
|
| 54 |
)
|
| 55 |
),
|
| 56 |
'primary key' => array('cid'),
|
| 57 |
'unique keys' => array(
|
| 58 |
'title' => array('title'),
|
| 59 |
),
|
| 60 |
);
|
| 61 |
|
| 62 |
$schema['aggregator_category_feed'] = array(
|
| 63 |
'description' => 'Bridge table; maps feeds to categories.',
|
| 64 |
'fields' => array(
|
| 65 |
'fid' => array(
|
| 66 |
'type' => 'int',
|
| 67 |
'not null' => TRUE,
|
| 68 |
'default' => 0,
|
| 69 |
'description' => "The feed's {aggregator_feed}.fid.",
|
| 70 |
),
|
| 71 |
'cid' => array(
|
| 72 |
'type' => 'int',
|
| 73 |
'not null' => TRUE,
|
| 74 |
'default' => 0,
|
| 75 |
'description' => 'The {aggregator_category}.cid to which the feed is being assigned.',
|
| 76 |
)
|
| 77 |
),
|
| 78 |
'primary key' => array('cid', 'fid'),
|
| 79 |
'indexes' => array(
|
| 80 |
'fid' => array('fid'),
|
| 81 |
),
|
| 82 |
'foreign keys' => array(
|
| 83 |
'cid' => array('aggregator_category' => 'cid'),
|
| 84 |
),
|
| 85 |
);
|
| 86 |
|
| 87 |
$schema['aggregator_category_item'] = array(
|
| 88 |
'description' => 'Bridge table; maps feed items to categories.',
|
| 89 |
'fields' => array(
|
| 90 |
'iid' => array(
|
| 91 |
'type' => 'int',
|
| 92 |
'not null' => TRUE,
|
| 93 |
'default' => 0,
|
| 94 |
'description' => "The feed item's {aggregator_item}.iid.",
|
| 95 |
),
|
| 96 |
'cid' => array(
|
| 97 |
'type' => 'int',
|
| 98 |
'not null' => TRUE,
|
| 99 |
'default' => 0,
|
| 100 |
'description' => 'The {aggregator_category}.cid to which the feed item is being assigned.',
|
| 101 |
)
|
| 102 |
),
|
| 103 |
'primary key' => array('cid', 'iid'),
|
| 104 |
'indexes' => array(
|
| 105 |
'iid' => array('iid'),
|
| 106 |
),
|
| 107 |
'foreign keys' => array(
|
| 108 |
'cid' => array('aggregator_category' => 'cid'),
|
| 109 |
),
|
| 110 |
);
|
| 111 |
|
| 112 |
$schema['aggregator_feed'] = array(
|
| 113 |
'description' => 'Stores feeds to be parsed by the aggregator.',
|
| 114 |
'fields' => array(
|
| 115 |
'fid' => array(
|
| 116 |
'type' => 'serial',
|
| 117 |
'not null' => TRUE,
|
| 118 |
'description' => 'Primary Key: Unique feed ID.',
|
| 119 |
),
|
| 120 |
'title' => array(
|
| 121 |
'type' => 'varchar',
|
| 122 |
'length' => 255,
|
| 123 |
'not null' => TRUE,
|
| 124 |
'default' => '',
|
| 125 |
'description' => 'Title of the feed.',
|
| 126 |
),
|
| 127 |
'url' => array(
|
| 128 |
'type' => 'varchar',
|
| 129 |
'length' => 255,
|
| 130 |
'not null' => TRUE,
|
| 131 |
'default' => '',
|
| 132 |
'description' => 'URL to the feed.',
|
| 133 |
),
|
| 134 |
'refresh' => array(
|
| 135 |
'type' => 'int',
|
| 136 |
'not null' => TRUE,
|
| 137 |
'default' => 0,
|
| 138 |
'description' => 'How often to check for new feed items, in seconds.',
|
| 139 |
),
|
| 140 |
'checked' => array(
|
| 141 |
'type' => 'int',
|
| 142 |
'not null' => TRUE,
|
| 143 |
'default' => 0,
|
| 144 |
'description' => 'Last time feed was checked for new items, as Unix timestamp.',
|
| 145 |
),
|
| 146 |
'link' => array(
|
| 147 |
'type' => 'varchar',
|
| 148 |
'length' => 255,
|
| 149 |
'not null' => TRUE,
|
| 150 |
'default' => '',
|
| 151 |
'description' => 'The parent website of the feed; comes from the <link> element in the feed.',
|
| 152 |
),
|
| 153 |
'description' => array(
|
| 154 |
'type' => 'text',
|
| 155 |
'not null' => TRUE,
|
| 156 |
'size' => 'big',
|
| 157 |
'description' => "The parent website's description; comes from the <description> element in the feed.",
|
| 158 |
),
|
| 159 |
'image' => array(
|
| 160 |
'type' => 'text',
|
| 161 |
'not null' => TRUE,
|
| 162 |
'size' => 'big',
|
| 163 |
'description' => 'An image representing the feed.',
|
| 164 |
),
|
| 165 |
'hash' => array(
|
| 166 |
'type' => 'varchar',
|
| 167 |
'length' => 32,
|
| 168 |
'not null' => TRUE,
|
| 169 |
'default' => '',
|
| 170 |
'description' => 'Calculated md5 hash of the feed data, used for validating cache.',
|
| 171 |
),
|
| 172 |
'etag' => array(
|
| 173 |
'type' => 'varchar',
|
| 174 |
'length' => 255,
|
| 175 |
'not null' => TRUE,
|
| 176 |
'default' => '',
|
| 177 |
'description' => 'Entity tag HTTP response header, used for validating cache.',
|
| 178 |
),
|
| 179 |
'modified' => array(
|
| 180 |
'type' => 'int',
|
| 181 |
'not null' => TRUE,
|
| 182 |
'default' => 0,
|
| 183 |
'description' => 'When the feed was last modified, as a Unix timestamp.',
|
| 184 |
),
|
| 185 |
'block' => array(
|
| 186 |
'type' => 'int',
|
| 187 |
'not null' => TRUE,
|
| 188 |
'default' => 0,
|
| 189 |
'size' => 'tiny',
|
| 190 |
'description' => "Number of items to display in the feed's block.",
|
| 191 |
)
|
| 192 |
),
|
| 193 |
'primary key' => array('fid'),
|
| 194 |
'unique keys' => array(
|
| 195 |
'url' => array('url'),
|
| 196 |
'title' => array('title'),
|
| 197 |
),
|
| 198 |
);
|
| 199 |
|
| 200 |
$schema['aggregator_item'] = array(
|
| 201 |
'description' => 'Stores the individual items imported from feeds.',
|
| 202 |
'fields' => array(
|
| 203 |
'iid' => array(
|
| 204 |
'type' => 'serial',
|
| 205 |
'not null' => TRUE,
|
| 206 |
'description' => 'Primary Key: Unique ID for feed item.',
|
| 207 |
),
|
| 208 |
'fid' => array(
|
| 209 |
'type' => 'int',
|
| 210 |
'not null' => TRUE,
|
| 211 |
'default' => 0,
|
| 212 |
'description' => 'The {aggregator_feed}.fid to which this item belongs.',
|
| 213 |
),
|
| 214 |
'title' => array(
|
| 215 |
'type' => 'varchar',
|
| 216 |
'length' => 255,
|
| 217 |
'not null' => TRUE,
|
| 218 |
'default' => '',
|
| 219 |
'description' => 'Title of the feed item.',
|
| 220 |
),
|
| 221 |
'link' => array(
|
| 222 |
'type' => 'varchar',
|
| 223 |
'length' => 255,
|
| 224 |
'not null' => TRUE,
|
| 225 |
'default' => '',
|
| 226 |
'description' => 'Link to the feed item.',
|
| 227 |
),
|
| 228 |
'author' => array(
|
| 229 |
'type' => 'varchar',
|
| 230 |
'length' => 255,
|
| 231 |
'not null' => TRUE,
|
| 232 |
'default' => '',
|
| 233 |
'description' => 'Author of the feed item.',
|
| 234 |
),
|
| 235 |
'description' => array(
|
| 236 |
'type' => 'text',
|
| 237 |
'not null' => TRUE,
|
| 238 |
'size' => 'big',
|
| 239 |
'description' => 'Body of the feed item.',
|
| 240 |
),
|
| 241 |
'timestamp' => array(
|
| 242 |
'type' => 'int',
|
| 243 |
'not null' => FALSE,
|
| 244 |
'description' => 'Posted date of the feed item, as a Unix timestamp.',
|
| 245 |
),
|
| 246 |
'guid' => array(
|
| 247 |
'type' => 'varchar',
|
| 248 |
'length' => 255,
|
| 249 |
'not null' => FALSE,
|
| 250 |
'description' => 'Unique identifier for the feed item.',
|
| 251 |
)
|
| 252 |
),
|
| 253 |
'primary key' => array('iid'),
|
| 254 |
'indexes' => array(
|
| 255 |
'fid' => array('fid'),
|
| 256 |
),
|
| 257 |
'foreign keys' => array(
|
| 258 |
'fid' => array('aggregator_feed' => 'fid'),
|
| 259 |
),
|
| 260 |
);
|
| 261 |
|
| 262 |
return $schema;
|
| 263 |
}
|
| 264 |
|
| 265 |
/**
|
| 266 |
* Add hash column to aggregator_feed table.
|
| 267 |
*/
|
| 268 |
function aggregator_update_7000() {
|
| 269 |
db_add_field('aggregator_feed', 'hash', array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => ''));
|
| 270 |
}
|
| 271 |
|
| 272 |
/**
|
| 273 |
* Add aggregator teaser length to settings from old global default teaser length
|
| 274 |
*/
|
| 275 |
function aggregator_update_7001() {
|
| 276 |
variable_set('aggregator_teaser_length', variable_get('teaser_length'));
|
| 277 |
}
|