Newer
Older

Dries Buytaert
committed
<?php

Dries Buytaert
committed
/**
* Implementation of hook_install().
*/

Dries Buytaert
committed
function aggregator_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {aggregator_category} (

Dries Buytaert
committed
cid int NOT NULL auto_increment,

Dries Buytaert
committed
title varchar(255) NOT NULL default '',
description longtext NOT NULL,

Dries Buytaert
committed
block tinyint NOT NULL default '0',

Dries Buytaert
committed
PRIMARY KEY (cid),
UNIQUE KEY title (title)
) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
db_query("CREATE TABLE {aggregator_category_feed} (

Dries Buytaert
committed
fid int NOT NULL default '0',
cid int NOT NULL default '0',

Dries Buytaert
committed
PRIMARY KEY (fid,cid)
) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
db_query("CREATE TABLE {aggregator_category_item} (

Dries Buytaert
committed
iid int NOT NULL default '0',
cid int NOT NULL default '0',

Dries Buytaert
committed
PRIMARY KEY (iid,cid)
) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
db_query("CREATE TABLE {aggregator_feed} (

Dries Buytaert
committed
fid int NOT NULL auto_increment,

Dries Buytaert
committed
title varchar(255) NOT NULL default '',
url varchar(255) NOT NULL default '',

Dries Buytaert
committed
refresh int NOT NULL default '0',
checked int NOT NULL default '0',

Dries Buytaert
committed
link varchar(255) NOT NULL default '',
description longtext NOT NULL,
image longtext NOT NULL,
etag varchar(255) NOT NULL default '',

Dries Buytaert
committed
modified int NOT NULL default '0',
block tinyint NOT NULL default '0',

Dries Buytaert
committed
PRIMARY KEY (fid),
UNIQUE KEY link (url),
UNIQUE KEY title (title)
) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
db_query("CREATE TABLE {aggregator_item} (

Dries Buytaert
committed
iid int NOT NULL auto_increment,
fid int NOT NULL default '0',

Dries Buytaert
committed
title varchar(255) NOT NULL default '',
link varchar(255) NOT NULL default '',
author varchar(255) NOT NULL default '',
description longtext NOT NULL,

Dries Buytaert
committed
timestamp int default NULL,

Dries Buytaert
committed
) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
break;
case 'pgsql':
db_query("CREATE TABLE {aggregator_category} (
cid serial,
title varchar(255) NOT NULL default '',
description text NOT NULL,
block smallint NOT NULL default '0',
PRIMARY KEY (cid),
UNIQUE (title)
)");
db_query("CREATE TABLE {aggregator_category_feed} (
fid int NOT NULL default '0',
cid int NOT NULL default '0',
PRIMARY KEY (fid,cid)
)");
db_query("CREATE TABLE {aggregator_category_item} (
iid int NOT NULL default '0',
cid int NOT NULL default '0',
PRIMARY KEY (iid,cid)
)");
db_query("CREATE TABLE {aggregator_feed} (
fid serial,
title varchar(255) NOT NULL default '',
url varchar(255) NOT NULL default '',
refresh int NOT NULL default '0',
checked int NOT NULL default '0',
link varchar(255) NOT NULL default '',

Dries Buytaert
committed
description text NOT NULL default '',
image text NOT NULL default '',
etag varchar(255) NOT NULL default '',
modified int NOT NULL default '0',
block smallint NOT NULL default '0',
PRIMARY KEY (fid),
UNIQUE (url),
UNIQUE (title)
)");
db_query("CREATE TABLE {aggregator_item} (
iid serial,
fid int NOT NULL default '0',
title varchar(255) NOT NULL default '',
link varchar(255) NOT NULL default '',
author varchar(255) NOT NULL default '',
description text NOT NULL,
timestamp int default NULL,
guid varchar(255),
PRIMARY KEY (iid)
)");
db_query("CREATE INDEX {aggregator_item}_fid_idx ON {aggregator_item} (fid)");

Dries Buytaert
committed
break;
}
}
/**
* Implementation of hook_uninstall().
*/
function aggregator_uninstall() {
db_query('DROP TABLE {aggregator_category}');
db_query('DROP TABLE {aggregator_category_feed}');
db_query('DROP TABLE {aggregator_category_item}');
db_query('DROP TABLE {aggregator_feed}');
db_query('DROP TABLE {aggregator_item}');
variable_del('aggregator_allowed_html_tags');
variable_del('aggregator_summary_items');
variable_del('aggregator_clear');
variable_del('aggregator_category_selector');
}