| 1 |
<?php
|
| 2 |
// $Id$
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Implementation of hook_install().
|
| 6 |
*/
|
| 7 |
function wordfilter_install() {
|
| 8 |
switch ($GLOBALS['db_type']) {
|
| 9 |
case 'mysql':
|
| 10 |
case 'mysqli':
|
| 11 |
$result = db_query("CREATE TABLE {wordfilter} (
|
| 12 |
id int(11) auto_increment,
|
| 13 |
words text NOT NULL,
|
| 14 |
replacement varchar(255) DEFAULT '' NOT NULL,
|
| 15 |
standalone tinyint(1) DEFAULT '0' NOT NULL,
|
| 16 |
PRIMARY KEY (id)
|
| 17 |
) /*!40100 DEFAULT CHARACTER SET utf8 */;");
|
| 18 |
break;
|
| 19 |
case 'pgsql':
|
| 20 |
$result = db_query("CREATE TABLE {wordfilter} (
|
| 21 |
id serial PRIMARY KEY,
|
| 22 |
words text NOT NULL,
|
| 23 |
replacement varchar(255) DEFAULT '' NOT NULL,
|
| 24 |
standalone smallint DEFAULT '0' NOT NULL
|
| 25 |
);");
|
| 26 |
break;
|
| 27 |
}
|
| 28 |
|
| 29 |
if ($result) {
|
| 30 |
drupal_set_message(t("wordfilter module installed successfully."));
|
| 31 |
} else {
|
| 32 |
drupal_set_message(t("wordfilter module was not installed. Please view the wordfilter module folder and read the INSTALL.txt"), 'error');
|
| 33 |
}
|
| 34 |
}
|
| 35 |
|
| 36 |
/**
|
| 37 |
* Implementation of hook_update().
|
| 38 |
*/
|
| 39 |
function wordfilter_update_1() {
|
| 40 |
return _system_update_utf8(array('wordfilter'));
|
| 41 |
}
|
| 42 |
|
| 43 |
function wordfilter_update_2() {
|
| 44 |
return array(update_sql("ALTER TABLE {wordfilter} CHANGE words words TEXT NOT NULL"));
|
| 45 |
}
|
| 46 |
|
| 47 |
/**
|
| 48 |
* Implementation of hook_uninstall().
|
| 49 |
*/
|
| 50 |
function wordfilter_uninstall() {
|
| 51 |
db_query('DROP TABLE {wordfilter}');
|
| 52 |
}
|