Ban editing and logging fixes (#42148)

Fixes #42146
Fixes ban created notes being double escaped.
Fixes admin tickets not being resolved for a disconnected client when banned.
Re-adds ban reason to admin log for a ban as requested
This commit is contained in:
Jordie
2019-01-02 00:31:42 +13:00
committed by oranges
parent d566771b20
commit f0cdd841da
+10 -11
View File
@@ -425,6 +425,10 @@
interval = sanitizeSQL(interval)
else
interval = "MINUTE"
var/time_message = "[duration] [lowertext(interval)]" //no DisplayTimeText because our duration is of variable interval type
if(duration > 1) //pluralize the interval if necessary
time_message += "s"
var/note_reason = "Banned from [roles_to_ban[1] == "Server" ? "the server" : " Roles: [roles_to_ban.Join(", ")]"] [isnull(duration) ? "permanently" : "for [time_message]"] - [reason]"
reason = sanitizeSQL(reason)
var/list/clients_online = GLOB.clients.Copy()
var/list/admins_online = list()
@@ -456,15 +460,11 @@
))
if(!SSdbcore.MassInsert(format_table_name("ban"), sql_ban, warn = 1))
return
var/time_message = "[duration] [lowertext(interval)]" //no DisplayTimeText because our duration is of variable interval type
if(duration > 1) //pluralize the interval if necessary
time_message += "s"
var/msg = "has created a [isnull(duration) ? "permanent" : "temporary [time_message]"] [applies_to_admins ? "admin " : ""][roles_to_ban[1] == "Server" ? "server ban" : "role ban from [roles_to_ban.len] roles"] for [player_key]."
log_admin_private("[kn] [msg][roles_to_ban[1] == "Server" ? "" : " Roles: [roles_to_ban.Join(", ")]"]")
message_admins("[kna] [msg][roles_to_ban[1] == "Server" ? "" : " Roles: [roles_to_ban.Join("\n")]"]")
log_admin_private("[kn] [msg][roles_to_ban[1] == "Server" ? "" : " Roles: [roles_to_ban.Join(", ")]"] Reason: [reason]")
message_admins("[kna] [msg][roles_to_ban[1] == "Server" ? "" : " Roles: [roles_to_ban.Join("\n")]"]\nReason: [reason]")
if(applies_to_admins)
send2irc("BAN ALERT","[kn] [msg]")
var/note_reason = "Banned from [roles_to_ban[1] == "Server" ? "the server" : " Roles: [roles_to_ban.Join(", ")]"] [isnull(duration) ? "permanently" : "for [time_message]"] - [reason]"
create_message("note", player_ckey, admin_ckey, note_reason, null, null, 0, 0, null, 0, severity)
var/client/C = GLOB.directory[player_ckey]
var/datum/admin_help/AH = admin_ticket_log(player_ckey, msg)
@@ -473,10 +473,9 @@
if(C)
build_ban_cache(C)
to_chat(C, "<span class='boldannounce'>You have been [applies_to_admins ? "admin " : ""]banned by [usr.client.key] from [roles_to_ban[1] == "Server" ? "the server" : " Roles: [roles_to_ban.Join(", ")]"].\nReason: [reason]</span><br><span class='danger'>This ban is [isnull(duration) ? "permanent." : "temporary, it will be removed in [time_message]."] The round ID is [GLOB.round_id].</span><br><span class='danger'>To appeal this ban go to [appeal_url]</span>")
if(roles_to_ban[1] == "Server")
if(AH)
AH.Resolve()
qdel(C)
qdel(C)
if(roles_to_ban[1] == "Server" && AH)
AH.Resolve()
for(var/client/i in GLOB.clients - C)
if(i.address == player_ip || i.computer_id == player_cid)
build_ban_cache(i)
@@ -664,7 +663,7 @@
var/list/changes_text= list()
var/list/changes_keys = list()
for(var/i in changes)
changes_text += "[i]: [changes[i]]"
changes_text += "[sanitizeSQL(i)]: [sanitizeSQL(changes[i])]"
changes_keys += i
var/where = "id = [sanitizeSQL(ban_id)]"
if(text2num(mirror_edit))