Updated SQLite script with more levels and roles (refs #62, #69)

* also added transactions to improve performance
This commit is contained in:
Timo Smit 2017-01-21 16:06:25 +01:00
parent f0618d8274
commit 7e5c009484
3 changed files with 155 additions and 9 deletions

View file

@ -108,20 +108,166 @@ CREATE TABLE IF NOT EXISTS `record` (
CREATE INDEX IF NOT EXISTS `record_player_idx` ON `record` (`player_id`);
-- add levels
BEGIN;
INSERT INTO `level` (`id`, `name`) VALUES (0, 'Guest');
INSERT INTO `level` (`id`, `name`) VALUES (1, 'Regular');
INSERT INTO `level` (`id`, `name`) VALUES (2, 'VIP');
INSERT INTO `level` (`id`, `name`) VALUES (3, 'Admin');
INSERT INTO `level` (`id`, `name`) VALUES (4, 'Senior Admin');
INSERT INTO `level` (`id`, `name`) VALUES (5, 'Admin');
COMMIT;
-- add roles for level 0
BEGIN;
INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'admintest');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'help');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'time');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'greeting');
COMMIT;
INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'listmaps');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'listsprees');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'listrules');
-- add roles for level 1
BEGIN;
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'admintest');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'help');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'time');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'greeting');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (0, 'adminchat');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'listmaps');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'listsprees');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (1, 'listrules');
COMMIT;
-- add roles for level 2
BEGIN;
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'admintest');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'help');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'time');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'greeting');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listplayers');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listteams');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listmaps');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listsprees');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'listrules');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (2, 'spec999');
COMMIT;
-- add roles for level 3
BEGIN;
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'admintest');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'help');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'time');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'greeting');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listplayers');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listteams');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listmaps');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listsprees');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listrules');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listhistory');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'listbans');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'liststats');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'adminchat');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'put');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'dropweapons');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'warn');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'mute');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'voicemute');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'spec999');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'balance');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'pause');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'nextmap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'restart');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'botadmin');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'enablevote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'noinactivity');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'novote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'nocensor');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (3, 'novotelimit');
COMMIT;
-- add roles for level 4
BEGIN;
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'admintest');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'help');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'time');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'greeting');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listplayers');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listteams');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listmaps');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listsprees');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listrules');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listhistory');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listwarns');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listbans');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'listaliases');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'liststats');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'finger');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'adminchat');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'put');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'dropweapons');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'rename');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'freeze');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'disorient');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'burn');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'slap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'gib');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'throw');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'glow');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'pants');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'pop');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'warn');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'mute');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'voicemute');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'kick');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'ban');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'spec999');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'balance');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'lockplayers');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'lockteam');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'shuffle');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'swap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'pause');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'nextmap');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'restart');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'botadmin');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'enablevote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'cancelvote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'passvote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'news');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'noinactivity');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'novote');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'nocensor');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'nobalance');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'novotelimit');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'noreason');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'teamcmds');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (4, 'silentcmds');
COMMIT;
-- add roles for level 5
BEGIN;
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'admintest');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'help');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'time');
@ -196,8 +342,10 @@ INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'teamcmds');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'silentcmds');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'spy');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'incognito');
INSERT INTO `level_role`(`level_id`, `role`) VALUES (5, 'immune');
COMMIT;
-- add console to players table
BEGIN;
INSERT INTO `player` (`id`, `guid`, `ip`, `level_id`) VALUES (1, 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', '127.0.0.1', 5);
INSERT INTO `alias` (`id`, `player_id`, `alias`, `cleanalias`, `lastused`, `used`) VALUES (1, 1, 'console', 'console', 0, 0);
COMMIT;

View file

@ -34,7 +34,6 @@ auth.PERM_LISTMAPS = "listmaps"
auth.PERM_LISTSPREES = "listsprees"
auth.PERM_LISTRULES = "listrules"
auth.PERM_LISTHISTORY = "listhistory"
auth.PERM_LISTWARNS = "listwarns"
auth.PERM_LISTBANS = "listbans"
auth.PERM_LISTALIASES = "listaliases"
auth.PERM_LISTLEVELS = "listlevels"
@ -67,7 +66,7 @@ auth.PERM_BAN = "ban"
auth.PERM_SPEC999 = "spec999"
auth.PERM_BALANCE = "balance"
auth.PERM_LOCKPLAYER = "lockplayers"
auth.PERM_LOCKPLAYER = "lockplayer"
auth.PERM_LOCKTEAM = "lockteam"
auth.PERM_SHUFFLE = "shuffle"
auth.PERM_SWAP = "swap"

View file

@ -35,7 +35,6 @@ local flags = {
[auth.PERM_LISTSPREES] = "I",
[auth.PERM_LISTRULES] = "C",
[auth.PERM_LISTHISTORY] = "f",
[auth.PERM_LISTWARNS] = "R",
[auth.PERM_LISTBANS] = "B",
[auth.PERM_LISTALIASES] = "f",
[auth.PERM_LISTLEVELS] = "s",