Skip to content

Commit

Permalink
Revert "Fix mentor deadminning and admin loading (BeeStation#10426)"
Browse files Browse the repository at this point in the history
This reverts commit fc314a5.
  • Loading branch information
JixS4v authored Jul 10, 2024
1 parent 7382362 commit 4ea70da
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 64 deletions.
46 changes: 21 additions & 25 deletions code/modules/admin/holder2.dm
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ GLOBAL_PROTECT(href_token)
deadmined = FALSE
if (GLOB.directory[target])
associate(GLOB.directory[target]) //find the client for a ckey if they are connected and associate them with us
load_mentors()

/datum/admins/proc/deactivate()
if(IsAdminAdvancedProcCall())
Expand All @@ -106,6 +107,7 @@ GLOBAL_PROTECT(href_token)
disassociate()
C.add_verb(/client/proc/readmin)
C.update_special_keybinds()
load_mentors()

/datum/admins/proc/associate(client/C)
if(IsAdminAdvancedProcCall())
Expand All @@ -114,38 +116,32 @@ GLOBAL_PROTECT(href_token)
log_admin("[key_name(usr)][msg]")
return

if(!istype(C))
return
if(C.ckey != target)
var/msg = " has attempted to associate with [target]'s admin datum"
message_admins("[key_name_admin(C)][msg]")
log_admin("[key_name(C)][msg]")
return
if (deadmined)
activate()
owner = C
owner.holder = src
owner.add_admin_verbs() //TODO <--- todo what? the proc clearly exists and works since its the backbone to our entire admin system
owner.remove_verb(/client/proc/readmin)
owner.update_special_keybinds()
GLOB.admins |= C
if(istype(owner.mentor_datum))
owner.mentor_datum.activate()
if(istype(C))
if(C.ckey != target)
var/msg = " has attempted to associate with [target]'s admin datum"
message_admins("[key_name_admin(C)][msg]")
log_admin("[key_name(C)][msg]")
return
if (deadmined)
activate()
owner = C
owner.holder = src
owner.add_admin_verbs() //TODO <--- todo what? the proc clearly exists and works since its the backbone to our entire admin system
owner.remove_verb(/client/proc/readmin)
owner.update_special_keybinds()
GLOB.admins |= C

/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]")
return
if(!owner)
return
GLOB.admins -= owner
owner.remove_admin_verbs()
if(istype(owner.mentor_datum))
owner.mentor_datum.deactivate()
owner.holder = null
owner = null
if(owner)
GLOB.admins -= owner
owner.remove_admin_verbs()
owner.holder = null
owner = null

/datum/admins/proc/check_for_rights(rights_required)
if(rights_required && !(rights_required & rank.rights))
Expand Down
38 changes: 2 additions & 36 deletions code/modules/mentor/mentor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,8 @@
var/href_token
/// The Mentor Ticket Manager interface
var/datum/help_ui/mentor/mentor_interface
/// If this mentor datum is inactive due to de-adminning.
var/dementored = FALSE
/// If this mentor datum was created due to someone being an admin, but not a mentor.
/// This is used so that deadminning doesn't remove verbs if someone is both a mentor and an admin.
var/for_admin = FALSE

/datum/mentors/New(ckey, for_admin)
/datum/mentors/New(ckey)
if(!ckey)
QDEL_IN(src, 0)
stack_trace("Mentor datum created without a ckey: [ckey]")
Expand All @@ -28,7 +23,6 @@
return
name = "[ckey]'s mentor datum"
href_token = GenerateToken()
src.for_admin = for_admin
GLOB.mentor_datums[target] = src
// If they're logged in, let's assign their mentor datum now.
var/client/C = GLOB.directory[ckey]
Expand All @@ -43,10 +37,7 @@
return
owner = C
owner.mentor_datum = src
if(for_admin)
activate()
else
owner.add_mentor_verbs()
owner.add_mentor_verbs()
if(!check_rights_for(owner, R_ADMIN)) // add nonadmins to the mentor list.
GLOB.mentors |= owner

Expand Down Expand Up @@ -86,9 +77,6 @@
log_href_exploit(usr, " Tried to use the mentor panel without having the correct mentor datum.")
return

if(dementored)
return

if(!CheckMentorHREF(href, href_list))
return

Expand All @@ -102,25 +90,3 @@
else if(href_list["mhelp_tickets"])
GLOB.mhelp_tickets.BrowseTickets(usr)


/datum/mentors/proc/activate()
if(!for_admin)
return
if(IsAdminAdvancedProcCall())
var/msg = " has tried to elevate permissions!"
message_admins("[key_name_admin(usr)][msg]")
log_admin("[key_name(usr)][msg]")
return
dementored = FALSE
owner.add_mentor_verbs()

/datum/mentors/proc/deactivate()
if(!for_admin)
return
if(IsAdminAdvancedProcCall())
var/msg = " has tried to elevate permissions!"
message_admins("[key_name_admin(usr)][msg]")
log_admin("[key_name(usr)][msg]")
return
dementored = TRUE
owner.remove_mentor_verbs()
6 changes: 3 additions & 3 deletions code/modules/mentor/mentor_loading.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
continue
if(findtextEx(line, "#", 1, 2))
continue
new /datum/mentors(line, for_admin = FALSE)
new /datum/mentors(line)
return TRUE

/// Loads mentors from the ss13_mentors table
Expand All @@ -51,7 +51,7 @@
if(!ckey)
stack_trace("Invalid mentor row in database with null ckey with id: [id] and raw data: [raw_ckey]")
continue
new /datum/mentors(ckey, for_admin = FALSE)
new /datum/mentors(ckey)
qdel(query_load_mentors)
return TRUE

Expand All @@ -69,6 +69,6 @@
return TRUE
// They're an admin, but not a mentor. Create them a mentor datum. This is automatically assigned.
else if(check_rights_for(src, R_ADMIN))
new /datum/mentors(ckey, for_admin = TRUE)
new /datum/mentors(ckey)
return TRUE
return FALSE

0 comments on commit 4ea70da

Please sign in to comment.