mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 10:12:45 +00:00
SERVER HOSTS: This commit replaces the existing admin-rank system. It is now more customizable. Admin.txt essentially works the same as it always has. Each line should look like: ckey - admin rank There is now however, an admin_ranks.txt. This textfile allows you to define ranks like so: admin rank +ADMIN +FUN +BUILD the +KEYWORD are flags adding permissions to that rank. There are brief descriptions in the text-file explaining what they do. You can now name the ranks anything you like, and give them the permissions you want them to have. This allows, for instance, ranks like: Game Admin on disciplinary +ADMIN +BAN This would give that game admin only the tools they need to admin. They would not have access to 'fun' verbs which control events and antags. There's lots of things you can do. For instance, a coder rank whom can debug stuff but cannot do admin tasks: Codermin +DEBUG +VAREDIT +SERVER There's lots you can do. As it evolves it will hopefully become more flexible. admin_ranks.txt defaults to use the old admin rank names. Apologies in advance as there will be a lot of anomalies, such as ranks losing verbs they once had. Please let me know about any problems. I can fix them quite easily simply by moving verbs between the lists or splitting the lists up into new flags. CODERS: There is now a check_rights(flags) proc. It check is usr is and admin and has -at least one of- the rights specified. It checks > usr < not src, so keep that in mind! If you need to check if something other than usr has specific tights, you can do if(holder.rights & R_ADMIN) etc. KNOWN ISSUES: +FUN probably needs to be split up into +MOBS and +EVENTS In-game promotion/demotion is currently disabled. It will be readded after everything else works ok. Erro's sql rights changes stuff is currently commented out. It will be re-added. There are still many many verbs which need updating. Apologies in advance for any inconvenience. git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4991 316c924e-a436-60f5-8080-3fe189b3f50e
143 lines
4.0 KiB
Plaintext
143 lines
4.0 KiB
Plaintext
var/list/admin_ranks = list() //list of all ranks with associated rights
|
|
|
|
//load our rank - > rights associations
|
|
/proc/load_admin_ranks()
|
|
admin_ranks.Cut()
|
|
|
|
var/previous_rights = 0
|
|
|
|
//load text from file
|
|
var/list/Lines = file2list("config/admin_ranks.txt")
|
|
|
|
//process each line seperately
|
|
for(var/line in Lines)
|
|
if(!length(line)) continue
|
|
if(copytext(line,1,2) == "#") continue
|
|
|
|
var/list/List = text2list(line,"+")
|
|
if(!List.len) continue
|
|
|
|
var/rank = ckeyEx(List[1])
|
|
switch(rank)
|
|
if(null,"") continue
|
|
if("Removed") continue //Reserved
|
|
|
|
var/rights = 0
|
|
for(var/i=2, i<=List.len, i++)
|
|
switch(ckey(List[i]))
|
|
if("@","prev") rights |= previous_rights
|
|
if("buildmode","build") rights |= R_BUILDMODE
|
|
if("admin") rights |= R_ADMIN
|
|
if("ban") rights |= R_BAN
|
|
if("fun") rights |= R_FUN
|
|
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
|
|
|
|
admin_ranks[rank] = rights
|
|
previous_rights = rights
|
|
|
|
#ifdef TESTING
|
|
var/msg = "Permission Sets Built:\n"
|
|
for(var/rank in admin_ranks)
|
|
msg += "\t[rank] - [admin_ranks[rank]]\n"
|
|
testing(msg)
|
|
#endif
|
|
|
|
|
|
/proc/load_admins()
|
|
//clear the datums references
|
|
admin_datums.Cut()
|
|
for(var/client/C in admins)
|
|
C.remove_admin_verbs()
|
|
C.holder = null
|
|
admins.Cut()
|
|
|
|
if(config.admin_legacy_system)
|
|
load_admin_ranks()
|
|
|
|
//load text from file
|
|
var/list/Lines = file2list("config/admins.txt")
|
|
|
|
//process each line seperately
|
|
for(var/line in Lines)
|
|
if(!length(line)) continue
|
|
if(copytext(line,1,2) == "#") continue
|
|
|
|
//Split the line at every "-"
|
|
var/list/List = text2list(line, "-")
|
|
if(!List.len) continue
|
|
|
|
//ckey is before the first "-"
|
|
var/ckey = ckey(List[1])
|
|
if(!ckey) continue
|
|
|
|
//rank follows the first "-"
|
|
var/rank = ""
|
|
if(List.len >= 2)
|
|
rank = ckeyEx(List[2])
|
|
|
|
//load permissions associated with this rank
|
|
var/rights = admin_ranks[rank]
|
|
|
|
//create the admin datum and store it for later use
|
|
var/datum/admins/D = new /datum/admins(rank, rights, ckey)
|
|
|
|
//find the client for a ckey if they are connected and associate them with the new admin datum
|
|
D.associate(directory[ckey])
|
|
|
|
else
|
|
//The current admin system uses SQL
|
|
var/user = sqlfdbklogin
|
|
var/pass = sqlfdbkpass
|
|
var/db = sqlfdbkdb
|
|
var/address = sqladdress
|
|
var/port = sqlport
|
|
|
|
var/DBConnection/dbcon = new()
|
|
|
|
dbcon.Connect("dbi:mysql:[db]:[address]:[port]","[user]","[pass]")
|
|
if(!dbcon.IsConnected())
|
|
diary << "Failed to connect to database in load_admins(). Reverting to legacy system."
|
|
config.admin_legacy_system = 1
|
|
load_admins()
|
|
return
|
|
|
|
var/DBQuery/query = dbcon.NewQuery("SELECT ckey, rank, level, flags FROM erro_admin")
|
|
query.Execute()
|
|
while(query.NextRow())
|
|
var/ckey = query.item[1]
|
|
var/rank = query.item[2]
|
|
if(rank == "Removed") return //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)
|
|
|
|
//find the client for a ckey if they are connected and associate them with the new admin datum
|
|
D.associate(directory[ckey])
|
|
|
|
if(!admin_datums)
|
|
diary << "The database query in load_admins() resulted in no admins being added to the list. Reverting to legacy system."
|
|
config.admin_legacy_system = 1
|
|
load_admins()
|
|
return
|
|
|
|
#ifdef TESTING
|
|
var/msg = "Admins Built:\n"
|
|
for(var/ckey in admin_datums)
|
|
var/rank
|
|
var/datum/admins/D = admin_datums[ckey]
|
|
if(D) rank = D.rank
|
|
msg += "\t[ckey] - [rank]\n"
|
|
testing(msg)
|
|
#endif
|
|
|
|
|