diff --git a/code/modules/admin/sql_ban_system.dm b/code/modules/admin/sql_ban_system.dm
index 58b11df0992..756fc367ab6 100644
--- a/code/modules/admin/sql_ban_system.dm
+++ b/code/modules/admin/sql_ban_system.dm
@@ -456,7 +456,7 @@
to_chat(usr, span_danger("Ban not [edit_id ? "edited" : "created"] because the following errors were present:\n[error_state.Join("\n")]"), confidential = TRUE)
return
if(edit_id)
- edit_ban(edit_id, player_key, ip_check, player_ip, cid_check, player_cid, use_last_connection, applies_to_admins, duration, interval, reason, mirror_edit, old_key, old_ip, old_cid, old_applies, page, admin_key, changes)
+ edit_ban(edit_id, player_key, ip_check, player_ip, cid_check, player_cid, use_last_connection, applies_to_admins, duration, interval, reason, mirror_edit, old_key, old_ip, old_cid, old_applies, page, admin_key, changes, roles_to_ban[1] == "Server")
else
create_ban(player_key, ip_check, player_ip, cid_check, player_cid, use_last_connection, applies_to_admins, duration, interval, severity, reason, roles_to_ban)
@@ -492,29 +492,8 @@
return
qdel(query_create_ban_get_player)
var/admin_ckey = usr.client.ckey
- if(applies_to_admins)
- var/datum/db_query/query_check_adminban_count = SSdbcore.NewQuery({"
- SELECT COUNT(DISTINCT bantime)
- FROM [format_table_name("ban")]
- WHERE
- a_ckey = :admin_ckey AND
- applies_to_admins = 1 AND
- unbanned_datetime IS NULL AND
- (expiration_time IS NULL OR expiration_time > NOW())
- "}, list("admin_ckey" = admin_ckey))
- if(!query_check_adminban_count.warn_execute()) //count distinct bantime to treat rolebans made at the same time as one ban
- qdel(query_check_adminban_count)
- return
- if(query_check_adminban_count.NextRow())
- var/adminban_count = text2num(query_check_adminban_count.item[1])
- var/max_adminbans = MAX_ADMINBANS_PER_ADMIN
- if(check_rights(R_PERMISSIONS, show_msg = FALSE) && (rank.can_edit_rights & R_EVERYTHING) == R_EVERYTHING) //edit rights are a more effective way to check hierarchical rank since many non-headmins have R_PERMISSIONS now
- max_adminbans = MAX_ADMINBANS_PER_HEADMIN
- if(adminban_count >= max_adminbans)
- to_chat(usr, span_danger("You've already logged [max_adminbans] admin ban(s) or more. Do not abuse this function!"), confidential = TRUE)
- qdel(query_check_adminban_count)
- return
- qdel(query_check_adminban_count)
+ if(applies_to_admins && !can_place_additional_admin_ban(admin_ckey))
+ return
var/admin_ip = usr.client.address
var/admin_cid = usr.client.computer_id
duration = text2num(duration)
@@ -523,7 +502,8 @@
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]"
+ var/is_server_ban = (roles_to_ban[1] == "Server")
+ var/note_reason = "Banned from [is_server_ban ? "the server" : " Roles: [roles_to_ban.Join(", ")]"] [isnull(duration) ? "permanently" : "for [time_message]"] - [reason]"
var/list/clients_online = GLOB.clients.Copy()
var/list/admins_online = list()
for(var/client/C in clients_online)
@@ -563,35 +543,23 @@
if(!SSdbcore.MassInsert(format_table_name("ban"), sql_ban, warn = TRUE, special_columns = special_columns))
return
var/target = ban_target_string(player_key, player_ip, player_cid)
- 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 [target]."
- 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]")
+ var/msg = "has created a [isnull(duration) ? "permanent" : "temporary [time_message]"] [applies_to_admins ? "admin " : ""][is_server_ban ? "server ban" : "role ban from [roles_to_ban.len] roles"] for [target]."
+ log_admin_private("[kn] [msg][is_server_ban ? "" : " Roles: [roles_to_ban.Join(", ")]"] Reason: [reason]")
+ message_admins("[kna] [msg][is_server_ban ? "" : " Roles: [roles_to_ban.Join("\n")]"]\nReason: [reason]")
if(applies_to_admins)
send2adminchat("BAN ALERT","[kn] [msg]")
if(player_ckey)
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, "[kna] [msg]")
- var/appeal_url = "No ban appeal url set!"
- appeal_url = CONFIG_GET(string/banappeals)
- var/is_admin = FALSE
- if(C)
- build_ban_cache(C)
- to_chat(C, span_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_danger("This ban is [isnull(duration) ? "permanent." : "temporary, it will be removed in [time_message]."] The round ID is [GLOB.round_id].")]
To appeal this ban go to [appeal_url]"), confidential = TRUE)
- if(GLOB.admin_datums[C.ckey] || GLOB.deadmins[C.ckey])
- is_admin = TRUE
- if(roles_to_ban[1] == "Server" && (!is_admin || (is_admin && applies_to_admins)))
- 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)
- to_chat(i, span_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_danger("This ban is [isnull(duration) ? "permanent." : "temporary, it will be removed in [time_message]."] The round ID is [GLOB.round_id].")]
To appeal this ban go to [appeal_url]"), confidential = TRUE)
- if(GLOB.admin_datums[i.ckey] || GLOB.deadmins[i.ckey])
- is_admin = TRUE
- if(roles_to_ban[1] == "Server" && (!is_admin || (is_admin && applies_to_admins)))
- qdel(i)
+
+ var/player_ban_notification = span_boldannounce("You have been [applies_to_admins ? "admin " : ""]banned by [usr.client.key] from [is_server_ban ? "the server" : " Roles: [roles_to_ban.Join(", ")]"].\nReason: [reason]
[span_danger("This ban is [isnull(duration) ? "permanent." : "temporary, it will be removed in [time_message]."] The round ID is [GLOB.round_id].")]")
+ var/other_ban_notification = span_boldannounce("Another player sharing your IP or CID has been banned by [usr.client.key] from [is_server_ban ? "the server" : " Roles: [roles_to_ban.Join(", ")]"].\nReason: [reason]
[span_danger("This ban is [isnull(duration) ? "permanent." : "temporary, it will be removed in [time_message]."] The round ID is [GLOB.round_id].")]")
+
+ notify_all_banned_players(player_ckey, player_ip, player_cid, player_ban_notification, other_ban_notification, is_server_ban, applies_to_admins)
+
+ var/datum/admin_help/linked_ahelp_ticket = admin_ticket_log(player_ckey, "[kna] [msg]")
+
+ if(is_server_ban && linked_ahelp_ticket)
+ linked_ahelp_ticket.Resolve()
/datum/admins/proc/unban_panel(player_key, admin_key, player_ip, player_cid, page = 0)
if(!check_rights(R_BAN))
@@ -701,24 +669,23 @@
var/ban_datetime = query_unban_search_bans.item[2]
var/ban_round_id = query_unban_search_bans.item[3]
var/role = query_unban_search_bans.item[4]
- //make the href for unban here so only the search parameters are passed
- var/unban_href = "Unban"
var/expiration_time = query_unban_search_bans.item[5]
//we don't cast duration as num because if the duration is large enough to be converted to scientific notation by byond then the + character gets lost when passed through href causing SQL to interpret '4.321e 007' as '4'
var/duration = query_unban_search_bans.item[6]
var/expired = query_unban_search_bans.item[7]
var/applies_to_admins = text2num(query_unban_search_bans.item[8])
var/reason = query_unban_search_bans.item[9]
- player_key = query_unban_search_bans.item[10]
- player_ip = query_unban_search_bans.item[11]
- player_cid = query_unban_search_bans.item[12]
- admin_key = query_unban_search_bans.item[13]
+ var/banned_player_key = query_unban_search_bans.item[10]
+ var/banned_player_ip = query_unban_search_bans.item[11]
+ var/banned_player_cid = query_unban_search_bans.item[12]
+ var/banning_admin_key = query_unban_search_bans.item[13]
var/edits = query_unban_search_bans.item[14]
var/unban_datetime = query_unban_search_bans.item[15]
var/unban_key = query_unban_search_bans.item[16]
var/unban_round_id = query_unban_search_bans.item[17]
- var/target = ban_target_string(player_key, player_ip, player_cid)
- output += "