| 1 |
<?php
|
| 2 |
// $Id$
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Implementation of hook_install().
|
| 6 |
*/
|
| 7 |
function role_watchdog_install() {
|
| 8 |
switch ($GLOBALS['db_type']) {
|
| 9 |
case 'mysqli':
|
| 10 |
case 'mysql':
|
| 11 |
db_query("CREATE TABLE if not exists {role_watchdog} (
|
| 12 |
aid int(10) unsigned NOT NULL,
|
| 13 |
rid int(10) unsigned NOT NULL,
|
| 14 |
action tinyint(1) NOT NULL,
|
| 15 |
uid int(10) unsigned NOT NULL,
|
| 16 |
stamp int(10) unsigned NOT NULL,
|
| 17 |
KEY aid (aid)
|
| 18 |
) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
|
| 19 |
break;
|
| 20 |
|
| 21 |
case 'pgsql':
|
| 22 |
db_query("CREATE TABLE if not exists {role_watchdog} (
|
| 23 |
aid int(10) unsigned NOT NULL,
|
| 24 |
rid int(10) unsigned NOT NULL,
|
| 25 |
action tinyint(1) NOT NULL,
|
| 26 |
uid int(10) unsigned NOT NULL,
|
| 27 |
stamp int(10) unsigned NOT NULL,
|
| 28 |
KEY aid (aid)
|
| 29 |
)");
|
| 30 |
break;
|
| 31 |
}
|
| 32 |
drupal_set_message(t('Role Watchdog table installed. !Configure_role_watchdog', array(
|
| 33 |
'!Configure_role_watchdog' => l('Configure Role Watchdog', 'admin/user/roles/role_watchdog')
|
| 34 |
)));
|
| 35 |
}
|
| 36 |
|
| 37 |
/**
|
| 38 |
* Implementation of hook_uninstall().
|
| 39 |
*/
|
| 40 |
function role_watchdog_uninstall() {
|
| 41 |
db_query("DROP TABLE {role_watchdog}");
|
| 42 |
$vars = array(
|
| 43 |
'role_watchdog_monitor_roles',
|
| 44 |
'role_watchdog_notify_roles',
|
| 45 |
'role_watchdog_history',
|
| 46 |
);
|
| 47 |
foreach ($vars as $var) {
|
| 48 |
variable_del($var);
|
| 49 |
}
|
| 50 |
drupal_set_message(t('Role Watchdog table and variables removed.'));
|
| 51 |
|
| 52 |
cache_clear_all();
|
| 53 |
}
|
| 54 |
|
| 55 |
function role_watchdog_update_1() {
|
| 56 |
$items = array();
|
| 57 |
$items[] = update_sql("CREATE TABLE if not exists {role_watchdog} (
|
| 58 |
aid int(10) unsigned NOT NULL,
|
| 59 |
rid int(10) unsigned NOT NULL,
|
| 60 |
action tinyint(1) NOT NULL,
|
| 61 |
uid int(10) unsigned NOT NULL,
|
| 62 |
stamp int(10) unsigned NOT NULL,
|
| 63 |
KEY aid (aid)
|
| 64 |
) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
|
| 65 |
|
| 66 |
return $items;
|
| 67 |
}
|