feat: legacy support atomcms with new permission system

This commit is contained in:
Niklas 2023-10-26 01:07:12 +02:00
parent fd8d2d1427
commit 8651e60bf8
2 changed files with 36 additions and 0 deletions

View File

@ -1,4 +1,11 @@
-- auto generated by mc8051.de -- auto generated by mc8051.de
SET FOREIGN_KEY_CHECKS = 0;
-- delete existing data
TRUNCATE permission_group_commands;
TRUNCATE permission_group_rights;
TRUNCATE permission_groups;
-- clear legacy permissions for support of autocms
TRUNCATE permissions;
-- permission group Member -- permission group Member
INSERT INTO permission_groups (id, name, description, level, prefix, prefix_color, badge, room_effect, log_enabled) VALUES ('8', 'Member', '', '1', '', '', '', '0', '1'); INSERT INTO permission_groups (id, name, description, level, prefix, prefix_color, badge, room_effect, log_enabled) VALUES ('8', 'Member', '', '1', '', '', '', '0', '1');
INSERT INTO permission_group_commands (group_id, command_name, setting_type) VALUES ('8', 'cmd_add_youtube_playlist', '0'); INSERT INTO permission_group_commands (group_id, command_name, setting_type) VALUES ('8', 'cmd_add_youtube_playlist', '0');
@ -158,6 +165,8 @@ INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES
INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('8', 'acc_unkickable', '0'); INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('8', 'acc_unkickable', '0');
INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('8', 'acc_unlimited_bots', '0'); INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('8', 'acc_unlimited_bots', '0');
INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('8', 'acc_unlimited_pets', '0'); INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('8', 'acc_unlimited_pets', '0');
-- legacy table
INSERT INTO permissions (id, rank_name, prefix, prefix_color) VALUES ('8', 'Member', '', '');
-- permission group VIP -- permission group VIP
@ -319,6 +328,8 @@ INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES
INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('9', 'acc_unkickable', '0'); INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('9', 'acc_unkickable', '0');
INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('9', 'acc_unlimited_bots', '0'); INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('9', 'acc_unlimited_bots', '0');
INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('9', 'acc_unlimited_pets', '0'); INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('9', 'acc_unlimited_pets', '0');
-- legacy table
INSERT INTO permissions (id, rank_name, prefix, prefix_color) VALUES ('9', 'VIP', '', '');
-- permission group Placeholder -- permission group Placeholder
@ -480,6 +491,8 @@ INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES
INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('10', 'acc_unkickable', '0'); INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('10', 'acc_unkickable', '0');
INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('10', 'acc_unlimited_bots', '0'); INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('10', 'acc_unlimited_bots', '0');
INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('10', 'acc_unlimited_pets', '0'); INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('10', 'acc_unlimited_pets', '0');
-- legacy table
INSERT INTO permissions (id, rank_name, prefix, prefix_color) VALUES ('10', 'Placeholder', '', '');
-- permission group Support -- permission group Support
@ -641,6 +654,8 @@ INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES
INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('11', 'acc_unkickable', '0'); INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('11', 'acc_unkickable', '0');
INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('11', 'acc_unlimited_bots', '0'); INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('11', 'acc_unlimited_bots', '0');
INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('11', 'acc_unlimited_pets', '0'); INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('11', 'acc_unlimited_pets', '0');
-- legacy table
INSERT INTO permissions (id, rank_name, prefix, prefix_color) VALUES ('11', 'Support', 'SUP', '');
-- permission group Moderator -- permission group Moderator
@ -802,6 +817,8 @@ INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES
INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('12', 'acc_unkickable', '0'); INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('12', 'acc_unkickable', '0');
INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('12', 'acc_unlimited_bots', '0'); INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('12', 'acc_unlimited_bots', '0');
INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('12', 'acc_unlimited_pets', '0'); INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('12', 'acc_unlimited_pets', '0');
-- legacy table
INSERT INTO permissions (id, rank_name, prefix, prefix_color) VALUES ('12', 'Moderator', 'MOD', '#d620b8');
-- permission group Super Mod -- permission group Super Mod
@ -963,6 +980,8 @@ INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES
INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('13', 'acc_unkickable', '1'); INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('13', 'acc_unkickable', '1');
INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('13', 'acc_unlimited_bots', '1'); INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('13', 'acc_unlimited_bots', '1');
INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('13', 'acc_unlimited_pets', '1'); INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('13', 'acc_unlimited_pets', '1');
-- legacy table
INSERT INTO permissions (id, rank_name, prefix, prefix_color) VALUES ('13', 'Super Mod', 'ADM', '#4220d6');
-- permission group Admin -- permission group Admin
@ -1124,5 +1143,8 @@ INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES
INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('14', 'acc_unkickable', '1'); INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('14', 'acc_unkickable', '1');
INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('14', 'acc_unlimited_bots', '1'); INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('14', 'acc_unlimited_bots', '1');
INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('14', 'acc_unlimited_pets', '1'); INSERT INTO permission_group_rights (group_id, right_name, setting_type) VALUES ('14', 'acc_unlimited_pets', '1');
-- legacy table
INSERT INTO permissions (id, rank_name, prefix, prefix_color) VALUES ('14', 'Admin', 'ADM', '#de1f1f');
SET FOREIGN_KEY_CHECKS = 1;

View File

@ -49,6 +49,16 @@ def generate_insert_sql(table_name, data):
with open("perms_groups.sql", 'w', encoding="utf-8") as file: with open("perms_groups.sql", 'w', encoding="utf-8") as file:
file.write(f"-- auto generated by mc8051.de\n") file.write(f"-- auto generated by mc8051.de\n")
file.write(f"SET FOREIGN_KEY_CHECKS = 0;\n")
file.write(f"-- delete existing data\n")
file.write(f"TRUNCATE permission_group_commands;\n")
file.write(f"TRUNCATE permission_group_rights;\n")
file.write(f"TRUNCATE permission_groups;\n")
file.write(f"-- clear legacy permissions for support of autocms\n")
file.write(f"TRUNCATE permissions;\n")
for group in groups: for group in groups:
file.write(f"-- permission group {group['name']}\n") file.write(f"-- permission group {group['name']}\n")
group_id = group["id"] group_id = group["id"]
@ -67,4 +77,8 @@ with open("perms_groups.sql", 'w', encoding="utf-8") as file:
sql = generate_insert_sql("permission_group_rights", {"group_id": group_id, "right_name": key, "setting_type": group[key]}) sql = generate_insert_sql("permission_group_rights", {"group_id": group_id, "right_name": key, "setting_type": group[key]})
file.write(sql + "\n") file.write(sql + "\n")
file.write("-- legacy table\n")
sql = generate_insert_sql("permissions", {"id": group_id, "rank_name": group["name"], "prefix": group["prefix"], "prefix_color": group["prefix_color"]})
file.write(sql + "\n")
file.write("\n\n") file.write("\n\n")
file.write(f"SET FOREIGN_KEY_CHECKS = 1;\n")