ACL system improvements (refs #69)

* renamed 'roles' to 'permissions'
* added player permissions
* added functions to manipulate shrubbot files
This commit is contained in:
Timo Smit 2018-12-31 11:03:48 +01:00
parent 1872921e52
commit 44f78fb1d3
9 changed files with 1061 additions and 830 deletions

View file

@ -4,11 +4,11 @@ CREATE TABLE IF NOT EXISTS `level` (
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ) 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, `level_id` int(11) NOT NULL,
`role` varchar(32) NOT NULL, `permission` varchar(32) NOT NULL,
PRIMARY KEY (`level_id`,`role`), PRIMARY KEY (`level_id`,`permission`),
CONSTRAINT `level_role_level` FOREIGN KEY (`level_id`) REFERENCES `level` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION 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; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE IF NOT EXISTS `player` ( 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 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; ) 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` ( CREATE TABLE IF NOT EXISTS `alias` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`player_id` int(10) unsigned NOT NULL, `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 (4, 'Senior Admin');
INSERT INTO `level` (`id`, `name`) VALUES (5, 'Server Owner'); INSERT INTO `level` (`id`, `name`) VALUES (5, 'Server Owner');
-- add roles for level 0 -- add permissions for level 0
INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'admintest'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'admintest');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'help'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'help');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'time'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'time');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'greeting'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'greeting');
-- add roles for level 1 -- add permissions for level 1
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'admintest'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'admintest');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'help'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'help');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'time'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'time');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'greeting'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'greeting');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'listmaps'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listmaps');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'listsprees'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listsprees');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'listrules'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listrules');
-- add roles for level 2 -- add permissions for level 2
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'admintest'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'admintest');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'help'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'help');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'time'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'time');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'greeting'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'greeting');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listplayers'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listplayers');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listteams'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listteams');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listmaps'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listmaps');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listsprees'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listsprees');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listrules'); 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 -- add permissions for level 3
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'admintest'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'admintest');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'help'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'help');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'time'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'time');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'greeting'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'greeting');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listplayers'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listplayers');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listteams'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listteams');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listmaps'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listmaps');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listsprees'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listsprees');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listrules'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listrules');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listhistory'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listhistory');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listbans'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listbans');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'liststats'); 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_permission`(`level_id`, `permission`) VALUES (3, 'put');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'dropweapons'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'dropweapons');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'warn'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'warn');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'mute'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'mute');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'voicemute'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'voicemute');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'spec999'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'spec999');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'balance'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'balance');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'cointoss'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'cointoss');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'pause'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'pause');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'nextmap'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'nextmap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'restart'); 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_permission`(`level_id`, `permission`) VALUES (3, 'noinactivity');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'novote'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'novote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'nocensor'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'nocensor');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'novotelimit'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'novotelimit');
-- add roles for level 4 -- add permissions for level 4
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'admintest'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'admintest');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'help'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'help');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'time'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'time');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'greeting'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'greeting');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listplayers'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listplayers');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listteams'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listteams');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listmaps'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listmaps');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listsprees'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listsprees');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listrules'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listrules');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listhistory'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listhistory');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listwarns'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listwarns');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listbans'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listbans');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listaliases'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listaliases');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'liststats'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'liststats');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'finger'); 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_permission`(`level_id`, `permission`) VALUES (4, 'put');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'dropweapons'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'dropweapons');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'rename'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'rename');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'freeze'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'freeze');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'disorient'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'disorient');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'burn'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'burn');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'slap'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'slap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'gib'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'gib');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'throw'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'throw');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'glow'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'glow');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'pants'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pants');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'pop'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pop');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'warn'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'warn');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'mute'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'mute');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'voicemute'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'voicemute');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'kick'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'kick');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'ban'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'ban');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'spec999'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'spec999');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'balance'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'balance');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'lockplayers'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'lockplayers');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'lockteam'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'lockteam');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'shuffle'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'shuffle');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'swap'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'swap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'cointoss'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'cointoss');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'pause'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pause');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'nextmap'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nextmap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'restart'); 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_permission`(`level_id`, `permission`) VALUES (4, 'enablevote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'cancelvote'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'cancelvote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'passvote'); 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_permission`(`level_id`, `permission`) VALUES (4, 'noinactivity');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'novote'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'novote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'nocensor'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nocensor');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'nobalance'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nobalance');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'novotelimit'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'novotelimit');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'noreason'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'noreason');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'teamcmds'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'teamcmds');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'silentcmds'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'silentcmds');
-- add roles for level 5 -- add permissions for level 5
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'admintest'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'admintest');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'help'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'help');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'time'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'time');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'greeting'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'greeting');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listplayers'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listplayers');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listteams'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listteams');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listmaps'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listmaps');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listsprees'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listsprees');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listrules'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listrules');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listhistory'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listhistory');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listwarns'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listwarns');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listbans'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listbans');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listaliases'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listaliases');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'liststats'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'liststats');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'finger'); 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_permission`(`level_id`, `permission`) VALUES (5, 'put');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'dropweapons'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'dropweapons');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'rename'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'rename');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'freeze'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'freeze');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'disorient'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'disorient');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'burn'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'burn');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'slap'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'slap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'gib'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'gib');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'throw'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'throw');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'glow'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'glow');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'pants'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pants');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'pop'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pop');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'warn'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'warn');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'mute'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'mute');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'voicemute'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'voicemute');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'kick'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'kick');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'ban'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'ban');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'spec999'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'spec999');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'balance'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'balance');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'lockplayers'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'lockplayers');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'lockteam'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'lockteam');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'shuffle'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'shuffle');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'swap'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'swap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'cointoss'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'cointoss');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'pause'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pause');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'nextmap'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nextmap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'restart'); 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_permission`(`level_id`, `permission`) VALUES (5, 'enablevote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'cancelvote'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'cancelvote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'passvote'); 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_permission`(`level_id`, `permission`) VALUES (5, 'uptime');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'setlevel'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'setlevel');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'readconfig'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'readconfig');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'noinactivity'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'noinactivity');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'novote'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'novote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'nocensor'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nocensor');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'nobalance'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nobalance');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'novotelimit'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'novotelimit');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'noreason'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'noreason');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'perma'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'perma');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'teamcmds'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'teamcmds');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'silentcmds'); 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 -- add console to players table
INSERT INTO `player` (`id`, `guid`, `ip`) VALUES (1, 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', '127.0.0.1'); INSERT INTO `player` (`id`, `guid`, `ip`) VALUES (1, 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', '127.0.0.1');

View file

@ -3,11 +3,11 @@ CREATE TABLE IF NOT EXISTS `level` (
`name` TEXT NOT NULL `name` TEXT NOT NULL
); );
CREATE TABLE `level_role` ( CREATE TABLE `level_permission` (
`level_id` INTEGER NOT NULL, `level_id` INTEGER NOT NULL,
`role` TEXT NOT NULL, `permission` TEXT NOT NULL,
PRIMARY KEY (`level_id`, `role`), PRIMARY KEY (`level_id`, `permission`),
CONSTRAINT `role_level` FOREIGN KEY (`level_id`) REFERENCES `level` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION 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` ( 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 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` ( CREATE TABLE IF NOT EXISTS `alias` (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`player_id` INTEGER NOT NULL, `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'); INSERT INTO `level` (`id`, `name`) VALUES (5, 'Server Owner');
COMMIT; COMMIT;
-- add roles for level 0 -- add permissions for level 0
BEGIN; BEGIN;
INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'admintest'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'admintest');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'help'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'help');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'time'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'time');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'greeting'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'greeting');
COMMIT; COMMIT;
-- add roles for level 1 -- add permissions for level 1
BEGIN; BEGIN;
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'admintest'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'admintest');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'help'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'help');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'time'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'time');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'greeting'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'greeting');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'listmaps'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listmaps');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'listsprees'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listsprees');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'listrules'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listrules');
COMMIT; COMMIT;
-- add roles for level 2 -- add permissions for level 2
BEGIN; BEGIN;
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'admintest'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'admintest');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'help'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'help');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'time'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'time');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'greeting'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'greeting');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listplayers'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listplayers');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listteams'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listteams');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listmaps'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listmaps');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listsprees'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listsprees');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listrules'); 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; COMMIT;
-- add roles for level 3 -- add permissions for level 3
BEGIN; BEGIN;
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'admintest'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'admintest');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'help'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'help');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'time'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'time');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'greeting'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'greeting');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listplayers'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listplayers');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listteams'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listteams');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listmaps'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listmaps');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listsprees'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listsprees');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listrules'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listrules');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listhistory'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listhistory');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listbans'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listbans');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'liststats'); 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_permission`(`level_id`, `permission`) VALUES (3, 'put');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'dropweapons'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'dropweapons');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'warn'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'warn');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'mute'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'mute');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'voicemute'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'voicemute');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'spec999'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'spec999');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'balance'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'balance');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'cointoss'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'cointoss');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'pause'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'pause');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'nextmap'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'nextmap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'restart'); 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_permission`(`level_id`, `permission`) VALUES (3, 'noinactivity');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'novote'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'novote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'nocensor'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'nocensor');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'novotelimit'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'novotelimit');
COMMIT; COMMIT;
-- add roles for level 4 -- add permissions for level 4
BEGIN; BEGIN;
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'admintest'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'admintest');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'help'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'help');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'time'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'time');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'greeting'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'greeting');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listplayers'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listplayers');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listteams'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listteams');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listmaps'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listmaps');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listsprees'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listsprees');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listrules'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listrules');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listhistory'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listhistory');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listwarns'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listwarns');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listbans'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listbans');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listaliases'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listaliases');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'liststats'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'liststats');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'finger'); 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_permission`(`level_id`, `permission`) VALUES (4, 'put');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'dropweapons'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'dropweapons');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'rename'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'rename');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'freeze'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'freeze');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'disorient'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'disorient');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'burn'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'burn');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'slap'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'slap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'gib'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'gib');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'throw'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'throw');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'glow'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'glow');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'pants'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pants');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'pop'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pop');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'warn'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'warn');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'mute'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'mute');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'voicemute'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'voicemute');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'kick'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'kick');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'ban'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'ban');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'spec999'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'spec999');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'balance'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'balance');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'lockplayers'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'lockplayers');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'lockteam'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'lockteam');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'shuffle'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'shuffle');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'swap'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'swap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'cointoss'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'cointoss');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'pause'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pause');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'nextmap'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nextmap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'restart'); 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_permission`(`level_id`, `permission`) VALUES (4, 'enablevote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'cancelvote'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'cancelvote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'passvote'); 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_permission`(`level_id`, `permission`) VALUES (4, 'noinactivity');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'novote'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'novote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'nocensor'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nocensor');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'nobalance'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nobalance');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'novotelimit'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'novotelimit');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'noreason'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'noreason');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'teamcmds'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'teamcmds');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'silentcmds'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'silentcmds');
COMMIT; COMMIT;
-- add roles for level 5 -- add permissions for level 5
BEGIN; BEGIN;
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'admintest'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'admintest');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'help'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'help');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'time'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'time');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'greeting'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'greeting');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listplayers'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listplayers');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listteams'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listteams');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listmaps'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listmaps');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listsprees'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listsprees');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listrules'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listrules');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listhistory'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listhistory');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listwarns'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listwarns');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listbans'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listbans');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listaliases'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listaliases');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'liststats'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'liststats');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'finger'); 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_permission`(`level_id`, `permission`) VALUES (5, 'put');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'dropweapons'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'dropweapons');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'rename'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'rename');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'freeze'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'freeze');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'disorient'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'disorient');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'burn'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'burn');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'slap'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'slap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'gib'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'gib');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'throw'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'throw');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'glow'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'glow');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'pants'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pants');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'pop'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pop');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'warn'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'warn');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'mute'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'mute');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'voicemute'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'voicemute');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'kick'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'kick');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'ban'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'ban');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'spec999'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'spec999');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'balance'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'balance');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'lockplayers'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'lockplayers');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'lockteam'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'lockteam');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'shuffle'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'shuffle');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'swap'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'swap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'cointoss'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'cointoss');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'pause'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pause');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'nextmap'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nextmap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'restart'); 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_permission`(`level_id`, `permission`) VALUES (5, 'enablevote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'cancelvote'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'cancelvote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'passvote'); 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_permission`(`level_id`, `permission`) VALUES (5, 'uptime');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'setlevel'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'setlevel');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'readconfig'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'readconfig');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'noinactivity'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'noinactivity');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'novote'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'novote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'nocensor'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nocensor');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'nobalance'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nobalance');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'novotelimit'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'novotelimit');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'noreason'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'noreason');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'perma'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'perma');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'teamcmds'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'teamcmds');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'silentcmds'); 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; COMMIT;
-- add console to players table -- add console to players table

View file

@ -40,13 +40,20 @@ CREATE TABLE IF NOT EXISTS `level` (
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1; ) 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, `level_id` int(11) NOT NULL,
`role` varchar(32) NOT NULL, `permission` varchar(32) NOT NULL,
PRIMARY KEY (`level_id`,`role`), PRIMARY KEY (`level_id`,`permission`),
CONSTRAINT `level_role_level` FOREIGN KEY (`level_id`) REFERENCES `level` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION CONSTRAINT `level_permission_level` FOREIGN KEY (`level_id`) REFERENCES `level` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1; ) 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 -- populate acl
-- add levels -- add levels
INSERT INTO `level` (`id`, `name`) VALUES (0, 'Guest'); 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 (4, 'Senior Admin');
INSERT INTO `level` (`id`, `name`) VALUES (5, 'Server Owner'); INSERT INTO `level` (`id`, `name`) VALUES (5, 'Server Owner');
-- add roles for level 0 -- add permissions for level 0
INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'admintest'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'admintest');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'help'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'help');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'time'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'time');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'greeting'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'greeting');
-- add roles for level 1 -- add permissions for level 1
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'admintest'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'admintest');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'help'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'help');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'time'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'time');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'greeting'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'greeting');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'listmaps'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listmaps');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'listsprees'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listsprees');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'listrules'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listrules');
-- add roles for level 2 -- add permissions for level 2
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'admintest'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'admintest');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'help'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'help');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'time'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'time');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'greeting'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'greeting');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listplayers'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listplayers');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listteams'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listteams');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listmaps'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listmaps');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listsprees'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listsprees');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listrules'); 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 -- add permissions for level 3
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'admintest'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'admintest');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'help'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'help');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'time'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'time');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'greeting'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'greeting');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listplayers'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listplayers');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listteams'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listteams');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listmaps'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listmaps');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listsprees'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listsprees');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listrules'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listrules');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listhistory'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listhistory');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listbans'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listbans');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'liststats'); 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_permission`(`level_id`, `permission`) VALUES (3, 'put');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'dropweapons'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'dropweapons');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'warn'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'warn');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'mute'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'mute');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'voicemute'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'voicemute');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'spec999'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'spec999');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'balance'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'balance');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'cointoss'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'cointoss');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'pause'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'pause');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'nextmap'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'nextmap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'restart'); 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_permission`(`level_id`, `permission`) VALUES (3, 'noinactivity');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'novote'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'novote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'nocensor'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'nocensor');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'novotelimit'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'novotelimit');
-- add roles for level 4 -- add permissions for level 4
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'admintest'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'admintest');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'help'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'help');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'time'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'time');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'greeting'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'greeting');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listplayers'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listplayers');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listteams'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listteams');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listmaps'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listmaps');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listsprees'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listsprees');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listrules'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listrules');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listhistory'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listhistory');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listwarns'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listwarns');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listbans'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listbans');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listaliases'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listaliases');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'liststats'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'liststats');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'finger'); 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_permission`(`level_id`, `permission`) VALUES (4, 'put');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'dropweapons'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'dropweapons');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'rename'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'rename');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'freeze'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'freeze');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'disorient'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'disorient');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'burn'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'burn');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'slap'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'slap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'gib'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'gib');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'throw'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'throw');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'glow'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'glow');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'pants'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pants');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'pop'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pop');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'warn'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'warn');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'mute'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'mute');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'voicemute'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'voicemute');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'kick'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'kick');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'ban'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'ban');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'spec999'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'spec999');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'balance'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'balance');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'lockplayers'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'lockplayers');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'lockteam'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'lockteam');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'shuffle'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'shuffle');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'swap'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'swap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'cointoss'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'cointoss');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'pause'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pause');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'nextmap'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nextmap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'restart'); 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_permission`(`level_id`, `permission`) VALUES (4, 'enablevote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'cancelvote'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'cancelvote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'passvote'); 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_permission`(`level_id`, `permission`) VALUES (4, 'noinactivity');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'novote'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'novote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'nocensor'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nocensor');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'nobalance'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nobalance');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'novotelimit'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'novotelimit');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'noreason'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'noreason');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'teamcmds'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'teamcmds');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'silentcmds'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'silentcmds');
-- add roles for level 5 -- add permissions for level 5
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'admintest'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'admintest');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'help'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'help');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'time'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'time');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'greeting'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'greeting');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listplayers'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listplayers');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listteams'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listteams');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listmaps'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listmaps');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listsprees'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listsprees');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listrules'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listrules');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listhistory'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listhistory');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listwarns'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listwarns');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listbans'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listbans');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listaliases'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listaliases');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'liststats'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'liststats');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'finger'); 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_permission`(`level_id`, `permission`) VALUES (5, 'put');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'dropweapons'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'dropweapons');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'rename'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'rename');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'freeze'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'freeze');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'disorient'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'disorient');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'burn'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'burn');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'slap'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'slap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'gib'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'gib');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'throw'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'throw');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'glow'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'glow');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'pants'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pants');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'pop'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pop');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'warn'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'warn');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'mute'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'mute');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'voicemute'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'voicemute');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'kick'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'kick');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'ban'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'ban');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'spec999'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'spec999');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'balance'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'balance');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'lockplayers'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'lockplayers');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'lockteam'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'lockteam');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'shuffle'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'shuffle');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'swap'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'swap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'cointoss'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'cointoss');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'pause'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pause');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'nextmap'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nextmap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'restart'); 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_permission`(`level_id`, `permission`) VALUES (5, 'enablevote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'cancelvote'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'cancelvote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'passvote'); 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_permission`(`level_id`, `permission`) VALUES (5, 'uptime');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'setlevel'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'setlevel');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'readconfig'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'readconfig');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'noinactivity'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'noinactivity');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'novote'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'novote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'nocensor'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nocensor');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'nobalance'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nobalance');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'novotelimit'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'novotelimit');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'noreason'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'noreason');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'perma'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'perma');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'teamcmds'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'teamcmds');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'silentcmds'); 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 -- update player table
ALTER TABLE `player` ALTER TABLE `player`

View file

@ -27,11 +27,18 @@ CREATE TABLE IF NOT EXISTS `level` (
`name` TEXT NOT NULL `name` TEXT NOT NULL
); );
CREATE TABLE `level_role` ( CREATE TABLE `level_permission` (
`level_id` INTEGER NOT NULL, `level_id` INTEGER NOT NULL,
`role` TEXT NOT NULL, `permission` TEXT NOT NULL,
PRIMARY KEY (`level_id`, `role`), PRIMARY KEY (`level_id`, `permission`),
CONSTRAINT `role_level` FOREIGN KEY (`level_id`) REFERENCES `level` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION 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 -- populate acl
@ -45,232 +52,232 @@ INSERT INTO `level` (`id`, `name`) VALUES (4, 'Senior Admin');
INSERT INTO `level` (`id`, `name`) VALUES (5, 'Server Owner'); INSERT INTO `level` (`id`, `name`) VALUES (5, 'Server Owner');
COMMIT; COMMIT;
-- add roles for level 0 -- add permissions for level 0
BEGIN; BEGIN;
INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'admintest'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'admintest');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'help'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'help');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'time'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'time');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'greeting'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'greeting');
COMMIT; COMMIT;
-- add roles for level 1 -- add permissions for level 1
BEGIN; BEGIN;
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'admintest'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'admintest');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'help'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'help');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'time'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'time');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'greeting'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'greeting');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'listmaps'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listmaps');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'listsprees'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listsprees');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'listrules'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listrules');
COMMIT; COMMIT;
-- add roles for level 2 -- add permissions for level 2
BEGIN; BEGIN;
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'admintest'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'admintest');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'help'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'help');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'time'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'time');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'greeting'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'greeting');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listplayers'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listplayers');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listteams'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listteams');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listmaps'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listmaps');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listsprees'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listsprees');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listrules'); 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; COMMIT;
-- add roles for level 3 -- add permissions for level 3
BEGIN; BEGIN;
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'admintest'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'admintest');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'help'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'help');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'time'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'time');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'greeting'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'greeting');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listplayers'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listplayers');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listteams'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listteams');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listmaps'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listmaps');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listsprees'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listsprees');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listrules'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listrules');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listhistory'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listhistory');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listbans'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listbans');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'liststats'); 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_permission`(`level_id`, `permission`) VALUES (3, 'put');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'dropweapons'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'dropweapons');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'warn'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'warn');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'mute'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'mute');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'voicemute'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'voicemute');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'spec999'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'spec999');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'balance'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'balance');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'cointoss'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'cointoss');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'pause'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'pause');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'nextmap'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'nextmap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'restart'); 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_permission`(`level_id`, `permission`) VALUES (3, 'noinactivity');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'novote'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'novote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'nocensor'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'nocensor');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'novotelimit'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'novotelimit');
COMMIT; COMMIT;
-- add roles for level 4 -- add permissions for level 4
BEGIN; BEGIN;
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'admintest'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'admintest');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'help'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'help');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'time'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'time');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'greeting'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'greeting');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listplayers'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listplayers');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listteams'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listteams');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listmaps'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listmaps');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listsprees'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listsprees');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listrules'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listrules');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listhistory'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listhistory');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listwarns'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listwarns');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listbans'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listbans');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listaliases'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listaliases');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'liststats'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'liststats');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'finger'); 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_permission`(`level_id`, `permission`) VALUES (4, 'put');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'dropweapons'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'dropweapons');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'rename'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'rename');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'freeze'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'freeze');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'disorient'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'disorient');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'burn'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'burn');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'slap'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'slap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'gib'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'gib');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'throw'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'throw');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'glow'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'glow');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'pants'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pants');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'pop'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pop');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'warn'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'warn');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'mute'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'mute');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'voicemute'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'voicemute');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'kick'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'kick');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'ban'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'ban');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'spec999'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'spec999');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'balance'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'balance');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'lockplayers'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'lockplayers');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'lockteam'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'lockteam');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'shuffle'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'shuffle');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'swap'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'swap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'cointoss'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'cointoss');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'pause'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pause');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'nextmap'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nextmap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'restart'); 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_permission`(`level_id`, `permission`) VALUES (4, 'enablevote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'cancelvote'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'cancelvote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'passvote'); 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_permission`(`level_id`, `permission`) VALUES (4, 'noinactivity');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'novote'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'novote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'nocensor'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nocensor');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'nobalance'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nobalance');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'novotelimit'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'novotelimit');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'noreason'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'noreason');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'teamcmds'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'teamcmds');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'silentcmds'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'silentcmds');
COMMIT; COMMIT;
-- add roles for level 5 -- add permissions for level 5
BEGIN; BEGIN;
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'admintest'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'admintest');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'help'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'help');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'time'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'time');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'greeting'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'greeting');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listplayers'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listplayers');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listteams'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listteams');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listmaps'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listmaps');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listsprees'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listsprees');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listrules'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listrules');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listhistory'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listhistory');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listwarns'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listwarns');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listbans'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listbans');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'listaliases'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listaliases');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'liststats'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'liststats');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'finger'); 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_permission`(`level_id`, `permission`) VALUES (5, 'put');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'dropweapons'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'dropweapons');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'rename'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'rename');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'freeze'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'freeze');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'disorient'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'disorient');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'burn'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'burn');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'slap'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'slap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'gib'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'gib');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'throw'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'throw');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'glow'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'glow');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'pants'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pants');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'pop'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pop');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'warn'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'warn');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'mute'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'mute');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'voicemute'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'voicemute');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'kick'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'kick');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'ban'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'ban');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'spec999'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'spec999');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'balance'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'balance');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'lockplayers'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'lockplayers');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'lockteam'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'lockteam');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'shuffle'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'shuffle');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'swap'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'swap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'cointoss'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'cointoss');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'pause'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pause');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'nextmap'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nextmap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'restart'); 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_permission`(`level_id`, `permission`) VALUES (5, 'enablevote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'cancelvote'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'cancelvote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'passvote'); 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_permission`(`level_id`, `permission`) VALUES (5, 'uptime');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'setlevel'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'setlevel');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'readconfig'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'readconfig');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'noinactivity'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'noinactivity');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'novote'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'novote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'nocensor'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nocensor');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'nobalance'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nobalance');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'novotelimit'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'novotelimit');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'noreason'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'noreason');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'perma'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'perma');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'teamcmds'); INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'teamcmds');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'silentcmds'); 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; COMMIT;
-- update player table -- update player table

View file

@ -19,11 +19,32 @@ local db = require (wolfa_getLuaPath()..".db.db")
local players = require (wolfa_getLuaPath()..".players.players") 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 tables = require (wolfa_getLuaPath()..".util.tables")
local acl = {} 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() function acl.readPermissions()
-- read level permissions into a cache file (can be loaded at mod start) -- read level permissions into a cache file (can be loaded at mod start)
@ -32,24 +53,24 @@ function acl.readPermissions()
local levels = db.getLevelsWithIds() local levels = db.getLevelsWithIds()
for _, level in ipairs(levels) do for _, level in ipairs(levels) do
data[level["id"]] = {} cachedLevels[level["id"]] = {}
end end
local roles = db.getLevelRoles() local permissions = db.getLevelPermissions()
for _, role in ipairs(roles) do for _, permission in ipairs(permissions) do
table.insert(data[role["level_id"]], role["role"]) table.insert(cachedLevels[permission["level_id"]], permission["permission"])
end end
end end
function acl.clearCache() function acl.clearCache()
data = {} cachedLevels = {}
end end
function acl.isPlayerAllowed(clientId, permission) function acl.isPlayerAllowed(clientId, permission, playerOnly)
local level = acl.getPlayerLevel(clientId) 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 end
function acl.getLevels() function acl.getLevels()
@ -63,65 +84,97 @@ end
function acl.addLevel(levelId, name) function acl.addLevel(levelId, name)
db.addLevel(levelId, name) db.addLevel(levelId, name)
data[levelId] = {} cachedLevels[levelId] = {}
end end
function acl.removeLevel(levelId) function acl.removeLevel(levelId)
db.removeLevel(levelId) db.removeLevel(levelId)
data[levelId] = nil cachedLevels[levelId] = nil
end end
function acl.reLevel(levelId, newLevelId) function acl.reLevel(levelId, newLevelId)
db.reLevel(levelId, newLevelId) db.reLevel(levelId, newLevelId)
end 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) function acl.getLevelName(levelId)
local level = db.getLevel(levelId) local level = db.getLevel(levelId)
return level["name"] return level["name"]
end 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 return acl

View file

@ -17,6 +17,8 @@
local shrubbot = {} local shrubbot = {}
local players = require (wolfa_getLuaPath()..".players.players")
local flags local flags
function shrubbot.loadFlags(mod) function shrubbot.loadFlags(mod)
@ -37,4 +39,88 @@ function shrubbot.getPlayerLevel(clientId)
return et.G_shrubbot_level(clientId) return et.G_shrubbot_level(clientId)
end 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 return shrubbot

View file

@ -54,7 +54,7 @@ function commandAclRemoveLevel(levelId)
return true return true
end end
acl.removeLevelRoles(levelId) acl.removeLevelPermissions(levelId)
acl.removeLevel(levelId) acl.removeLevel(levelId)
et.G_Print("removed level "..levelId.."\n") 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") et.G_Print("releveled all players with "..levelId.." to "..newLevelId.."\n")
end end
function commandAclListLevelRoles(levelId) function commandAclListLevelPermissions(levelId)
local levelId = tonumber(levelId) local levelId = tonumber(levelId)
if not levelId or not acl.isLevel(levelId) then 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 return true
end 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 for _, permission in ipairs(acl.getLevelPermissions(levelId)) do
et.G_Print(role.."\n") et.G_Print(permission.."\n")
end end
end end
function commandAclIsAllowed(levelId, role) function commandAclIsAllowed(levelId, permission)
local levelId = tonumber(levelId) local levelId = tonumber(levelId)
if not levelId or not acl.isLevel(levelId) or not role then if not levelId or not acl.isLevel(levelId) or not permission then
et.G_Print("usage: acl isallowed [id] [role]\n") et.G_Print("usage: acl isallowed [id] [permission]\n")
return true return true
end 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 end
function commandAclAddLevelRole(levelId, role) function commandAclAddLevelPermission(levelId, permission)
local levelId = tonumber(levelId) local levelId = tonumber(levelId)
if not levelId or not acl.isLevel(levelId) or not role then if not levelId or not acl.isLevel(levelId) or not permission then
et.G_Print("usage: acl addrole [id] [role]\n") et.G_Print("usage: acl addpermission [id] [permission]\n")
return true return true
end end
local isAllowed = acl.isLevelAllowed(levelId, role) local isAllowed = acl.isLevelAllowed(levelId, permission)
if isAllowed then 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 return true
end 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 end
function commandAclRemoveLevelRole(levelId, role) function commandAclRemoveLevelPermission(levelId, permission)
local levelId = tonumber(levelId) local levelId = tonumber(levelId)
if not levelId or not acl.isLevel(levelId) or not role then if not levelId or not acl.isLevel(levelId) or not permission then
et.G_Print("usage: acl removerole [id] [role]\n") et.G_Print("usage: acl removepermission [id] [permission]\n")
return true return true
end end
local isAllowed = acl.isLevelAllowed(levelId, role) local isAllowed = acl.isLevelAllowed(levelId, permission)
if not isAllowed then 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 return true
end 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 end
function commandAclCopyLevelRoles(levelId, newLevelId) function commandAclCopyLevelPermissions(levelId, newLevelId)
local levelId = tonumber(levelId) local levelId = tonumber(levelId)
local newLevelId = tonumber(newLevelId) local newLevelId = tonumber(newLevelId)
if not levelId or not acl.isLevel(levelId) or not newLevelId or not acl.isLevel(newLevelId) then 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 return true
end end
if #acl.getLevelRoles(newLevelId) ~= 0 then if #acl.getLevelPermissions(newLevelId) ~= 0 then
et.G_Print("error: level "..newLevelId.." already has roles\n") et.G_Print("error: level "..newLevelId.." already has permissions\n")
return true return true
end 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 end
function commandAcl(command, action, ...) function commandAcl(command, action, ...)
@ -179,18 +179,18 @@ function commandAcl(command, action, ...)
return commandAclRemoveLevel(...) return commandAclRemoveLevel(...)
elseif action == "relevel" then elseif action == "relevel" then
return commandAclReLevel(...) return commandAclReLevel(...)
elseif action == "listroles" then elseif action == "listpermissions" then
return commandAclListLevelRoles(...) return commandAclListLevelPermissions(...)
elseif action == "isallowed" then elseif action == "isallowed" then
return commandAclIsAllowed(...) return commandAclIsAllowed(...)
elseif action == "addrole" then elseif action == "addpermission" then
return commandAclAddLevelRole(...) return commandAclAddLevelPermission(...)
elseif action == "removerole" then elseif action == "removepermission" then
return commandAclRemoveLevelRole(...) return commandAclRemoveLevelPermission(...)
elseif action == "copyroles" then elseif action == "copypermissions" then
return commandAclCopyLevelRoles(...) return commandAclCopyLevelPermissions(...)
else 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 end
return true return true

View file

@ -143,36 +143,68 @@ function mysql.getLevel(id)
end end
-- acl -- acl
function mysql.getLevelRoles() function mysql.getLevelPermissions()
cur = assert(con:execute("SELECT * FROM `level_role`")) cur = assert(con:execute("SELECT * FROM `level_permission`"))
local roles = {} local permissions = {}
local row = cur:fetch({}, "a") local row = cur:fetch({}, "a")
while row do while row do
table.insert(roles, tables.copy(row)) table.insert(permissions, tables.copy(row))
row = cur:fetch(row, "a") row = cur:fetch(row, "a")
end end
cur:close() cur:close()
return roles return permissions
end end
function mysql.addLevelRole(levelId, role) function mysql.addLevelPermission(levelId, permission)
cur = assert(con:execute("INSERT INTO `level_role` (`level_id`, `role`) VALUES ("..tonumber(levelId)..", '"..util.escape(role).."')")) cur = assert(con:execute("INSERT INTO `level_permission` (`level_id`, `permission`) VALUES ("..tonumber(levelId)..", '"..util.escape(permission).."')"))
end end
function mysql.removeLevelRole(levelId, role) function mysql.removeLevelPermission(levelId, permission)
cur = assert(con:execute("DELETE FROM `level_role` WHERE `level_id`="..tonumber(levelId).." AND role='"..util.escape(role).."'")) cur = assert(con:execute("DELETE FROM `level_permission` WHERE `level_id`="..tonumber(levelId).." AND permission='"..util.escape(permission).."'"))
end end
function mysql.copyLevelRoles(levelId, newLevelId) function mysql.copyLevelPermissions(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))) 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 end
function mysql.removeLevelRoles(levelId) function mysql.removeLevelPermissions(levelId)
cur = assert(con:execute("DELETE FROM `level_role` WHERE `level_id`="..tonumber(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 end
-- aliases -- aliases

View file

@ -143,36 +143,68 @@ function sqlite3.getLevel(id)
end end
-- acl -- acl
function sqlite3.getLevelRoles() function sqlite3.getLevelPermissions()
cur = assert(con:execute("SELECT * FROM `level_role`")) cur = assert(con:execute("SELECT * FROM `level_permission`"))
local roles = {} local permissions = {}
local row = cur:fetch({}, "a") local row = cur:fetch({}, "a")
while row do while row do
table.insert(roles, tables.copy(row)) table.insert(permissions, tables.copy(row))
row = cur:fetch(row, "a") row = cur:fetch(row, "a")
end end
cur:close() cur:close()
return roles return permissions
end end
function sqlite3.addLevelRole(levelId, role) function sqlite3.addLevelPermission(levelId, permission)
cur = assert(con:execute("INSERT INTO `level_role` (`level_id`, `role`) VALUES ("..tonumber(levelId)..", '"..util.escape(role).."')")) cur = assert(con:execute("INSERT INTO `level_permission` (`level_id`, `permission`) VALUES ("..tonumber(levelId)..", '"..util.escape(permission).."')"))
end end
function sqlite3.removeLevelRole(levelId, role) function sqlite3.removeLevelPermission(levelId, permission)
cur = assert(con:execute("DELETE FROM `level_role` WHERE `level_id`="..tonumber(levelId).." AND role='"..util.escape(role).."'")) cur = assert(con:execute("DELETE FROM `level_permission` WHERE `level_id`="..tonumber(levelId).." AND permission='"..util.escape(permission).."'"))
end end
function sqlite3.copyLevelRoles(levelId, newLevelId) function sqlite3.copyLevelPermissions(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))) 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 end
function sqlite3.removeLevelRoles(levelId) function sqlite3.removeLevelPermissions(levelId)
cur = assert(con:execute("DELETE FROM `level_role` WHERE `level_id`="..tonumber(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 end
-- aliases -- aliases