Files
Paradise/code/modules/admin/admin_ranks.dm
S34N 91660824fa Browser/TGUI Stat Panels (#24065)
* initial commit (broken)

* load the html

* fix this

* Fix various issues with browser statpanel

* Fix Alt Clicking opening up a window and Add back some object verbs to the browser stat panel

* Optimize stat panel and fix guardian verbs

* Restyles Stat Panel, Adds Subpanel Sub-Categories

* Use better layout for verbs in stat panel

* Updates statpanel verb widths to be more dynamic at higher screen resolutions.

* Adjust stat panel grid item widths and breakpoints

* refactors statpanel to use tgui API

* CI moment

* more CI

* this stupid thing

* Apply suggestions from code review

Co-authored-by: GDN <96800819+GDNgit@users.noreply.github.com>
Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>

* Update code/modules/client/client_procs.dm

* ci fix

* emergency mc debug view

* temp revert some code change suggestions due to massive runtiming

* proper atom click topic implementation

* optimise

* mob clicking in stat panels work

* yeet spell tab thingy

* yeet simple stat panel pref

* allow insertion of html into MC tab content

* tidy up status tab

* Apply suggestions from code review

* fix this

* fix CI

* oops

* fix index runtime

* fixes MC tab showing up for mentors, fixes runtime

* safeties!

* Return of theme support

* more fixes

* fix view range pref, tidy prefs tab

* Remove old stat panel from themes

* fixes

* make sure verbs don't go missing

* fix ooc/looc breaking

* Revert "make sure verbs don't go missing"

This reverts commit 7d07ad45ed.

* fix this properly

* fix stat panel hitting rate limiters

* fix borg status tab

* Object Window Niceties

* Adds file cycling for icon2base64

* optimizes icon2html() for icon files known to be in the rsc at compile time

* CI moment

* remove dupe emergency shuttle timers

* more robust verb updates

* statpanel tweaks

* zip archived changelog to avoid search results

* optimise

* fix mentor chat wonkyness when disabled

* debug log moment

* i am very smart

* reintroduce this because it was needed

* better time listings

* less jank

* stops telling admins they arent mentors

* returns MC tab pref for admins

* Update code/controllers/subsystem/SSstatpanel.dm

Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>

* lewcc

* OD typemaker prep

---------

Co-authored-by: GDN <96800819+GDNgit@users.noreply.github.com>
Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>
Co-authored-by: Aylong <alexanderkitsa@gmail.com>
Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
2024-03-07 10:31:36 -05:00

153 lines
5.1 KiB
Plaintext

GLOBAL_LIST_EMPTY(admin_ranks) //list of all ranks with associated rights
GLOBAL_PROTECT(admin_ranks) // this shit is being protected for obvious reasons
//load our rank - > rights associations
/proc/load_admin_ranks()
GLOB.admin_ranks.Cut()
var/previous_rights = 0
// Process each rank set seperately
// key: rank name | value: list of rights
for(var/rankname in GLOB.configuration.admin.rank_rights_map)
var/list/rank_right_tokens = GLOB.configuration.admin.rank_rights_map[rankname]
var/rights = 0
for(var/right_token in rank_right_tokens)
var/token = lowertext(splittext(right_token, "+")[2])
switch(token)
if("@","prev") rights |= previous_rights
if("buildmode","build") rights |= R_BUILDMODE
if("admin") rights |= R_ADMIN
if("ban") rights |= R_BAN
if("event") rights |= R_EVENT
if("server") rights |= R_SERVER
if("debug") rights |= R_DEBUG
if("permissions","rights") rights |= R_PERMISSIONS
if("possess") rights |= R_POSSESS
if("stealth") rights |= R_STEALTH
if("rejuv","rejuvinate") rights |= R_REJUVINATE
if("varedit") rights |= R_VAREDIT
if("everything","host","all") rights |= R_HOST
if("sound","sounds") rights |= R_SOUNDS
if("spawn","create") rights |= R_SPAWN
if("mod") rights |= R_MOD
if("mentor") rights |= R_MENTOR
if("proccall") rights |= R_PROCCALL
if("viewruntimes") rights |= R_VIEWRUNTIMES
if("maintainer") rights |= R_MAINTAINER
GLOB.admin_ranks[rankname] = rights
previous_rights = rights
#ifdef TESTING
var/msg = "Permission Sets Built:\n"
for(var/rank in GLOB.admin_ranks)
msg += "\t[rank] - [GLOB.admin_ranks[rank]]\n"
testing(msg)
#endif
/proc/load_admins(run_async = FALSE)
if(IsAdminAdvancedProcCall())
to_chat(usr, "<span class='boldannounce'>Admin reload blocked: Advanced ProcCall detected.</span>")
message_admins("[key_name(usr)] attempted to reload admins via advanced proc-call")
log_admin("[key_name(usr)] attempted to reload admins via advanced proc-call")
return
//clear the datums references
GLOB.admin_datums.Cut()
for(var/client/C in GLOB.admins)
C.hide_verbs()
C.holder = null
GLOB.admins.Cut()
// Remove all profiler access
for(var/A in world.GetConfig("admin"))
world.SetConfig("APP/admin", A, null)
if(!GLOB.configuration.admin.use_database_admins)
load_admin_ranks()
//process each line seperately
for(var/iterator_key in GLOB.configuration.admin.ckey_rank_map)
var/ckey = ckey(iterator_key) // Snip out formatting
var/rank = GLOB.configuration.admin.ckey_rank_map[iterator_key]
//load permissions associated with this rank
var/rights = GLOB.admin_ranks[rank]
//create the admin datum and store it for later use
var/datum/admins/D = new /datum/admins(rank, rights, ckey)
if(D.rights & R_DEBUG || D.rights & R_VIEWRUNTIMES) // Grants profiler access to anyone with R_DEBUG or R_VIEWRUNTIMES
world.SetConfig("APP/admin", ckey, "role=admin")
//find the client for a ckey if they are connected and associate them with the new admin datum
D.associate(GLOB.directory[ckey])
else
//The current admin system uses SQL
if(!SSdbcore.IsConnected())
log_world("Failed to connect to database in load_admins(). Reverting to legacy system.")
GLOB.configuration.admin.use_database_admins = FALSE
load_admins()
return
var/datum/db_query/query = SSdbcore.NewQuery("SELECT ckey, admin_rank, level, flags FROM admin")
if(!query.warn_execute(async=run_async))
qdel(query)
return
while(query.NextRow())
var/ckey = query.item[1]
var/rank = query.item[2]
if(rank == "Removed") continue //This person was de-adminned. They are only in the admin list for archive purposes.
var/rights = query.item[4]
if(istext(rights)) rights = text2num(rights)
var/datum/admins/D = new /datum/admins(rank, rights, ckey)
if(D.rights & R_DEBUG || D.rights & R_VIEWRUNTIMES) // Grants profiler access to anyone with R_DEBUG or R_VIEWRUNTIMES
world.SetConfig("APP/admin", ckey, "role=admin")
//find the client for a ckey if they are connected and associate them with the new admin datum
D.associate(GLOB.directory[ckey])
qdel(query)
if(!GLOB.admin_datums)
log_world("The database query in load_admins() resulted in no admins being added to the list. Reverting to legacy system.")
GLOB.configuration.admin.use_database_admins = FALSE
load_admins()
return
#ifdef TESTING
var/msg = "Admins Built:\n"
for(var/ckey in GLOB.admin_datums)
var/rank
var/datum/admins/D = GLOB.admin_datums[ckey]
if(D) rank = D.rank
msg += "\t[ckey] - [rank]\n"
testing(msg)
#endif
#ifdef TESTING
/client/verb/changerank(newrank in GLOB.admin_ranks)
if(holder)
holder.rank = newrank
holder.rights = GLOB.admin_ranks[newrank]
else
holder = new /datum/admins(newrank,GLOB.admin_ranks[newrank],ckey)
remove_admin_verbs()
holder.associate(src)
/client/verb/changerights(newrights as num)
if(holder)
holder.rights = newrights
else
holder = new /datum/admins("testing",newrights,ckey)
remove_admin_verbs()
holder.associate(src)
#endif