| 1 |
<?php
|
| 2 |
// $Id: announcements.install,v 1.5 2008/05/08 14:18:27 nancyw Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* announcement module install file.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implementation of hook_install().
|
| 11 |
*
|
| 12 |
* Inserts the announcement module's schema in the SQL database.
|
| 13 |
*/
|
| 14 |
function announcements_install() {
|
| 15 |
switch ($GLOBALS['db_type']) {
|
| 16 |
case 'mysql':
|
| 17 |
case 'mysqli':
|
| 18 |
$created = db_query("CREATE TABLE {announcements} (
|
| 19 |
nid int(10) unsigned NOT NULL default '0',
|
| 20 |
abstract varchar(255) default '',
|
| 21 |
publish_date integer NOT NULL default '0',
|
| 22 |
expiration_date integer NOT NULL default '0',
|
| 23 |
PRIMARY KEY (nid));");
|
| 24 |
break;
|
| 25 |
|
| 26 |
case 'pgsql':
|
| 27 |
$created = db_query("CREATE TABLE {announcements} (
|
| 28 |
nid integer unsigned NOT NULL default '0',
|
| 29 |
abstract varchar(255) default '',
|
| 30 |
publish_date integer NOT NULL default '0',
|
| 31 |
expiration_date integer NOT NULL default '0',
|
| 32 |
PRIMARY KEY (nid));");
|
| 33 |
break;
|
| 34 |
}
|
| 35 |
|
| 36 |
if (!$created) {
|
| 37 |
drupal_set_message(t('Table installation for the Announcement module was unsuccessful.'), 'error');
|
| 38 |
}
|
| 39 |
}
|
| 40 |
|
| 41 |
/**
|
| 42 |
* Implementation of hook_uninstall().
|
| 43 |
*
|
| 44 |
* Remove the variables, nodes and schema corresponding to the FAQ module.
|
| 45 |
*/
|
| 46 |
function announcements_uninstall() {
|
| 47 |
switch ($GLOBALS['db_type']) {
|
| 48 |
case 'mysql':
|
| 49 |
case 'mysqli':
|
| 50 |
$deleted = db_query("DROP TABLE IF EXISTS {announcements}");
|
| 51 |
break;
|
| 52 |
|
| 53 |
case 'pgsql':
|
| 54 |
$deleted = db_query('DROP TABLE {announcements}');
|
| 55 |
break;
|
| 56 |
}
|
| 57 |
|
| 58 |
// Delete the variables.
|
| 59 |
variable_del('announcements_block_max_list_count');
|
| 60 |
variable_del('announcements_display_classification');
|
| 61 |
variable_del('announcements_interval');
|
| 62 |
|
| 63 |
// Remove the node type.
|
| 64 |
node_type_delete('announcements');
|
| 65 |
db_query("DELETE FROM {node} WHERE type='announcements'");
|
| 66 |
|
| 67 |
}
|