mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-29 06:57:42 +01:00
Make DB admin ranks more useful (#29906)
* Make DB admin ranks more useful * Avoid error message when cancelling permission toggle, allow adding localhost admins as real admins. * Lint. * Don't SQL error when a previously-unseen player connects. * Use ckey of permission editor, not mob name. * Strikethrough * Order in the list. * Deadmin, readmin, and 2fa. * Correct merge error --------- Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>
This commit is contained in:
@@ -879,119 +879,10 @@ GLOBAL_LIST_INIT(view_logs_verbs, list(
|
||||
|
||||
log_admin("[key_name(usr)] deadmined themself.")
|
||||
message_admins("[key_name_admin(usr)] deadmined themself.")
|
||||
if(check_rights(R_ADMIN, FALSE))
|
||||
GLOB.de_admins += ckey
|
||||
else
|
||||
GLOB.de_mentors += ckey
|
||||
deadmin()
|
||||
add_verb(src, /client/proc/readmin)
|
||||
update_active_keybindings()
|
||||
to_chat(src, "<span class='interface'>You are now a normal player.</span>")
|
||||
SSblackbox.record_feedback("tally", "admin_verb", 1, "De-admin") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
|
||||
|
||||
/client/proc/readmin()
|
||||
set name = "Re-admin self"
|
||||
set category = "Admin"
|
||||
set desc = "Regain your admin powers."
|
||||
|
||||
var/datum/admins/D = GLOB.admin_datums[ckey]
|
||||
var/rank = null
|
||||
if(!GLOB.configuration.admin.use_database_admins)
|
||||
for(var/iterator_key in GLOB.configuration.admin.ckey_rank_map)
|
||||
var/_ckey = ckey(iterator_key) // Snip out formatting
|
||||
if(ckey != _ckey)
|
||||
continue
|
||||
rank = GLOB.configuration.admin.ckey_rank_map[iterator_key]
|
||||
break
|
||||
else
|
||||
if(!SSdbcore.IsConnected())
|
||||
to_chat(src, "Warning, MYSQL database is not connected.")
|
||||
return
|
||||
|
||||
var/datum/db_query/rank_read = SSdbcore.NewQuery(
|
||||
"SELECT admin_rank FROM admin WHERE ckey=:ckey",
|
||||
list("ckey" = ckey)
|
||||
)
|
||||
|
||||
if(!rank_read.warn_execute())
|
||||
qdel(rank_read)
|
||||
return FALSE
|
||||
|
||||
while(rank_read.NextRow())
|
||||
rank = ckeyEx(rank_read.item[1])
|
||||
|
||||
qdel(rank_read)
|
||||
if(!D)
|
||||
D = try_localhost_autoadmin()
|
||||
if(!D)
|
||||
if(!GLOB.configuration.admin.use_database_admins)
|
||||
if(GLOB.admin_ranks[rank] == null)
|
||||
error("Error while re-adminning [src], admin rank ([rank]) does not exist.")
|
||||
to_chat(src, "Error while re-adminning, admin rank ([rank]) does not exist.")
|
||||
return
|
||||
|
||||
// Do a little check here
|
||||
if(GLOB.configuration.system.is_production && (GLOB.admin_ranks[rank] & R_ADMIN) && prefs._2fa_status == _2FA_DISABLED) // If they are an admin and their 2FA is disabled
|
||||
to_chat(src,"<span class='boldannounceooc'><big>You do not have 2FA enabled. Admin verbs will be unavailable until you have enabled 2FA.</big></span>") // Very fucking obvious
|
||||
return
|
||||
D = new(rank, GLOB.admin_ranks[rank], ckey)
|
||||
else
|
||||
if(!SSdbcore.IsConnected())
|
||||
to_chat(src, "Warning, MYSQL database is not connected.")
|
||||
return
|
||||
|
||||
var/datum/db_query/admin_read = SSdbcore.NewQuery(
|
||||
"SELECT ckey, admin_rank, flags FROM admin WHERE ckey=:ckey",
|
||||
list("ckey" = ckey)
|
||||
)
|
||||
|
||||
if(!admin_read.warn_execute())
|
||||
qdel(admin_read)
|
||||
return FALSE
|
||||
|
||||
while(admin_read.NextRow())
|
||||
var/admin_ckey = admin_read.item[1]
|
||||
var/admin_rank = admin_read.item[2]
|
||||
var/flags = admin_read.item[3]
|
||||
if(!admin_ckey)
|
||||
to_chat(src, "Error while re-adminning, ckey [admin_ckey] was not found in the admin database.")
|
||||
qdel(admin_read)
|
||||
return
|
||||
if(admin_rank == "Removed") //This person was de-adminned. They are only in the admin list for archive purposes.
|
||||
to_chat(src, "Error while re-adminning, ckey [admin_ckey] is not an admin.")
|
||||
qdel(admin_read)
|
||||
return
|
||||
|
||||
if(istext(flags))
|
||||
flags = text2num(flags)
|
||||
var/client/check_client = GLOB.directory[ckey]
|
||||
// Do a little check here
|
||||
if(GLOB.configuration.system.is_production && (flags & R_ADMIN) && check_client.prefs._2fa_status == _2FA_DISABLED) // If they are an admin and their 2FA is disabled
|
||||
to_chat(src,"<span class='boldannounceooc'><big>You do not have 2FA enabled. Admin verbs will be unavailable until you have enabled 2FA.</big></span>") // Very fucking obvious
|
||||
qdel(admin_read)
|
||||
return
|
||||
D = new(admin_rank, flags, ckey)
|
||||
qdel(admin_read)
|
||||
|
||||
var/client/C = GLOB.directory[ckey]
|
||||
D.associate(C)
|
||||
update_active_keybindings()
|
||||
message_admins("[key_name_admin(usr)] re-adminned themselves.")
|
||||
log_admin("[key_name(usr)] re-adminned themselves.")
|
||||
GLOB.de_admins -= ckey
|
||||
GLOB.de_mentors -= ckey
|
||||
if(istype(mob, /mob/dead/observer))
|
||||
var/mob/dead/observer/O = mob
|
||||
O.update_admin_actions()
|
||||
SSblackbox.record_feedback("tally", "admin_verb", 1, "Re-admin")
|
||||
return
|
||||
else
|
||||
to_chat(src, "You are already an admin.")
|
||||
remove_verb(src, /client/proc/readmin)
|
||||
GLOB.de_admins -= ckey
|
||||
GLOB.de_mentors -= ckey
|
||||
return
|
||||
|
||||
/client/proc/toggle_log_hrefs()
|
||||
set name = "Toggle href logging"
|
||||
set category = "Server"
|
||||
|
||||
Reference in New Issue
Block a user