Ban refactor part 1/3 - Removes appearance bans (#17125)

This commit is contained in:
AffectedArc07
2021-11-18 13:24:50 +00:00
committed by GitHub
parent 3a77df7518
commit 01044ab481
8 changed files with 1 additions and 175 deletions
-1
View File
@@ -120,7 +120,6 @@ GLOBAL_VAR_INIT(nologevent, 0)
body += "<A href='?_src_=holder;boot2=[M.UID()]'>Kick</A> | "
body += "<A href='?_src_=holder;newban=[M.UID()];dbbanaddckey=[M.ckey]'>Ban</A> | "
body += "<A href='?_src_=holder;jobban2=[M.UID()];dbbanaddckey=[M.ckey]'>Jobban</A> | "
body += "<A href='?_src_=holder;appearanceban=[M.UID()];dbbanaddckey=[M.ckey]'>Appearance Ban</A> | "
body += "<A href='?_src_=holder;shownoteckey=[M.ckey]'>Notes</A> | "
body += "<A href='?_src_=holder;viewkarma=[M.ckey]'>View Karma</A> | "
if(GLOB.configuration.url.forum_playerinfo_url)
-99
View File
@@ -1,99 +0,0 @@
//ban people from using custom names and appearances. that'll show 'em.
GLOBAL_VAR(appearanceban_runonce) //Updates legacy bans with new info
GLOBAL_LIST_EMPTY(appearance_keylist) //to store the keys
/proc/appearance_fullban(mob/M, reason)
if(!M || !M.key) return
GLOB.appearance_keylist.Add(text("[M.ckey] ## [reason]"))
appearance_savebanfile()
/proc/appearance_client_fullban(ckey)
if(!ckey) return
GLOB.appearance_keylist.Add(text("[ckey]"))
appearance_savebanfile()
//returns a reason if M is banned, returns 0 otherwise
/proc/appearance_isbanned(mob/M)
if(M)
for(var/s in GLOB.appearance_keylist)
if(findtext(s, "[M.ckey]") == 1)
var/startpos = findtext(s, "## ") + 3
if(startpos && startpos < length(s))
var/text = copytext(s, startpos, 0)
if(text)
return text
return "Reason Unspecified"
return 0
/*
DEBUG
/mob/verb/list_all_appearances()
set name = "list all appearances"
for(var/s in appearance_keylist)
to_chat(world, s)
/mob/verb/reload_appearances()
set name = "reload appearances"
appearance_loadbanfile()
*/
// AA 2020-11-25: This entire proc isnt even called. What the actual fuck.
// AA 2021-05-23: This entire proc STILL isnt even called. I am going to screan.
/proc/appearance_loadbanfile()
if(!GLOB.configuration.general.use_database_bans)
var/savefile/S=new("data/appearance_full.ban")
S["keys[0]"] >> GLOB.appearance_keylist
log_admin("Loading appearance_rank")
S["runonce"] >> GLOB.appearanceban_runonce
if(!length(GLOB.appearance_keylist))
GLOB.appearance_keylist=list()
log_admin("appearance_keylist was empty")
else
if(!SSdbcore.IsConnected())
log_world("Database connection failed. Reverting to the legacy ban system.")
GLOB.configuration.general.use_database_bans = FALSE
appearance_loadbanfile()
return
//appearance bans
var/datum/db_query/appearanceban_query = SSdbcore.NewQuery("SELECT ckey FROM ban WHERE bantype = 'APPEARANCE_BAN' AND NOT unbanned = 1")
if(!appearanceban_query.warn_execute())
qdel(appearanceban_query)
return FALSE
while(appearanceban_query.NextRow())
var/ckey = appearanceban_query.item[1]
GLOB.appearance_keylist.Add("[ckey]")
qdel(appearanceban_query)
/proc/appearance_savebanfile()
var/savefile/S=new("data/appearance_full.ban")
to_chat(S["keys[0]"], GLOB.appearance_keylist)
/proc/appearance_unban(mob/M)
appearance_remove("[M.ckey]")
appearance_savebanfile()
/proc/appearance_updatelegacybans()
if(!GLOB.appearanceban_runonce)
log_admin("Updating appearancefile!")
// Updates bans.. Or fixes them. Either way.
for(var/T in GLOB.appearance_keylist)
if(!T) continue
GLOB.appearanceban_runonce++ //don't run this update again
/proc/appearance_remove(X)
for(var/i = 1; i <= length(GLOB.appearance_keylist); i++)
if( findtext(GLOB.appearance_keylist[i], "[X]") )
GLOB.appearance_keylist.Remove(GLOB.appearance_keylist[i])
appearance_savebanfile()
return 1
return 0
-13
View File
@@ -37,10 +37,6 @@
bantype_str = "JOB_TEMPBAN"
bantype_pass = 1
isjobban = 1
if(BANTYPE_APPEARANCE)
bantype_str = "APPEARANCE_BAN"
duration = -1
bantype_pass = 1
if(BANTYPE_ADMIN_PERMA)
bantype_str = "ADMIN_PERMABAN"
duration = -1
@@ -214,9 +210,6 @@
bantype_str = "JOB_TEMPBAN"
bantype_pass = 1
isjobban = 1
if(BANTYPE_APPEARANCE)
bantype_str = "APPEARANCE_BAN"
bantype_pass = 1
if(BANTYPE_ADMIN_PERMA)
bantype_str = "ADMIN_PERMABAN"
bantype_pass = 1
@@ -459,7 +452,6 @@
output += "<option value='[BANTYPE_TEMP]'>TEMPBAN</option>"
output += "<option value='[BANTYPE_JOB_PERMA]'>JOB PERMABAN</option>"
output += "<option value='[BANTYPE_JOB_TEMP]'>JOB TEMPBAN</option>"
output += "<option value='[BANTYPE_APPEARANCE]'>APPEARANCE BAN</option>"
output += "<option value='[BANTYPE_ADMIN_PERMA]'>ADMIN PERMABAN</option>"
output += "<option value='[BANTYPE_ADMIN_TEMP]'>ADMIN TEMPBAN</option>"
output += "</select></td>"
@@ -501,7 +493,6 @@
output += "<option value='[BANTYPE_TEMP]'>TEMPBAN</option>"
output += "<option value='[BANTYPE_JOB_PERMA]'>JOB PERMABAN</option>"
output += "<option value='[BANTYPE_JOB_TEMP]'>JOB TEMPBAN</option>"
output += "<option value='[BANTYPE_APPEARANCE]'>APPEARANCE BAN</option>"
output += "<option value='[BANTYPE_ADMIN_PERMA]'>ADMIN PERMABAN</option>"
output += "<option value='[BANTYPE_ADMIN_TEMP]'>ADMIN TEMPBAN</option>"
output += "</select></td></tr></table>"
@@ -576,8 +567,6 @@
bantypesearch += "'JOB_PERMABAN' "
if(BANTYPE_JOB_TEMP)
bantypesearch += "'JOB_TEMPBAN' "
if(BANTYPE_APPEARANCE)
bantypesearch += "'APPEARANCE_BAN' "
if(BANTYPE_ADMIN_PERMA)
bantypesearch = "'ADMIN_PERMABAN' "
if(BANTYPE_ADMIN_TEMP)
@@ -629,8 +618,6 @@
typedesc = "<b>JOBBAN</b><br><font size='2'>([job])"
if("JOB_TEMPBAN")
typedesc = "<b>TEMP JOBBAN</b><br><font size='2'>([job])<br>([duration] minutes<br>Expires [expiration]"
if("APPEARANCE_BAN")
typedesc = "<b>APPEARANCE/NAME BAN</b>"
if("ADMIN_PERMABAN")
typedesc = "<b>ADMIN PERMABAN</b>"
if("ADMIN_TEMPBAN")
-55
View File
@@ -137,12 +137,6 @@
to_chat(usr, "<span class='warning'>Not enough parameters (Requires ckey, reason and job)</span>")
return
job_ban = TRUE
if(BANTYPE_APPEARANCE)
if(!banckey || !banreason)
to_chat(usr, "<span class='warning'>Not enough parameters (Requires ckey and reason)</span>")
return
banduration = null
banjob = null
if(BANTYPE_ADMIN_PERMA)
if(!banckey || !banreason)
to_chat(usr, "<span class='warning'>Not enough parameters (Requires ckey and reason)</span>")
@@ -493,55 +487,6 @@
GLOB.banlist_savefile.cd = "/base"
unbanpanel()
/////////////////////////////////////new ban stuff
else if(href_list["appearanceban"])
if(!check_rights(R_BAN))
return
var/mob/M = locateUID(href_list["appearanceban"])
if(!istype(M, /mob))
to_chat(usr, "<span class='warning'>This can only be used on instances of type /mob</span>")
return
if(!M.ckey) //sanity
to_chat(usr, "<span class='warning'>This mob has no ckey</span>")
return
var/ban_ckey_param = href_list["dbbanaddckey"]
var/banreason = appearance_isbanned(M)
if(banreason)
/* if(!config.ban_legacy_system)
to_chat(usr, "<span class='warning'>Unfortunately, database based unbanning cannot be done through this panel</span>")
DB_ban_panel(M.ckey)
return */
switch(alert("Reason: '[banreason]' Remove appearance ban?","Please Confirm","Yes","No"))
if("Yes")
log_admin("[key_name(usr)] removed [key_name(M)]'s appearance ban")
DB_ban_unban(M.ckey, BANTYPE_APPEARANCE)
appearance_unban(M)
message_admins("<span class='notice'>[key_name_admin(usr)] removed [key_name_admin(M)]'s appearance ban</span>", 1)
to_chat(M, "<span class='warning'><big><b>[usr.client.ckey] has removed your appearance ban.</b></big></span>")
else switch(alert("Appearance ban [M.ckey]?",,"Yes","No", "Cancel"))
if("Yes")
var/reason = input(usr,"Please state the reason","Reason") as message|null
if(!reason)
return
M = admin_ban_mobsearch(M, ban_ckey_param, usr)
log_admin("[key_name(usr)] appearance banned [key_name(M)]. \nReason: [reason]")
DB_ban_record(BANTYPE_APPEARANCE, M, -1, reason)
appearance_fullban(M, "[reason]; By [usr.ckey] on [time2text(world.realtime)]")
add_note(M.ckey, "Appearance banned - [reason]", null, usr.ckey, 0)
message_admins("<span class='notice'>[key_name_admin(usr)] appearance banned [key_name_admin(M)]</span>", 1)
to_chat(M, "<span class='warning'><big><b>You have been appearance banned by [usr.client.ckey].</b></big></span>")
to_chat(M, "<span class='danger'>The reason is: [reason]</span>")
to_chat(M, "<span class='warning'>Appearance ban can be lifted only upon request.</span>")
if(GLOB.configuration.url.banappeals_url)
to_chat(M, "<span class='warning'>To try to resolve this matter head to [GLOB.configuration.url.banappeals_url]</span>")
else
to_chat(M, "<span class='warning'>No ban appeals URL has been set.</span>")
if("No")
return
else if(href_list["jobban2"])
// if(!check_rights(R_BAN)) return