Files
Bubberstation/code/modules/admin/holder2.dm
carnie bbe7354265 Fixes #1147 - type-mismatch
Added helper: /proc/findchar(haystack, needles, start=1, end=0)
works like findtext except it finds the first occurrence of one of the characters from the needles string, within haystack.

Permissions can now be removed as well as added, by replacing the + with a -. e.g. +BAN adds bans permissions, -BAN removes them. This applies to admin_ranks.txt and the permissions panel.

Verb overrides are now possible for admins_ranks. Specific verbs can be forced-on, or forced-off via keywords like +/client/proc/mimespeak or -/client/verb/ooc. This applies both to admin_ranks.txt and the permissions panel. SQL system is not compatible.

admin_ranks are now datums. This means admin_ranks actually behave more like permission groups as intended.
When you temporarily modify an admin's permissions via the permissions panel, their rank_name is appended with "([ckey])". This prevents modifications to their rights affecting everyone.

admin rank names now support - _ and @ characters (since ckeyEx() does not strip these).

SQL permissions system was modified. SQL databases will have to be updated or they will no longer work.

WARNING: admin_ranks.txt and admins.txt format has changed slightly! You will need to redo those txt files!
2013-08-14 18:10:26 +01:00

91 lines
3.1 KiB
Plaintext

var/list/admin_datums = list()
/datum/admins
var/datum/admin_rank/rank
var/client/owner = null
var/fakekey = null
var/datum/marked_datum
var/admincaster_screen = 0 //See newscaster.dm under machinery for a full description
var/datum/feed_message/admincaster_feed_message = new /datum/feed_message //These two will act as holders.
var/datum/feed_channel/admincaster_feed_channel = new /datum/feed_channel
var/admincaster_signature //What you'll sign the newsfeeds as
/datum/admins/New(datum/admin_rank/R, ckey)
if(!ckey)
error("Admin datum created without a ckey argument. Datum has been deleted")
del(src)
return
if(!istype(R))
error("Admin datum created without a rank. Datum has been deleted")
del(src)
return
rank = R
admincaster_signature = "Nanotrasen Officer #[rand(0,9)][rand(0,9)][rand(0,9)]"
admin_datums[ckey] = src
/datum/admins/proc/associate(client/C)
if(istype(C))
owner = C
owner.holder = src
owner.add_admin_verbs() //TODO
admins |= C
/datum/admins/proc/disassociate()
if(owner)
admins -= owner
owner.remove_admin_verbs()
owner.holder = null
owner = null
/*
checks if usr is an admin with at least ONE of the flags in rights_required. (Note, they don't need all the flags)
if rights_required == 0, then it simply checks if they are an admin.
if it doesn't return 1 and show_msg=1 it will prints a message explaining why the check has failed
generally it would be used like so:
proc/admin_proc()
if(!check_rights(R_ADMIN)) return
world << "you have enough rights!"
NOTE: it checks usr! not src! So if you're checking somebody's rank in a proc which they did not call
you will have to do something like if(client.rights & R_ADMIN) yourself.
*/
/proc/check_rights(rights_required, show_msg=1)
if(usr && usr.client)
if (check_rights_for(usr.client, rights_required))
return 1
else
if(show_msg)
usr << "<font color='red'>Error: You do not have sufficient rights to do that. You require one of the following flags:[rights2text(rights_required," ")].</font>"
return 0
//probably a bit iffy - will hopefully figure out a better solution
/proc/check_if_greater_rights_than(client/other)
if(usr && usr.client)
if(usr.client.holder)
if(!other || !other.holder)
return 1
if(usr.client.holder.rank.rights != other.holder.rank.rights) //Check values smaller than 65536
if( (usr.client.holder.rank.rights & other.holder.rank.rights) == other.holder.rank.rights )
return 1 //we have all the rights they have and more
usr << "<font color='red'>Error: Cannot proceed. They have greater or equal rights to us.</font>"
return 0
/client/proc/deadmin()
admin_datums -= ckey
if(holder)
holder.disassociate()
del(holder)
return 1
//This proc checks whether subject has at least ONE of the rights specified in rights_required.
/proc/check_rights_for(client/subject, rights_required)
if(subject && subject.holder && subject.holder.rank)
if(rights_required && !(rights_required & subject.holder.rank.rights))
return 0
return 1
return 0