allows check_rights to accept either mobs or clients.

This commit is contained in:
NullSnapshot
2016-07-26 14:39:04 -07:00
committed by Yoshax
parent 3345ac5cd1
commit e987e2f0c4
3 changed files with 18 additions and 14 deletions

View File

@@ -13,6 +13,7 @@ var/list/admin_datums = list()
var/datum/feed_channel/admincaster_feed_channel = new /datum/feed_channel
var/admincaster_signature //What you'll sign the newsfeeds as
/datum/admins/New(initial_rank = "Temporary Admin", initial_rights = 0, ckey)
if(!ckey)
error("Admin datum created without a ckey argument. Datum has been deleted")
@@ -57,21 +58,24 @@ proc/admin_proc()
NOTE: It checks usr by default. Supply the "user" argument if you wish to check for a specific mob.
*/
/proc/check_rights(rights_required, show_msg=1, var/mob/user = usr)
if(user && user.client)
/proc/check_rights(rights_required, show_msg=1, var/client/C = usr)
if(ismob(C))
var/mob/M = C
C = M.client
if(C)
if(rights_required)
if(user.client.holder)
if(rights_required & user.client.holder.rights)
return 1
else
if(show_msg)
user << "<font color='red'>Error: You do not have sufficient rights to do that. You require one of the following flags:[rights2text(rights_required," ")].</font>"
else
if(user.client.holder)
if(rights_required & C.holder.rights)
return 1
else
if(show_msg)
user << "<font color='red'>Error: You are not an admin.</font>"
C << "<font color='red'>Error: You do not have sufficient rights to do that. You require one of the following flags:[rights2text(rights_required," ")].</font>"
else
if(C.holder)
return 1
else
if(show_msg)
C << "<font color='red'>Error: You are not an admin.</font>"
return 0
//probably a bit iffy - will hopefully figure out a better solution

View File

@@ -38,13 +38,13 @@
/obj/item/weapon/paper/admin/proc/generateHeader()
var/originhash = md5("[origin]")
var/challengehash = copytext(md5("[game_id]"),1,10) // changed to a hash of the game ID so it's more consistant but changes every round.
var/timehash = copytext(md5("[world.time]"),1,10)
var/text = null
//TODO change logo based on who you're contacting.
text = "<center><img src = ntlogo.png></br>"
text += "<b>[origin] Quantum Uplink Signed Message</b><br>"
text += "<font size = \"1\">Encryption key: [originhash]<br>"
text += "Challenge: [challengehash]<br></font></center><hr>"
text += "Challenge: [timehash]<br></font></center><hr>"
header = text

View File

@@ -201,6 +201,6 @@ var/list/adminfaxes = list() //cache for faxes that have been sent to admins
msg += "Receiving '[sent.name]' via secure connection ... <a href='?_src_=holder;AdminFaxView=\ref[sent]'>view message</a></span>"
for(var/client/C in admins)
if((R_ADMIN | R_MOD) & C.holder.rights)
if(check_rights((R_ADMIN|R_MOD),0,C))
C << msg
C << 'sound/effects/printer.ogg'