| 1 |
<?php
|
| 2 |
// $Id: customfilter.install,v 1.3.2.1 2007/10/27 17:07:32 arhip Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Implementation of hook_install()
|
| 6 |
*/
|
| 7 |
function customfilter_install() {
|
| 8 |
$result = array();
|
| 9 |
|
| 10 |
switch ($GLOBALS['db_type']) {
|
| 11 |
case 'mysql':
|
| 12 |
case 'mysqli':
|
| 13 |
$result[] = db_query("CREATE TABLE {customfilter_set} (
|
| 14 |
`sid` int(10) unsigned NOT NULL default '0',
|
| 15 |
`name` varchar(32) NOT NULL default '',
|
| 16 |
`cache` boolean NOT NULL default '1',
|
| 17 |
`description` text,
|
| 18 |
`shorttips` text,
|
| 19 |
`longtips` text);");
|
| 20 |
|
| 21 |
$result[] = db_query("CREATE TABLE {customfilter_filter} (
|
| 22 |
`fid` int(10) unsigned NOT NULL default '0',
|
| 23 |
`sid` int(10) unsigned NOT NULL default '0',
|
| 24 |
`parentid` int(10) unsigned NOT NULL default '0',
|
| 25 |
`name` varchar(32) NOT NULL default '',
|
| 26 |
`description` text,
|
| 27 |
`matches` int(2) NOT NULL default '1',
|
| 28 |
`pattern` text,
|
| 29 |
`replacement` text,
|
| 30 |
`func` boolean NOT NULL default '0',
|
| 31 |
`weight` int(5) NOT NULL default '0');");
|
| 32 |
|
| 33 |
break;
|
| 34 |
case 'pgsql':
|
| 35 |
break;
|
| 36 |
}
|
| 37 |
|
| 38 |
if (count($result) == count(array_filter($result))) {
|
| 39 |
drupal_set_message(t('The CustomFilter module has successfully added its tables to the database.'));
|
| 40 |
}
|
| 41 |
else {
|
| 42 |
drupal_set_message(t('Drupal was unable to install the database tables for the CustomFilter module.'), 'error');
|
| 43 |
}
|
| 44 |
}
|
| 45 |
|
| 46 |
/**
|
| 47 |
* Implementation of hook_uninstall()
|
| 48 |
*/
|
| 49 |
function customfilter_uninstall() {
|
| 50 |
db_query("DROP TABLE {customfilter_filter}");
|
| 51 |
db_query("DROP TABLE {customfilter_set}");
|
| 52 |
}
|
| 53 |
|
| 54 |
/**
|
| 55 |
* Implementation of hook_update_N()
|
| 56 |
*/
|
| 57 |
function customfilter_update_1() {
|
| 58 |
$result = array();
|
| 59 |
$result[] = update_sql("ALTER TABLE {customfilter_set} ADD COLUMN `cache` boolean NOT NULL default '1' AFTER `name`;");
|
| 60 |
|
| 61 |
return $result;
|
| 62 |
}
|