View source
<?php
function feedback_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {feedback} (\n fid int unsigned NOT NULL default '0',\n uid int unsigned NOT NULL default '0',\n status tinyint unsigned NOT NULL default '0',\n message longtext NOT NULL,\n location text NOT NULL,\n location_masked text NOT NULL,\n url text NOT NULL,\n timestamp int NOT NULL,\n useragent varchar(255) NOT NULL,\n PRIMARY KEY (fid),\n KEY location (location(32)),\n KEY location_masked (location_masked(32))\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
break;
case 'pgsql':
db_query("CREATE TABLE {feedback} (\n fid int_unsigned NOT NULL default '0',\n uid int_unsigned NOT NULL default '0',\n status smallint NOT NULL default '0',\n message text NOT NULL,\n location text NOT NULL,\n location_masked text NOT NULL,\n url text NOT NULL,\n timestamp int NOT NULL,\n useragent varchar(255) NOT NULL,\n PRIMARY KEY (fid)\n )");
db_query("CREATE INDEX {feedback}_fid_idx ON {feedback} (fid)");
db_query("CREATE INDEX {feedback}_location_idx ON {feedback} (location)");
db_query("CREATE INDEX {feedback}_location_masked_idx ON {feedback} (location_masked)");
break;
}
}
function feedback_uninstall() {
db_query("DROP TABLE {feedback}");
db_query("DELETE FROM {variable} WHERE name LIKE 'feedback_%%'");
}
function feedback_update_5200() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {feedback} ADD location_masked text NOT NULL AFTER location");
$ret[] = update_sql("ALTER TABLE {feedback} ADD KEY location_masked (location_masked(32))");
break;
case 'pgsql':
db_add_column($ret, 'feedback', 'location_masked', 'text', array(
'not null' => TRUE,
));
$ret[] = update_sql("CREATE INDEX {feedback}_location_masked_idx ON {feedback} (location_masked)");
break;
}
return $ret;
}
function feedback_update_5201() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {feedback} ADD useragent varchar(255) NOT NULL");
break;
case 'pgsql':
db_add_column($ret, 'feedback', 'useragent', 'varchar(255)', array(
'not null' => TRUE,
));
break;
}
return $ret;
}
function feedback_update_5202() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {feedback} ADD url text NOT NULL AFTER location_masked");
$ret[] = update_sql("UPDATE {feedback} SET url = location");
break;
case 'pgsql':
db_add_column($ret, 'feedback', 'url', 'text', array(
'not null' => TRUE,
));
$ret[] = update_sql("UPDATE {feedback} SET url = location");
break;
}
return $ret;
}