diff --git a/code/modules/admin/holder2.dm b/code/modules/admin/holder2.dm index ef23f12379e21..f99f89c6b3651 100644 --- a/code/modules/admin/holder2.dm +++ b/code/modules/admin/holder2.dm @@ -85,7 +85,6 @@ 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()) @@ -101,7 +100,6 @@ 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()) @@ -110,20 +108,23 @@ GLOBAL_PROTECT(href_token) log_admin("[key_name(usr)][msg]") return - 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 + 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() /datum/admins/proc/disassociate() if(IsAdminAdvancedProcCall()) @@ -131,11 +132,14 @@ GLOBAL_PROTECT(href_token) message_admins("[key_name_admin(usr)][msg]") log_admin("[key_name(usr)][msg]") return - if(owner) - GLOB.admins -= owner - owner.remove_admin_verbs() - owner.holder = null - owner = null + if(!owner) + return + GLOB.admins -= owner + owner.remove_admin_verbs() + if(istype(owner.mentor_datum)) + owner.mentor_datum.deactivate() + owner.holder = null + owner = null /datum/admins/proc/check_for_rights(rights_required) if(rights_required && !(rights_required & rank.rights)) diff --git a/code/modules/mentor/mentor.dm b/code/modules/mentor/mentor.dm index 5e6525d1813c3..7b04a668ea90e 100644 --- a/code/modules/mentor/mentor.dm +++ b/code/modules/mentor/mentor.dm @@ -10,8 +10,13 @@ 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) +/datum/mentors/New(ckey, for_admin) if(!ckey) QDEL_IN(src, 0) stack_trace("Mentor datum created without a ckey: [ckey]") @@ -23,6 +28,7 @@ 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] @@ -37,7 +43,10 @@ return owner = C owner.mentor_datum = src - owner.add_mentor_verbs() + if(for_admin) + activate() + else + owner.add_mentor_verbs() if(!check_rights_for(owner, R_ADMIN)) // add nonadmins to the mentor list. GLOB.mentors |= owner @@ -77,6 +86,9 @@ 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 @@ -90,3 +102,25 @@ 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() diff --git a/code/modules/mentor/mentor_loading.dm b/code/modules/mentor/mentor_loading.dm index ed4068cc4ba37..4bdfac1ddb4b9 100644 --- a/code/modules/mentor/mentor_loading.dm +++ b/code/modules/mentor/mentor_loading.dm @@ -28,7 +28,7 @@ continue if(findtextEx(line, "#", 1, 2)) continue - new /datum/mentors(line) + new /datum/mentors(line, for_admin = FALSE) return TRUE /// Loads mentors from the ss13_mentors table @@ -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) + new /datum/mentors(ckey, for_admin = FALSE) qdel(query_load_mentors) return TRUE @@ -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) + new /datum/mentors(ckey, for_admin = TRUE) return TRUE return FALSE