From bf63fa766a2b50f2f1574b42c6e2db1d50c5c1ff Mon Sep 17 00:00:00 2001 From: CitadelStationBot Date: Mon, 26 Mar 2018 04:40:12 -0500 Subject: [PATCH] [MIRROR] Adds sync to tgdb button for permission panel (#6086) * Merge pull request #36413 from Jordie0608/ifyoupressthisbuttonthreetimesatmidnighttheghostoferroragewillstealyourholder Adds sync to tgdb button for permission panel * Adds sync to tgdb button for permission panel --- code/modules/admin/permissionedit.dm | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/code/modules/admin/permissionedit.dm b/code/modules/admin/permissionedit.dm index 15fc906e05..b6d8c11e67 100644 --- a/code/modules/admin/permissionedit.dm +++ b/code/modules/admin/permissionedit.dm @@ -42,7 +42,7 @@ deadminlink = " \[DA\]" output += "" - output += "[adm_ckey] [deadminlink]\[-\]" + output += "[adm_ckey]
[deadminlink]\[-\]\[SYNC TGDB\]" output += "[D.rank.name]" output += "[rights2text(D.rank.include_rights," ")]" output += "[rights2text(D.rank.exclude_rights," ", "-")]" @@ -72,7 +72,7 @@ var/use_db var/task = href_list["editrights"] var/skip - if(task == "activate" || task == "deactivate") + if(task == "activate" || task == "deactivate" || task == "sync") skip = TRUE if(!CONFIG_GET(flag/admin_legacy_system) && CONFIG_GET(flag/protect_legacy_admins) && task == "rank") if(admin_ckey in GLOB.protected_admins) @@ -102,9 +102,10 @@ D = GLOB.deadmins[admin_ckey] if(!D) return - if(!check_if_greater_rights_than_holder(D)) + if((task != "sync") && !check_if_greater_rights_than_holder(D)) message_admins("[key_name_admin(usr)] attempted to change the rank of [admin_ckey] without sufficient rights.") log_admin("[key_name(usr)] attempted to change the rank of [admin_ckey] without sufficient rights.") + return switch(task) if("add") admin_ckey = add_admin(use_db) @@ -121,6 +122,8 @@ force_readmin(admin_ckey, D) if("deactivate") force_deadmin(admin_ckey, D) + if("sync") + sync_lastadminrank(admin_ckey, D) edit_admin_permissions() /datum/admins/proc/add_admin(use_db) @@ -221,7 +224,7 @@ var/new_flags = input_bitfield(usr, "Include permission flags
[use_db ? "This will affect ALL admins with this rank." : "This will affect only the current admin [admin_ckey]"]", "admin_flags", D.rank.include_rights, 350, 590, allowed_edit_list = usr.client.holder.rank.can_edit_rights) if(isnull(new_flags)) return - var/new_exclude_flags = input_bitfield(usr, "Exclude permission flags
Flags enabled here will be removed from a rank.
Note these take precedence over included flags.
[use_db ? "This will affect ALL admins with this rank." : "This will affect only the current admin [admin_ckey]"]", "admin_flags", D.rank.exclude_rights, 350, 660, "red", usr.client.holder.rank.can_edit_rights) + var/new_exclude_flags = input_bitfield(usr, "Exclude permission flags
Flags enabled here will be removed from a rank.
Note these take precedence over included flags.
[use_db ? "This will affect ALL admins with this rank." : "This will affect only the current admin [admin_ckey]"]", "admin_flags", D.rank.exclude_rights, 350, 670, "red", usr.client.holder.rank.can_edit_rights) if(isnull(new_exclude_flags)) return var/new_can_edit_flags = input_bitfield(usr, "Editable permission flags
These are the flags this rank is allowed to edit if they have access to the permissions panel.
They will be unable to modify admins to a rank that has a flag not included here.
[use_db ? "This will affect ALL admins with this rank." : "This will affect only the current admin [admin_ckey]"]", "admin_flags", D.rank.can_edit_rights, 350, 710, allowed_edit_list = usr.client.holder.rank.can_edit_rights) @@ -275,3 +278,11 @@ D.associate(C) //link up with the client and add verbs message_admins("[key_name_admin(usr)] edited the permissions of [use_db ? " rank [D.rank.name] permanently" : "[admin_ckey] temporarily"]") log_admin("[key_name(usr)] edited the permissions of [use_db ? " rank [D.rank.name] permanently" : "[admin_ckey] temporarily"]") + +/datum/admins/proc/sync_lastadminrank(admin_ckey, datum/admins/D) + var/sqlrank = sanitizeSQL(D.rank.name) + admin_ckey = sanitizeSQL(admin_ckey) + var/datum/DBQuery/query_sync_lastadminrank = SSdbcore.NewQuery("UPDATE [format_table_name("player")] SET lastadminrank = '[sqlrank]' WHERE ckey = '[admin_ckey]'") + if(!query_sync_lastadminrank.warn_execute()) + return + to_chat(usr, "Sync of [admin_ckey] successful.")