wordfilter.install in Wordfilter 5
Same filename and directory in other branches
Module install and update functions for the Wordfilter module.
File
wordfilter.installView source
<?php
/**
* @file
* Module install and update functions for the Wordfilter module.
*/
/**
* Implementation of hook_install().
*/
function wordfilter_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$result = db_query("CREATE TABLE {wordfilter} (\n id int(11) auto_increment,\n words text NOT NULL,\n replacement varchar(255) DEFAULT '' NOT NULL,\n standalone tinyint(1) DEFAULT '0' NOT NULL,\n PRIMARY KEY (id)\n ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
break;
case 'pgsql':
$result = db_query("CREATE TABLE {wordfilter} (\n id serial PRIMARY KEY,\n words text NOT NULL,\n replacement varchar(255) DEFAULT '' NOT NULL,\n standalone smallint DEFAULT '0' NOT NULL\n );");
break;
}
if ($result) {
drupal_set_message(t('wordfilter module installed successfully.'));
}
else {
drupal_set_message(t('wordfilter module was not installed. Please view the wordfilter module folder and read the INSTALL.txt'), 'error');
}
}
/**
* Implementation of hook_update_N().
*/
function wordfilter_update_1() {
return _system_update_utf8(array(
'wordfilter',
));
}
/**
* Implementation of hook_update_N().
*/
function wordfilter_update_2() {
return array(
update_sql('ALTER TABLE {wordfilter} CHANGE words words TEXT NOT NULL'),
);
}
/**
* Implementation of hook_update_N().
*
* Update to lower module weight so that wordfiltering
* can occur before other modules can run hook_nodeapi
* and hook_comment
*/
function wordfilter_update_3() {
$ret = array();
$ret[] = update_sql("UPDATE {system} SET weight = -1 WHERE name = '%s' AND type = '%s'", 'wordfilter', 'module');
return $ret;
}
/**
* Implementation of hook_uninstall().
*/
function wordfilter_uninstall() {
db_query('DROP TABLE {wordfilter}');
variable_del('wordfilter_default_replacement');
variable_del('wordfilter_node_title');
variable_del('wordfilter_comment_title');
}
Functions
Name![]() |
Description |
---|---|
wordfilter_install | Implementation of hook_install(). |
wordfilter_uninstall | Implementation of hook_uninstall(). |
wordfilter_update_1 | Implementation of hook_update_N(). |
wordfilter_update_2 | Implementation of hook_update_N(). |
wordfilter_update_3 | Implementation of hook_update_N(). |