diff --git a/database/new/mysql.sql b/database/new/mysql.sql index 45d52dc..16f98cf 100644 --- a/database/new/mysql.sql +++ b/database/new/mysql.sql @@ -4,11 +4,11 @@ CREATE TABLE IF NOT EXISTS `level` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -CREATE TABLE IF NOT EXISTS `level_role` ( +CREATE TABLE IF NOT EXISTS `level_permission` ( `level_id` int(11) NOT NULL, - `role` varchar(32) NOT NULL, - PRIMARY KEY (`level_id`,`role`), - CONSTRAINT `level_role_level` FOREIGN KEY (`level_id`) REFERENCES `level` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION + `permission` varchar(32) NOT NULL, + PRIMARY KEY (`level_id`,`permission`), + CONSTRAINT `level_permission_level` FOREIGN KEY (`level_id`) REFERENCES `level` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; CREATE TABLE IF NOT EXISTS `player` ( @@ -24,6 +24,13 @@ CREATE TABLE IF NOT EXISTS `player` ( CONSTRAINT `player_level` FOREIGN KEY (`level_id`) REFERENCES `level` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +CREATE TABLE IF NOT EXISTS `player_permission` ( + `player_id` int(11) NOT NULL, + `permission` varchar(32) NOT NULL, + PRIMARY KEY (`player_id`,`permission`), + CONSTRAINT `player_permission_level` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + CREATE TABLE IF NOT EXISTS `alias` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `player_id` int(10) unsigned NOT NULL, @@ -108,221 +115,221 @@ INSERT INTO `level` (`id`, `name`) VALUES (3, 'Admin'); INSERT INTO `level` (`id`, `name`) VALUES (4, 'Senior Admin'); INSERT INTO `level` (`id`, `name`) VALUES (5, 'Server Owner'); --- add roles for level 0 -INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'admintest'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'help'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'time'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'greeting'); +-- add permissions for level 0 +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'admintest'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'help'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'time'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'greeting'); --- add roles for level 1 -INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'admintest'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'help'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'time'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'greeting'); +-- add permissions for level 1 +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'admintest'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'help'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'time'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'greeting'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'listmaps'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'listsprees'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'listrules'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listmaps'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listsprees'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listrules'); --- add roles for level 2 -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'admintest'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'help'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'time'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'greeting'); +-- add permissions for level 2 +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'admintest'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'help'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'time'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'greeting'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listplayers'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listteams'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listmaps'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listsprees'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listrules'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listplayers'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listteams'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listmaps'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listsprees'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listrules'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'spec999'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'spec999'); --- add roles for level 3 -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'admintest'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'help'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'time'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'greeting'); +-- add permissions for level 3 +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'admintest'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'help'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'time'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'greeting'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listplayers'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listteams'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listmaps'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listsprees'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listrules'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listhistory'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listbans'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'liststats'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listplayers'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listteams'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listmaps'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listsprees'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listrules'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listhistory'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listbans'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'liststats'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'adminchat'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'adminchat'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'put'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'dropweapons'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'put'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'dropweapons'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'warn'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'mute'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'voicemute'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'warn'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'mute'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'voicemute'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'spec999'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'balance'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'spec999'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'balance'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'cointoss'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'pause'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'nextmap'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'restart'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'cointoss'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'pause'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'nextmap'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'restart'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'botadmin'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'botadmin'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'enablevote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'enablevote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'noinactivity'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'novote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'nocensor'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'novotelimit'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'noinactivity'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'novote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'nocensor'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'novotelimit'); --- add roles for level 4 -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'admintest'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'help'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'time'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'greeting'); +-- add permissions for level 4 +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'admintest'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'help'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'time'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'greeting'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listplayers'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listteams'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listmaps'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listsprees'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listrules'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listhistory'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listwarns'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listbans'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listaliases'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'liststats'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'finger'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listplayers'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listteams'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listmaps'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listsprees'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listrules'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listhistory'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listwarns'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listbans'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listaliases'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'liststats'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'finger'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'adminchat'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'adminchat'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'put'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'dropweapons'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'rename'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'freeze'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'disorient'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'burn'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'slap'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'gib'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'throw'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'glow'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'pants'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'pop'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'put'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'dropweapons'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'rename'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'freeze'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'disorient'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'burn'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'slap'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'gib'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'throw'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'glow'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pants'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pop'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'warn'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'mute'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'voicemute'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'kick'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'ban'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'warn'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'mute'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'voicemute'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'kick'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'ban'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'spec999'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'balance'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'lockplayers'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'lockteam'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'shuffle'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'swap'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'spec999'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'balance'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'lockplayers'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'lockteam'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'shuffle'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'swap'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'cointoss'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'pause'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'nextmap'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'restart'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'cointoss'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pause'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nextmap'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'restart'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'botadmin'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'botadmin'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'enablevote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'cancelvote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'passvote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'enablevote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'cancelvote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'passvote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'news'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'news'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'noinactivity'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'novote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'nocensor'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'nobalance'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'novotelimit'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'noreason'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'noinactivity'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'novote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nocensor'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nobalance'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'novotelimit'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'noreason'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'teamcmds'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'silentcmds'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'teamcmds'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'silentcmds'); --- add roles for level 5 -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'admintest'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'help'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'time'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'greeting'); +-- add permissions for level 5 +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'admintest'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'help'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'time'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'greeting'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listplayers'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listteams'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listmaps'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listsprees'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listrules'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listhistory'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listwarns'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listbans'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listaliases'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'liststats'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'finger'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listplayers'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listteams'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listmaps'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listsprees'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listrules'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listhistory'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listwarns'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listbans'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listaliases'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'liststats'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'finger'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'adminchat'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'adminchat'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'put'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'dropweapons'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'rename'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'freeze'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'disorient'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'burn'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'slap'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'gib'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'throw'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'glow'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'pants'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'pop'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'put'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'dropweapons'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'rename'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'freeze'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'disorient'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'burn'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'slap'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'gib'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'throw'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'glow'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pants'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pop'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'warn'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'mute'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'voicemute'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'kick'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'ban'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'warn'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'mute'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'voicemute'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'kick'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'ban'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'spec999'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'balance'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'lockplayers'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'lockteam'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'shuffle'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'swap'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'spec999'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'balance'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'lockplayers'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'lockteam'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'shuffle'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'swap'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'cointoss'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'pause'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'nextmap'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'restart'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'cointoss'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pause'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nextmap'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'restart'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'botadmin'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'botadmin'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'enablevote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'cancelvote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'passvote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'enablevote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'cancelvote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'passvote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'news'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'news'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'uptime'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'setlevel'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'readconfig'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'uptime'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'setlevel'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'readconfig'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'noinactivity'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'novote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'nocensor'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'nobalance'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'novotelimit'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'noreason'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'perma'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'noinactivity'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'novote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nocensor'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nobalance'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'novotelimit'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'noreason'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'perma'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'teamcmds'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'silentcmds'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'teamcmds'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'silentcmds'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'spy'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'spy'); -- add console to players table INSERT INTO `player` (`id`, `guid`, `ip`) VALUES (1, 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', '127.0.0.1'); diff --git a/database/new/sqlite.sql b/database/new/sqlite.sql index fdd0101..f91d005 100644 --- a/database/new/sqlite.sql +++ b/database/new/sqlite.sql @@ -3,11 +3,11 @@ CREATE TABLE IF NOT EXISTS `level` ( `name` TEXT NOT NULL ); -CREATE TABLE `level_role` ( +CREATE TABLE `level_permission` ( `level_id` INTEGER NOT NULL, - `role` TEXT NOT NULL, - PRIMARY KEY (`level_id`, `role`), - CONSTRAINT `role_level` FOREIGN KEY (`level_id`) REFERENCES `level` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION + `permission` TEXT NOT NULL, + PRIMARY KEY (`level_id`, `permission`), + CONSTRAINT `level_permission_level` FOREIGN KEY (`level_id`) REFERENCES `level` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ); CREATE TABLE IF NOT EXISTS `player` ( @@ -20,6 +20,13 @@ CREATE TABLE IF NOT EXISTS `player` ( CONSTRAINT `player_level` FOREIGN KEY (`level_id`) REFERENCES `level` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ); +CREATE TABLE `player_permission` ( + `player_id` INTEGER NOT NULL, + `permission` TEXT NOT NULL, + PRIMARY KEY (`player_id`, `permission`), + CONSTRAINT `player_permission_player` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION +); + CREATE TABLE IF NOT EXISTS `alias` ( `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, `player_id` INTEGER NOT NULL, @@ -106,232 +113,232 @@ INSERT INTO `level` (`id`, `name`) VALUES (4, 'Senior Admin'); INSERT INTO `level` (`id`, `name`) VALUES (5, 'Server Owner'); COMMIT; --- add roles for level 0 +-- add permissions for level 0 BEGIN; -INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'admintest'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'help'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'time'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'greeting'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'admintest'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'help'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'time'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'greeting'); COMMIT; --- add roles for level 1 +-- add permissions for level 1 BEGIN; -INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'admintest'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'help'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'time'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'greeting'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'admintest'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'help'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'time'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'greeting'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'listmaps'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'listsprees'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'listrules'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listmaps'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listsprees'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listrules'); COMMIT; --- add roles for level 2 +-- add permissions for level 2 BEGIN; -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'admintest'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'help'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'time'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'greeting'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'admintest'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'help'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'time'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'greeting'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listplayers'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listteams'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listmaps'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listsprees'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listrules'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listplayers'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listteams'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listmaps'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listsprees'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listrules'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'spec999'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'spec999'); COMMIT; --- add roles for level 3 +-- add permissions for level 3 BEGIN; -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'admintest'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'help'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'time'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'greeting'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'admintest'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'help'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'time'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'greeting'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listplayers'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listteams'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listmaps'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listsprees'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listrules'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listhistory'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listbans'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'liststats'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listplayers'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listteams'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listmaps'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listsprees'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listrules'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listhistory'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listbans'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'liststats'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'adminchat'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'adminchat'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'put'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'dropweapons'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'put'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'dropweapons'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'warn'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'mute'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'voicemute'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'warn'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'mute'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'voicemute'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'spec999'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'balance'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'spec999'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'balance'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'cointoss'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'pause'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'nextmap'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'restart'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'cointoss'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'pause'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'nextmap'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'restart'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'botadmin'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'botadmin'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'enablevote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'enablevote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'noinactivity'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'novote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'nocensor'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'novotelimit'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'noinactivity'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'novote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'nocensor'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'novotelimit'); COMMIT; --- add roles for level 4 +-- add permissions for level 4 BEGIN; -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'admintest'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'help'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'time'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'greeting'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'admintest'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'help'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'time'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'greeting'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listplayers'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listteams'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listmaps'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listsprees'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listrules'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listhistory'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listwarns'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listbans'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listaliases'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'liststats'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'finger'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listplayers'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listteams'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listmaps'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listsprees'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listrules'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listhistory'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listwarns'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listbans'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listaliases'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'liststats'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'finger'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'adminchat'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'adminchat'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'put'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'dropweapons'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'rename'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'freeze'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'disorient'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'burn'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'slap'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'gib'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'throw'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'glow'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'pants'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'pop'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'put'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'dropweapons'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'rename'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'freeze'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'disorient'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'burn'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'slap'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'gib'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'throw'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'glow'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pants'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pop'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'warn'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'mute'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'voicemute'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'kick'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'ban'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'warn'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'mute'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'voicemute'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'kick'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'ban'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'spec999'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'balance'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'lockplayers'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'lockteam'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'shuffle'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'swap'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'spec999'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'balance'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'lockplayers'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'lockteam'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'shuffle'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'swap'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'cointoss'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'pause'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'nextmap'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'restart'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'cointoss'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pause'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nextmap'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'restart'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'botadmin'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'botadmin'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'enablevote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'cancelvote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'passvote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'enablevote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'cancelvote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'passvote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'news'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'news'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'noinactivity'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'novote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'nocensor'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'nobalance'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'novotelimit'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'noreason'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'noinactivity'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'novote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nocensor'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nobalance'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'novotelimit'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'noreason'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'teamcmds'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'silentcmds'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'teamcmds'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'silentcmds'); COMMIT; --- add roles for level 5 +-- add permissions for level 5 BEGIN; -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'admintest'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'help'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'time'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'greeting'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'admintest'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'help'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'time'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'greeting'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listplayers'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listteams'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listmaps'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listsprees'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listrules'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listhistory'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listwarns'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listbans'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listaliases'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'liststats'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'finger'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listplayers'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listteams'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listmaps'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listsprees'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listrules'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listhistory'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listwarns'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listbans'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listaliases'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'liststats'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'finger'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'adminchat'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'adminchat'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'put'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'dropweapons'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'rename'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'freeze'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'disorient'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'burn'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'slap'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'gib'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'throw'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'glow'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'pants'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'pop'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'put'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'dropweapons'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'rename'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'freeze'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'disorient'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'burn'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'slap'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'gib'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'throw'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'glow'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pants'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pop'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'warn'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'mute'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'voicemute'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'kick'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'ban'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'warn'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'mute'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'voicemute'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'kick'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'ban'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'spec999'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'balance'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'lockplayers'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'lockteam'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'shuffle'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'swap'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'spec999'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'balance'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'lockplayers'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'lockteam'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'shuffle'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'swap'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'cointoss'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'pause'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'nextmap'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'restart'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'cointoss'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pause'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nextmap'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'restart'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'botadmin'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'botadmin'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'enablevote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'cancelvote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'passvote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'enablevote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'cancelvote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'passvote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'news'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'news'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'uptime'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'setlevel'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'readconfig'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'uptime'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'setlevel'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'readconfig'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'noinactivity'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'novote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'nocensor'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'nobalance'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'novotelimit'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'noreason'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'perma'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'noinactivity'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'novote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nocensor'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nobalance'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'novotelimit'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'noreason'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'perma'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'teamcmds'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'silentcmds'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'teamcmds'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'silentcmds'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'spy'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'spy'); COMMIT; -- add console to players table diff --git a/database/upgrade/1.1.0/mysql.sql b/database/upgrade/1.1.0/mysql.sql index 785d6c7..6585772 100644 --- a/database/upgrade/1.1.0/mysql.sql +++ b/database/upgrade/1.1.0/mysql.sql @@ -40,13 +40,20 @@ CREATE TABLE IF NOT EXISTS `level` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -CREATE TABLE IF NOT EXISTS `level_role` ( +CREATE TABLE IF NOT EXISTS `level_permission` ( `level_id` int(11) NOT NULL, - `role` varchar(32) NOT NULL, - PRIMARY KEY (`level_id`,`role`), - CONSTRAINT `level_role_level` FOREIGN KEY (`level_id`) REFERENCES `level` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION + `permission` varchar(32) NOT NULL, + PRIMARY KEY (`level_id`,`permission`), + CONSTRAINT `level_permission_level` FOREIGN KEY (`level_id`) REFERENCES `level` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=latin1; +CREATE TABLE IF NOT EXISTS `player_permission` ( + `player_id` int(11) NOT NULL, + `permission` varchar(32) NOT NULL, + PRIMARY KEY (`player_id`,`permission`), + CONSTRAINT `player_permission_level` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + -- populate acl -- add levels INSERT INTO `level` (`id`, `name`) VALUES (0, 'Guest'); @@ -56,221 +63,221 @@ INSERT INTO `level` (`id`, `name`) VALUES (3, 'Admin'); INSERT INTO `level` (`id`, `name`) VALUES (4, 'Senior Admin'); INSERT INTO `level` (`id`, `name`) VALUES (5, 'Server Owner'); --- add roles for level 0 -INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'admintest'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'help'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'time'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'greeting'); +-- add permissions for level 0 +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'admintest'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'help'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'time'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'greeting'); --- add roles for level 1 -INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'admintest'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'help'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'time'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'greeting'); +-- add permissions for level 1 +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'admintest'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'help'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'time'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'greeting'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'listmaps'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'listsprees'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'listrules'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listmaps'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listsprees'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listrules'); --- add roles for level 2 -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'admintest'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'help'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'time'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'greeting'); +-- add permissions for level 2 +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'admintest'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'help'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'time'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'greeting'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listplayers'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listteams'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listmaps'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listsprees'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listrules'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listplayers'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listteams'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listmaps'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listsprees'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listrules'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'spec999'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'spec999'); --- add roles for level 3 -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'admintest'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'help'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'time'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'greeting'); +-- add permissions for level 3 +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'admintest'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'help'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'time'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'greeting'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listplayers'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listteams'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listmaps'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listsprees'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listrules'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listhistory'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listbans'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'liststats'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listplayers'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listteams'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listmaps'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listsprees'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listrules'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listhistory'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listbans'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'liststats'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'adminchat'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'adminchat'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'put'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'dropweapons'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'put'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'dropweapons'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'warn'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'mute'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'voicemute'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'warn'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'mute'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'voicemute'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'spec999'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'balance'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'spec999'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'balance'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'cointoss'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'pause'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'nextmap'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'restart'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'cointoss'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'pause'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'nextmap'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'restart'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'botadmin'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'botadmin'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'enablevote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'enablevote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'noinactivity'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'novote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'nocensor'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'novotelimit'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'noinactivity'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'novote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'nocensor'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'novotelimit'); --- add roles for level 4 -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'admintest'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'help'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'time'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'greeting'); +-- add permissions for level 4 +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'admintest'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'help'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'time'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'greeting'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listplayers'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listteams'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listmaps'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listsprees'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listrules'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listhistory'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listwarns'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listbans'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listaliases'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'liststats'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'finger'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listplayers'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listteams'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listmaps'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listsprees'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listrules'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listhistory'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listwarns'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listbans'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listaliases'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'liststats'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'finger'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'adminchat'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'adminchat'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'put'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'dropweapons'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'rename'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'freeze'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'disorient'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'burn'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'slap'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'gib'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'throw'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'glow'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'pants'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'pop'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'put'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'dropweapons'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'rename'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'freeze'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'disorient'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'burn'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'slap'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'gib'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'throw'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'glow'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pants'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pop'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'warn'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'mute'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'voicemute'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'kick'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'ban'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'warn'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'mute'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'voicemute'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'kick'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'ban'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'spec999'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'balance'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'lockplayers'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'lockteam'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'shuffle'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'swap'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'spec999'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'balance'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'lockplayers'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'lockteam'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'shuffle'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'swap'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'cointoss'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'pause'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'nextmap'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'restart'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'cointoss'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pause'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nextmap'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'restart'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'botadmin'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'botadmin'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'enablevote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'cancelvote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'passvote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'enablevote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'cancelvote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'passvote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'news'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'news'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'noinactivity'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'novote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'nocensor'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'nobalance'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'novotelimit'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'noreason'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'noinactivity'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'novote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nocensor'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nobalance'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'novotelimit'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'noreason'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'teamcmds'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'silentcmds'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'teamcmds'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'silentcmds'); --- add roles for level 5 -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'admintest'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'help'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'time'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'greeting'); +-- add permissions for level 5 +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'admintest'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'help'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'time'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'greeting'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listplayers'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listteams'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listmaps'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listsprees'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listrules'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listhistory'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listwarns'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listbans'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listaliases'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'liststats'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'finger'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listplayers'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listteams'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listmaps'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listsprees'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listrules'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listhistory'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listwarns'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listbans'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listaliases'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'liststats'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'finger'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'adminchat'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'adminchat'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'put'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'dropweapons'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'rename'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'freeze'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'disorient'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'burn'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'slap'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'gib'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'throw'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'glow'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'pants'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'pop'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'put'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'dropweapons'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'rename'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'freeze'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'disorient'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'burn'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'slap'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'gib'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'throw'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'glow'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pants'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pop'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'warn'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'mute'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'voicemute'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'kick'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'ban'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'warn'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'mute'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'voicemute'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'kick'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'ban'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'spec999'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'balance'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'lockplayers'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'lockteam'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'shuffle'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'swap'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'spec999'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'balance'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'lockplayers'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'lockteam'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'shuffle'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'swap'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'cointoss'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'pause'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'nextmap'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'restart'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'cointoss'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pause'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nextmap'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'restart'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'botadmin'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'botadmin'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'enablevote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'cancelvote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'passvote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'enablevote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'cancelvote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'passvote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'news'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'news'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'uptime'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'setlevel'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'readconfig'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'uptime'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'setlevel'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'readconfig'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'noinactivity'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'novote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'nocensor'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'nobalance'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'novotelimit'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'noreason'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'perma'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'noinactivity'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'novote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nocensor'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nobalance'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'novotelimit'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'noreason'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'perma'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'teamcmds'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'silentcmds'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'teamcmds'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'silentcmds'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'spy'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'spy'); -- update player table ALTER TABLE `player` diff --git a/database/upgrade/1.1.0/sqlite.sql b/database/upgrade/1.1.0/sqlite.sql index 945820f..8ed20dc 100644 --- a/database/upgrade/1.1.0/sqlite.sql +++ b/database/upgrade/1.1.0/sqlite.sql @@ -27,11 +27,18 @@ CREATE TABLE IF NOT EXISTS `level` ( `name` TEXT NOT NULL ); -CREATE TABLE `level_role` ( +CREATE TABLE `level_permission` ( `level_id` INTEGER NOT NULL, - `role` TEXT NOT NULL, - PRIMARY KEY (`level_id`, `role`), - CONSTRAINT `role_level` FOREIGN KEY (`level_id`) REFERENCES `level` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION + `permission` TEXT NOT NULL, + PRIMARY KEY (`level_id`, `permission`), + CONSTRAINT `level_permission_level` FOREIGN KEY (`level_id`) REFERENCES `level` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION +); + +CREATE TABLE `player_permission` ( + `player_id` INTEGER NOT NULL, + `permission` TEXT NOT NULL, + PRIMARY KEY (`player_id`, `permission`), + CONSTRAINT `player_permission_player` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ); -- populate acl @@ -45,232 +52,232 @@ INSERT INTO `level` (`id`, `name`) VALUES (4, 'Senior Admin'); INSERT INTO `level` (`id`, `name`) VALUES (5, 'Server Owner'); COMMIT; --- add roles for level 0 +-- add permissions for level 0 BEGIN; -INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'admintest'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'help'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'time'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'greeting'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'admintest'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'help'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'time'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'greeting'); COMMIT; --- add roles for level 1 +-- add permissions for level 1 BEGIN; -INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'admintest'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'help'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'time'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'greeting'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'admintest'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'help'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'time'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'greeting'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'listmaps'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'listsprees'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'listrules'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listmaps'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listsprees'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listrules'); COMMIT; --- add roles for level 2 +-- add permissions for level 2 BEGIN; -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'admintest'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'help'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'time'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'greeting'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'admintest'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'help'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'time'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'greeting'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listplayers'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listteams'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listmaps'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listsprees'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listrules'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listplayers'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listteams'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listmaps'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listsprees'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listrules'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'spec999'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'spec999'); COMMIT; --- add roles for level 3 +-- add permissions for level 3 BEGIN; -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'admintest'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'help'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'time'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'greeting'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'admintest'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'help'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'time'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'greeting'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listplayers'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listteams'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listmaps'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listsprees'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listrules'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listhistory'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listbans'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'liststats'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listplayers'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listteams'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listmaps'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listsprees'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listrules'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listhistory'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listbans'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'liststats'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'adminchat'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'adminchat'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'put'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'dropweapons'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'put'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'dropweapons'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'warn'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'mute'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'voicemute'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'warn'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'mute'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'voicemute'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'spec999'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'balance'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'spec999'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'balance'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'cointoss'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'pause'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'nextmap'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'restart'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'cointoss'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'pause'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'nextmap'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'restart'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'botadmin'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'botadmin'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'enablevote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'enablevote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'noinactivity'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'novote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'nocensor'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'novotelimit'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'noinactivity'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'novote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'nocensor'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'novotelimit'); COMMIT; --- add roles for level 4 +-- add permissions for level 4 BEGIN; -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'admintest'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'help'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'time'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'greeting'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'admintest'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'help'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'time'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'greeting'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listplayers'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listteams'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listmaps'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listsprees'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listrules'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listhistory'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listwarns'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listbans'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listaliases'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'liststats'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'finger'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listplayers'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listteams'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listmaps'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listsprees'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listrules'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listhistory'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listwarns'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listbans'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listaliases'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'liststats'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'finger'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'adminchat'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'adminchat'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'put'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'dropweapons'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'rename'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'freeze'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'disorient'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'burn'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'slap'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'gib'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'throw'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'glow'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'pants'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'pop'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'put'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'dropweapons'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'rename'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'freeze'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'disorient'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'burn'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'slap'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'gib'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'throw'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'glow'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pants'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pop'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'warn'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'mute'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'voicemute'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'kick'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'ban'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'warn'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'mute'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'voicemute'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'kick'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'ban'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'spec999'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'balance'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'lockplayers'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'lockteam'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'shuffle'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'swap'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'spec999'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'balance'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'lockplayers'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'lockteam'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'shuffle'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'swap'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'cointoss'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'pause'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'nextmap'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'restart'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'cointoss'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pause'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nextmap'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'restart'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'botadmin'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'botadmin'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'enablevote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'cancelvote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'passvote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'enablevote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'cancelvote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'passvote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'news'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'news'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'noinactivity'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'novote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'nocensor'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'nobalance'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'novotelimit'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'noreason'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'noinactivity'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'novote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nocensor'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nobalance'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'novotelimit'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'noreason'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'teamcmds'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'silentcmds'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'teamcmds'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'silentcmds'); COMMIT; --- add roles for level 5 +-- add permissions for level 5 BEGIN; -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'admintest'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'help'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'time'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'greeting'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'admintest'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'help'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'time'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'greeting'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listplayers'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listteams'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listmaps'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listsprees'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listrules'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listhistory'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listwarns'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listbans'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listaliases'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'liststats'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'finger'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listplayers'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listteams'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listmaps'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listsprees'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listrules'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listhistory'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listwarns'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listbans'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listaliases'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'liststats'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'finger'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'adminchat'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'adminchat'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'put'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'dropweapons'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'rename'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'freeze'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'disorient'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'burn'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'slap'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'gib'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'throw'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'glow'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'pants'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'pop'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'put'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'dropweapons'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'rename'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'freeze'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'disorient'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'burn'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'slap'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'gib'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'throw'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'glow'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pants'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pop'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'warn'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'mute'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'voicemute'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'kick'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'ban'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'warn'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'mute'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'voicemute'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'kick'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'ban'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'spec999'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'balance'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'lockplayers'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'lockteam'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'shuffle'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'swap'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'spec999'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'balance'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'lockplayers'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'lockteam'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'shuffle'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'swap'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'cointoss'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'pause'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'nextmap'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'restart'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'cointoss'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pause'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nextmap'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'restart'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'botadmin'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'botadmin'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'enablevote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'cancelvote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'passvote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'enablevote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'cancelvote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'passvote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'news'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'news'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'uptime'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'setlevel'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'readconfig'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'uptime'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'setlevel'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'readconfig'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'noinactivity'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'novote'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'nocensor'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'nobalance'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'novotelimit'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'noreason'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'perma'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'noinactivity'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'novote'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nocensor'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nobalance'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'novotelimit'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'noreason'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'perma'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'teamcmds'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'silentcmds'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'teamcmds'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'silentcmds'); -INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'spy'); +INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'spy'); COMMIT; -- update player table diff --git a/luamods/wolfadmin/auth/acl.lua b/luamods/wolfadmin/auth/acl.lua index 8c45d49..a47f2f9 100644 --- a/luamods/wolfadmin/auth/acl.lua +++ b/luamods/wolfadmin/auth/acl.lua @@ -19,11 +19,32 @@ local db = require (wolfa_getLuaPath()..".db.db") local players = require (wolfa_getLuaPath()..".players.players") +local events = require (wolfa_getLuaPath()..".util.events") +local settings = require (wolfa_getLuaPath()..".util.settings") local tables = require (wolfa_getLuaPath()..".util.tables") local acl = {} -local data = {} +local cachedLevels = {} +local cachedClients = {} + +function acl.onClientConnect(clientId, firstTime, isBot) + if settings.get("g_standalone") ~= 0 and settings.get("db_type") ~= "none" then + local guid = et.Info_ValueForKey(et.trap_GetUserinfo(clientId), "cl_guid") + local player = db.getPlayer(guid) + + if player then + cachedClients[clientId] = {} + + local permissions = db.getPlayerPermissions(player["id"]) + + for _, permission in ipairs(permissions) do + table.insert(cachedClients[clientId], permission["permission"]) + end + end + end +end +events.handle("onClientConnect", acl.onClientConnect) function acl.readPermissions() -- read level permissions into a cache file (can be loaded at mod start) @@ -32,24 +53,24 @@ function acl.readPermissions() local levels = db.getLevelsWithIds() for _, level in ipairs(levels) do - data[level["id"]] = {} + cachedLevels[level["id"]] = {} end - local roles = db.getLevelRoles() + local permissions = db.getLevelPermissions() - for _, role in ipairs(roles) do - table.insert(data[role["level_id"]], role["role"]) + for _, permission in ipairs(permissions) do + table.insert(cachedLevels[permission["level_id"]], permission["permission"]) end end function acl.clearCache() - data = {} + cachedLevels = {} end -function acl.isPlayerAllowed(clientId, permission) +function acl.isPlayerAllowed(clientId, permission, playerOnly) local level = acl.getPlayerLevel(clientId) - return data[level] ~= nil and tables.contains(data[level], permission) + return (not playerOnly and acl.isLevelAllowed(level, permission)) or (cachedClients[clientId] ~= nil and tables.contains(cachedClients[clientId], permission)) end function acl.getLevels() @@ -63,65 +84,97 @@ end function acl.addLevel(levelId, name) db.addLevel(levelId, name) - data[levelId] = {} + cachedLevels[levelId] = {} end function acl.removeLevel(levelId) db.removeLevel(levelId) - data[levelId] = nil + cachedLevels[levelId] = nil end function acl.reLevel(levelId, newLevelId) db.reLevel(levelId, newLevelId) end -function acl.getLevelRoles(levelId) - return data[levelId] -end - -function acl.isLevelAllowed(levelId, role) - return tables.contains(data[levelId], role) -end - -function acl.addLevelRole(levelId, role) - db.addLevelRole(levelId, role) - - table.insert(data[levelId], role) -end - -function acl.removeLevelRole(levelId, role) - db.removeLevelRole(levelId, role) - - for i, levelRole in ipairs(data[levelId]) do - if levelRole == role then - table.remove(data[levelId], i) - end - end -end - -function acl.copyLevelRoles(levelId, newLevelId) - db.copyLevelRoles(levelId, newLevelId) - - data[newLevelId] = tables.copy(data[levelId]) -end - -function acl.removeLevelRoles(levelId) - db.removeLevelRoles(levelId) - - data[levelId] = {} -end - -function acl.getPlayerLevel(clientId) - local player = db.getPlayer(players.getGUID(clientId)) - - return player["level_id"] -end - function acl.getLevelName(levelId) local level = db.getLevel(levelId) return level["name"] end +function acl.getLevelPermissions(levelId) + return cachedLevels[levelId] +end + +function acl.addLevelPermission(levelId, permission) + db.addLevelPermission(levelId, permission) + + table.insert(cachedLevels[levelId], permission) +end + +function acl.removeLevelPermission(levelId, permission) + db.removeLevelPermission(levelId, permission) + + for i, levelPermission in ipairs(cachedLevels[levelId]) do + if levelPermission == permission then + table.remove(cachedLevels[levelId], i) + end + end +end + +function acl.copyLevelPermissions(levelId, newLevelId) + db.copyLevelPermissions(levelId, newLevelId) + + cachedLevels[newLevelId] = tables.copy(cachedLevels[levelId]) +end + +function acl.removeLevelPermissions(levelId) + db.removeLevelPermissions(levelId) + + cachedLevels[levelId] = {} +end + +function acl.isLevelAllowed(levelId, permission) + return cachedLevels[levelId] ~= nil and tables.contains(cachedLevels[levelId], permission) +end + +function acl.getPlayerPermissions(clientId) + return cachedClients[clientId] +end + +function acl.addPlayerPermission(clientId, permission) + db.addPlayerPermission(db.getPlayerId(clientId), permission) + + table.insert(cachedClients[clientId], permission) +end + +function acl.removePlayerPermission(clientId, permission) + db.removePlayerPermission(db.getPlayerId(clientId), permission) + + for i, levelPermission in ipairs(cachedClients[clientId]) do + if levelPermission == permission then + table.remove(cachedClients[clientId], i) + end + end +end + +function acl.copyPlayerPermissions(clientId, newClientId) + db.copyPlayerPermissions(db.getPlayerId(clientId), db.getPlayerId(newClientId)) + + cachedClients[newClientId] = tables.copy(cachedClients[clientId]) +end + +function acl.removePlayerPermissions(clientId) + db.removePlayerPermissions(db.getPlayerId(clientId)) + + cachedClients[clientId] = {} +end + +function acl.getPlayerLevel(clientId) + local player = db.getPlayer(players.getGUID(clientId)) + + return player["level_id"] +end + return acl diff --git a/luamods/wolfadmin/auth/shrubbot.lua b/luamods/wolfadmin/auth/shrubbot.lua index 8f8e373..fff9f8a 100644 --- a/luamods/wolfadmin/auth/shrubbot.lua +++ b/luamods/wolfadmin/auth/shrubbot.lua @@ -17,6 +17,8 @@ local shrubbot = {} +local players = require (wolfa_getLuaPath()..".players.players") + local flags function shrubbot.loadFlags(mod) @@ -37,4 +39,88 @@ function shrubbot.getPlayerLevel(clientId) return et.G_shrubbot_level(clientId) end +function shrubbot.addPlayerPermission(clientId, permission) + local fileName = et.trap_Cvar_Get("g_shrubbot") + local fileDescriptor, fileLength = et.trap_FS_FOpenFile(fileName, et.FS_READ) + + if fileLength == -1 then + error("failed to open "..fileName.."\n") + end + + local fileString = et.trap_FS_Read(fileDescriptor, fileLength) + + et.trap_FS_FCloseFile(fileDescriptor) + + for _, adminName, adminGUID, adminLevel, adminFlags in string.gmatch(fileString, "(%[admin%]\nname%s+=%s+([%a%d%p]+)\nguid%s+=%s+([%u%d]+)\nlevel%s+=%s+([%d]+)\nflags%s+=%s+([%a%d%p]*)\n\n)") do + -- et.G_Print(string.format("%s %s %d %s\n", adminName, adminGUID, adminLevel, adminFlags)) + + if players.getGUID(clientId) == adminGUID then + if not auth.isPlayerAllowed(clientId, flags[permission]) then + adminFlags = adminFlags.."+"..flags[permission] + end + + local adminNameEscaped = string.gsub(adminName, "([%*%+%-%?%^%$%%%[%]%(%)%.])", "%%%1") -- fix for special captures + fileString = string.gsub(fileString, "%[admin%]\nname%s+=%s+"..adminNameEscaped.."\nguid%s+=%s+"..adminGUID.."\nlevel%s+=%s+"..adminLevel.."\nflags%s+=%s+([%a%d%p]*)\n\n", "[admin]\nname = "..adminName.."\nguid = "..adminGUID.."\nlevel = "..adminLevel.."\nflags = "..adminFlags.."\n\n") + + break + end + end + + local fileDescriptor, _ = et.trap_FS_FOpenFile(fileName, et.FS_WRITE) + + local writeCount = et.trap_FS_Write(fileString, string.len(fileString), fileDescriptor) + + if not writeCount or writeCount < 1 then + error("failed to write "..fileName.."\n") + end + + et.trap_FS_FCloseFile(fileDescriptor) + + et.trap_SendConsoleCommand(et.EXEC_APPEND, "readconfig;") +end + +function shrubbot.removePlayerPermission(clientId, permission) + local fileName = et.trap_Cvar_Get("g_shrubbot") + local fileDescriptor, fileLength = et.trap_FS_FOpenFile(fileName, et.FS_READ) + + if fileLength == -1 then + error("failed to open "..fileName.."\n") + end + + local fileString = et.trap_FS_Read(fileDescriptor, fileLength) + + et.trap_FS_FCloseFile(fileDescriptor) + + for _, adminName, adminGUID, adminLevel, adminFlags in string.gmatch(fileString, "(%[admin%]\nname%s+=%s+([%a%d%p]+)\nguid%s+=%s+([%u%d]+)\nlevel%s+=%s+([%d]+)\nflags%s+=%s+([%a%d%p]*)\n\n)") do + -- et.G_Print(string.format("%s %s %d %s\n", adminName, adminGUID, adminLevel, adminFlags)) + + if players.getGUID(clientId) == adminGUID then + if string.find(adminFlags, "+"..flags[permission]) then + adminFlags = string.gsub(adminFlags, "+"..flags[permission], "") + elseif string.find(adminFlags, flags[permission]) then + adminFlags = string.gsub(adminFlags, flags[permission], "") + else + adminFlags = adminFlags.."-"..flags[permission] + end + + local adminNameEscaped = string.gsub(adminName, "([%*%+%-%?%^%$%%%[%]%(%)%.])", "%%%1") -- fix for special captures + fileString = string.gsub(fileString, "%[admin%]\nname%s+=%s+"..adminNameEscaped.."\nguid%s+=%s+"..adminGUID.."\nlevel%s+=%s+"..adminLevel.."\nflags%s+=%s+([%a%d%p]*)\n\n", "[admin]\nname = "..adminName.."\nguid = "..adminGUID.."\nlevel = "..adminLevel.."\nflags = "..adminFlags.."\n\n") + + break + end + end + + local fileDescriptor, _ = et.trap_FS_FOpenFile(fileName, et.FS_WRITE) + + local writeCount = et.trap_FS_Write(fileString, string.len(fileString), fileDescriptor) + + if not writeCount or writeCount < 1 then + error("failed to write "..fileName.."\n") + end + + et.trap_FS_FCloseFile(fileDescriptor) + + et.trap_SendConsoleCommand(et.EXEC_APPEND, "readconfig;") +end + return shrubbot diff --git a/luamods/wolfadmin/commands/server/acl.lua b/luamods/wolfadmin/commands/server/acl.lua index 83b4b5b..64ba131 100644 --- a/luamods/wolfadmin/commands/server/acl.lua +++ b/luamods/wolfadmin/commands/server/acl.lua @@ -54,7 +54,7 @@ function commandAclRemoveLevel(levelId) return true end - acl.removeLevelRoles(levelId) + acl.removeLevelPermissions(levelId) acl.removeLevel(levelId) et.G_Print("removed level "..levelId.."\n") @@ -75,99 +75,99 @@ function commandAclReLevel(levelId, newLevelId) et.G_Print("releveled all players with "..levelId.." to "..newLevelId.."\n") end -function commandAclListLevelRoles(levelId) +function commandAclListLevelPermissions(levelId) local levelId = tonumber(levelId) if not levelId or not acl.isLevel(levelId) then - et.G_Print("usage: acl listroles [id]\n") + et.G_Print("usage: acl listpermissions [id]\n") return true end - et.G_Print("roles for level "..levelId..":\n") + et.G_Print("permissions for level "..levelId..":\n") - for _, role in ipairs(acl.getLevelRoles(levelId)) do - et.G_Print(role.."\n") + for _, permission in ipairs(acl.getLevelPermissions(levelId)) do + et.G_Print(permission.."\n") end end -function commandAclIsAllowed(levelId, role) +function commandAclIsAllowed(levelId, permission) local levelId = tonumber(levelId) - if not levelId or not acl.isLevel(levelId) or not role then - et.G_Print("usage: acl isallowed [id] [role]\n") + if not levelId or not acl.isLevel(levelId) or not permission then + et.G_Print("usage: acl isallowed [id] [permission]\n") return true end - local isAllowed = acl.isLevelAllowed(levelId, role) + local isAllowed = acl.isLevelAllowed(levelId, permission) - et.G_Print("level "..levelId.." "..(isAllowed and "HAS" or "HAS NOT").." "..role.."\n") + et.G_Print("level "..levelId.." "..(isAllowed and "HAS" or "HAS NOT").." "..permission.."\n") end -function commandAclAddLevelRole(levelId, role) +function commandAclAddLevelPermission(levelId, permission) local levelId = tonumber(levelId) - if not levelId or not acl.isLevel(levelId) or not role then - et.G_Print("usage: acl addrole [id] [role]\n") + if not levelId or not acl.isLevel(levelId) or not permission then + et.G_Print("usage: acl addpermission [id] [permission]\n") return true end - local isAllowed = acl.isLevelAllowed(levelId, role) + local isAllowed = acl.isLevelAllowed(levelId, permission) if isAllowed then - et.G_Print("error: level "..levelId.." already has '"..role.."'\n") + et.G_Print("error: level "..levelId.." already has '"..permission.."'\n") return true end - acl.addLevelRole(levelId, role) + acl.addLevelPermission(levelId, permission) - et.G_Print("added role "..role.." to level "..levelId.."\n") + et.G_Print("added permission "..permission.." to level "..levelId.."\n") end -function commandAclRemoveLevelRole(levelId, role) +function commandAclRemoveLevelPermission(levelId, permission) local levelId = tonumber(levelId) - if not levelId or not acl.isLevel(levelId) or not role then - et.G_Print("usage: acl removerole [id] [role]\n") + if not levelId or not acl.isLevel(levelId) or not permission then + et.G_Print("usage: acl removepermission [id] [permission]\n") return true end - local isAllowed = acl.isLevelAllowed(levelId, role) + local isAllowed = acl.isLevelAllowed(levelId, permission) if not isAllowed then - et.G_Print("error: level "..levelId.." does not have '"..role.."'\n") + et.G_Print("error: level "..levelId.." does not have '"..permission.."'\n") return true end - acl.removeLevelRole(levelId, role) + acl.removeLevelPermission(levelId, permission) - et.G_Print("removed role "..role.." from level "..levelId.."\n") + et.G_Print("removed permission "..permission.." from level "..levelId.."\n") end -function commandAclCopyLevelRoles(levelId, newLevelId) +function commandAclCopyLevelPermissions(levelId, newLevelId) local levelId = tonumber(levelId) local newLevelId = tonumber(newLevelId) if not levelId or not acl.isLevel(levelId) or not newLevelId or not acl.isLevel(newLevelId) then - et.G_Print("usage: acl copyroles [id] [newid]\n") + et.G_Print("usage: acl copypermissions [id] [newid]\n") return true end - if #acl.getLevelRoles(newLevelId) ~= 0 then - et.G_Print("error: level "..newLevelId.." already has roles\n") + if #acl.getLevelPermissions(newLevelId) ~= 0 then + et.G_Print("error: level "..newLevelId.." already has permissions\n") return true end - acl.copyLevelRoles(levelId, newLevelId) + acl.copyLevelPermissions(levelId, newLevelId) - et.G_Print("copied roles from "..levelId.." to "..newLevelId.."\n") + et.G_Print("copied permissions from "..levelId.." to "..newLevelId.."\n") end function commandAcl(command, action, ...) @@ -179,18 +179,18 @@ function commandAcl(command, action, ...) return commandAclRemoveLevel(...) elseif action == "relevel" then return commandAclReLevel(...) - elseif action == "listroles" then - return commandAclListLevelRoles(...) + elseif action == "listpermissions" then + return commandAclListLevelPermissions(...) elseif action == "isallowed" then return commandAclIsAllowed(...) - elseif action == "addrole" then - return commandAclAddLevelRole(...) - elseif action == "removerole" then - return commandAclRemoveLevelRole(...) - elseif action == "copyroles" then - return commandAclCopyLevelRoles(...) + elseif action == "addpermission" then + return commandAclAddLevelPermission(...) + elseif action == "removepermission" then + return commandAclRemoveLevelPermission(...) + elseif action == "copypermissions" then + return commandAclCopyLevelPermissions(...) else - et.G_Print("usage: acl [listlevels|addlevel|removelevel|relevel|listroles|isallowed|addrole|removerole|copyroles]") + et.G_Print("usage: acl [listlevels|addlevel|removelevel|relevel|listpermissions|isallowed|addpermission|removepermission|copypermissions]") end return true diff --git a/luamods/wolfadmin/db/mysql.lua b/luamods/wolfadmin/db/mysql.lua index d107269..515140d 100644 --- a/luamods/wolfadmin/db/mysql.lua +++ b/luamods/wolfadmin/db/mysql.lua @@ -143,36 +143,68 @@ function mysql.getLevel(id) end -- acl -function mysql.getLevelRoles() - cur = assert(con:execute("SELECT * FROM `level_role`")) +function mysql.getLevelPermissions() + cur = assert(con:execute("SELECT * FROM `level_permission`")) - local roles = {} + local permissions = {} local row = cur:fetch({}, "a") while row do - table.insert(roles, tables.copy(row)) + table.insert(permissions, tables.copy(row)) row = cur:fetch(row, "a") end cur:close() - return roles + return permissions end -function mysql.addLevelRole(levelId, role) - cur = assert(con:execute("INSERT INTO `level_role` (`level_id`, `role`) VALUES ("..tonumber(levelId)..", '"..util.escape(role).."')")) +function mysql.addLevelPermission(levelId, permission) + cur = assert(con:execute("INSERT INTO `level_permission` (`level_id`, `permission`) VALUES ("..tonumber(levelId)..", '"..util.escape(permission).."')")) end -function mysql.removeLevelRole(levelId, role) - cur = assert(con:execute("DELETE FROM `level_role` WHERE `level_id`="..tonumber(levelId).." AND role='"..util.escape(role).."'")) +function mysql.removeLevelPermission(levelId, permission) + cur = assert(con:execute("DELETE FROM `level_permission` WHERE `level_id`="..tonumber(levelId).." AND permission='"..util.escape(permission).."'")) end -function mysql.copyLevelRoles(levelId, newLevelId) - cur = assert(con:execute("INSERT INTO `level_role` (`level_id`, `role`) SELECT '"..tonumber(newLevelId).."' AS `level_id`, `role` FROM `level_role` WHERE `level_id`="..tonumber(levelId))) +function mysql.copyLevelPermissions(levelId, newLevelId) + cur = assert(con:execute("INSERT INTO `level_permission` (`level_id`, `permission`) SELECT '"..tonumber(newLevelId).."' AS `level_id`, `permission` FROM `level_permission` WHERE `level_id`="..tonumber(levelId))) end -function mysql.removeLevelRoles(levelId) - cur = assert(con:execute("DELETE FROM `level_role` WHERE `level_id`="..tonumber(levelId).."")) +function mysql.removeLevelPermissions(levelId) + cur = assert(con:execute("DELETE FROM `level_permission` WHERE `level_id`="..tonumber(levelId).."")) +end + +function mysql.getPlayerPermissions() + cur = assert(con:execute("SELECT * FROM `player_permission`")) + + local permissions = {} + local row = cur:fetch({}, "a") + + while row do + table.insert(permissions, tables.copy(row)) + row = cur:fetch(row, "a") + end + + cur:close() + + return permissions +end + +function mysql.addPlayerPermission(playerId, permission) + cur = assert(con:execute("INSERT INTO `player_permission` (`player_id`, `permission`) VALUES ("..tonumber(playerId)..", '"..util.escape(permission).."')")) +end + +function mysql.removePlayerPermission(playerId, permission) + cur = assert(con:execute("DELETE FROM `player_permission` WHERE `player_id`="..tonumber(playerId).." AND permission='"..util.escape(permission).."'")) +end + +function mysql.copyPlayerPermissions(playerId, newPlayerId) + cur = assert(con:execute("INSERT INTO `player_permission` (`player_id`, `permission`) SELECT '"..tonumber(newPlayerId).."' AS `player_id`, `permission` FROM `player_permission` WHERE `player_id`="..tonumber(playerId))) +end + +function mysql.removePlayerPermissions(playerId) + cur = assert(con:execute("DELETE FROM `player_permission` WHERE `player_id`="..tonumber(playerId).."")) end -- aliases diff --git a/luamods/wolfadmin/db/sqlite3.lua b/luamods/wolfadmin/db/sqlite3.lua index 0ae4281..3d01a04 100644 --- a/luamods/wolfadmin/db/sqlite3.lua +++ b/luamods/wolfadmin/db/sqlite3.lua @@ -143,36 +143,68 @@ function sqlite3.getLevel(id) end -- acl -function sqlite3.getLevelRoles() - cur = assert(con:execute("SELECT * FROM `level_role`")) +function sqlite3.getLevelPermissions() + cur = assert(con:execute("SELECT * FROM `level_permission`")) - local roles = {} + local permissions = {} local row = cur:fetch({}, "a") while row do - table.insert(roles, tables.copy(row)) + table.insert(permissions, tables.copy(row)) row = cur:fetch(row, "a") end cur:close() - return roles + return permissions end -function sqlite3.addLevelRole(levelId, role) - cur = assert(con:execute("INSERT INTO `level_role` (`level_id`, `role`) VALUES ("..tonumber(levelId)..", '"..util.escape(role).."')")) +function sqlite3.addLevelPermission(levelId, permission) + cur = assert(con:execute("INSERT INTO `level_permission` (`level_id`, `permission`) VALUES ("..tonumber(levelId)..", '"..util.escape(permission).."')")) end -function sqlite3.removeLevelRole(levelId, role) - cur = assert(con:execute("DELETE FROM `level_role` WHERE `level_id`="..tonumber(levelId).." AND role='"..util.escape(role).."'")) +function sqlite3.removeLevelPermission(levelId, permission) + cur = assert(con:execute("DELETE FROM `level_permission` WHERE `level_id`="..tonumber(levelId).." AND permission='"..util.escape(permission).."'")) end -function sqlite3.copyLevelRoles(levelId, newLevelId) - cur = assert(con:execute("INSERT INTO `level_role` (`level_id`, `role`) SELECT '"..tonumber(newLevelId).."' AS `level_id`, `role` FROM `level_role` WHERE `level_id`="..tonumber(levelId))) +function sqlite3.copyLevelPermissions(levelId, newLevelId) + cur = assert(con:execute("INSERT INTO `level_permission` (`level_id`, `permission`) SELECT '"..tonumber(newLevelId).."' AS `level_id`, `permission` FROM `level_permission` WHERE `level_id`="..tonumber(levelId))) end -function sqlite3.removeLevelRoles(levelId) - cur = assert(con:execute("DELETE FROM `level_role` WHERE `level_id`="..tonumber(levelId).."")) +function sqlite3.removeLevelPermissions(levelId) + cur = assert(con:execute("DELETE FROM `level_permission` WHERE `level_id`="..tonumber(levelId).."")) +end + +function sqlite3.getPlayerPermissions(playerId) + cur = assert(con:execute("SELECT * FROM `player_permission` WHERE `player_id`="..tonumber(playerId).."")) + + local permissions = {} + local row = cur:fetch({}, "a") + + while row do + table.insert(permissions, tables.copy(row)) + row = cur:fetch(row, "a") + end + + cur:close() + + return permissions +end + +function sqlite3.addPlayerPermission(playerId, permission) + cur = assert(con:execute("INSERT INTO `player_permission` (`player_id`, `permission`) VALUES ("..tonumber(playerId)..", '"..util.escape(permission).."')")) +end + +function sqlite3.removePlayerPermission(playerId, permission) + cur = assert(con:execute("DELETE FROM `player_permission` WHERE `player_id`="..tonumber(playerId).." AND permission='"..util.escape(permission).."'")) +end + +function sqlite3.copyPlayerPermissions(playerId, newPlayerId) + cur = assert(con:execute("INSERT INTO `player_permission` (`player_id`, `permission`) SELECT '"..tonumber(newPlayerId).."' AS `player_id`, `permission` FROM `player_permission` WHERE `player_id`="..tonumber(playerId))) +end + +function sqlite3.removePlayerPermissions(playerId) + cur = assert(con:execute("DELETE FROM `player_permission` WHERE `player_id`="..tonumber(playerId).."")) end -- aliases