Skip to content

Commit

Permalink
[MIRROR] Turns the "Admin Permission Elevation Notification" into a m…
Browse files Browse the repository at this point in the history
…acro [MDB IGNORE](#1008)

* Turns the "Admin Permission Elevation Notification" into a macro (#80149)

---------

Co-authored-by: SkyratBot <[email protected]>
Co-authored-by: san7890 <[email protected]>
  • Loading branch information
3 people authored Dec 7, 2023
1 parent 2a6214a commit 84b7df1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 27 deletions.
1 change: 1 addition & 0 deletions code/__DEFINES/admin.dm
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,4 @@ GLOBAL_VAR_INIT(ghost_role_flags, ALL)
/// Used in logging uses of admin verbs (and sometimes some non-admin or debug verbs) to the blackbox
/// Only pass it a string key, the verb being used.
#define BLACKBOX_LOG_ADMIN_VERB(the_verb) SSblackbox.record_feedback("tally", "admin_verb", 1, the_verb)

7 changes: 7 additions & 0 deletions code/__HELPERS/admin.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/// Returns if the given client is an admin, REGARDLESS of if they're deadminned or not.
/proc/is_admin(client/client)
return !isnull(GLOB.admin_datums[client.ckey]) || !isnull(GLOB.deadmins[client.ckey])

/// Sends a message in the event that someone attempts to elevate their permissions through invoking a certain proc.
/proc/alert_to_permissions_elevation_attempt(mob/user)
var/message = " has tried to elevate permissions!"
message_admins(key_name_admin(user) + message)
log_admin(key_name(user) + message)

12 changes: 3 additions & 9 deletions code/modules/admin/admin_ranks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ GLOBAL_PROTECT(protected_ranks)

/datum/admin_rank/New(init_name, init_rights, init_exclude_rights, init_edit_rights)
if(IsAdminAdvancedProcCall())
var/msg = " has tried to elevate permissions!"
message_admins("[key_name_admin(usr)][msg]")
log_admin("[key_name(usr)][msg]")
alert_to_permissions_elevation_attempt(usr)
if (name == "NoRank") //only del if this is a true creation (and not just a New() proc call), other wise trialmins/coders could abuse this to deadmin other admins
QDEL_IN(src, 0)
CRASH("Admin proc call creation of admin datum")
Expand All @@ -35,9 +33,7 @@ GLOBAL_PROTECT(protected_ranks)

/datum/admin_rank/Destroy()
if(IsAdminAdvancedProcCall())
var/msg = " has tried to elevate permissions!"
message_admins("[key_name_admin(usr)][msg]")
log_admin("[key_name(usr)][msg]")
alert_to_permissions_elevation_attempt(usr)
return QDEL_HINT_LETMELIVE
. = ..()

Expand All @@ -47,9 +43,7 @@ GLOBAL_PROTECT(protected_ranks)
// Adds/removes rights to this admin_rank
/datum/admin_rank/proc/process_keyword(group, group_count, datum/admin_rank/previous_rank)
if(IsAdminAdvancedProcCall())
var/msg = " has tried to elevate permissions!"
message_admins("[key_name_admin(usr)][msg]")
log_admin("[key_name(usr)][msg]")
alert_to_permissions_elevation_attempt(usr)
return
var/list/keywords = splittext(group, " ")
var/flag = 0
Expand Down
24 changes: 6 additions & 18 deletions code/modules/admin/holder2.dm
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ GLOBAL_PROTECT(href_token)

/datum/admins/New(list/datum/admin_rank/ranks, ckey, force_active = FALSE, protected)
if(IsAdminAdvancedProcCall())
var/msg = " has tried to elevate permissions!"
message_admins("[key_name_admin(usr)][msg]")
log_admin("[key_name(usr)][msg]")
alert_to_permissions_elevation_attempt(usr)
if (!target) //only del if this is a true creation (and not just a New() proc call), other wise trialmins/coders could abuse this to deadmin other admins
QDEL_IN(src, 0)
CRASH("Admin proc call creation of admin datum")
Expand All @@ -79,17 +77,13 @@ GLOBAL_PROTECT(href_token)

/datum/admins/Destroy()
if(IsAdminAdvancedProcCall())
var/msg = " has tried to elevate permissions!"
message_admins("[key_name_admin(usr)][msg]")
log_admin("[key_name(usr)][msg]")
alert_to_permissions_elevation_attempt(usr)
return QDEL_HINT_LETMELIVE
. = ..()

/datum/admins/proc/activate()
if(IsAdminAdvancedProcCall())
var/msg = " has tried to elevate permissions!"
message_admins("[key_name_admin(usr)][msg]")
log_admin("[key_name(usr)][msg]")
alert_to_permissions_elevation_attempt(usr)
return
GLOB.deadmins -= target
GLOB.admin_datums[target] = src
Expand All @@ -101,9 +95,7 @@ GLOBAL_PROTECT(href_token)

/datum/admins/proc/deactivate()
if(IsAdminAdvancedProcCall())
var/msg = " has tried to elevate permissions!"
message_admins("[key_name_admin(usr)][msg]")
log_admin("[key_name(usr)][msg]")
alert_to_permissions_elevation_attempt(usr)
return
GLOB.deadmins[target] = src
GLOB.admin_datums -= target
Expand All @@ -119,9 +111,7 @@ GLOBAL_PROTECT(href_token)

/datum/admins/proc/associate(client/client)
if(IsAdminAdvancedProcCall())
var/msg = " has tried to elevate permissions!"
message_admins("[key_name_admin(usr)][msg]")
log_admin("[key_name(usr)][msg]")
alert_to_permissions_elevation_attempt(usr)
return

if(!istype(client))
Expand Down Expand Up @@ -163,9 +153,7 @@ GLOBAL_PROTECT(href_token)

/datum/admins/proc/disassociate()
if(IsAdminAdvancedProcCall())
var/msg = " has tried to elevate permissions!"
message_admins("[key_name_admin(usr)][msg]")
log_admin("[key_name(usr)][msg]")
alert_to_permissions_elevation_attempt(usr)
return
if(owner)
GLOB.admins -= owner
Expand Down

0 comments on commit 84b7df1

Please sign in to comment.