Merge pull request #6743 from Boggart/readmin

Adds the ability for admins to re-admin themselves once they de-admin.
This commit is contained in:
tkdrg
2015-01-03 00:36:02 -03:00
+56 -6
View File
@@ -245,7 +245,8 @@ var/list/admin_verbs_hideable = list(
/client/proc/startSinglo,
/client/proc/ticklag,
/client/proc/cmd_admin_grantfullaccess,
/client/proc/cmd_admin_areatest
/client/proc/cmd_admin_areatest,
/client/proc/readmin
)
if(holder)
verbs.Remove(holder.rank.adds)
@@ -501,11 +502,11 @@ var/list/admin_verbs_hideable = list(
set category = "Admin"
if(holder)
if(alert("Confirm self-deadmin for the round? You can't re-admin yourself without someont promoting you.",,"Yes","No") == "Yes")
log_admin("[src] deadmined themself.")
message_admins("[src] deadmined themself.")
deadmin()
src << "<span class='interface'>You are now a normal player.</span>"
log_admin("[src] deadmined themself.")
message_admins("[src] deadmined themself.")
deadmin()
verbs += /client/proc/readmin
src << "<span class='interface'>You are now a normal player.</span>"
feedback_add_details("admin_verb","DAS") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
/client/proc/toggle_log_hrefs()
@@ -526,3 +527,52 @@ var/list/admin_verbs_hideable = list(
if(holder)
src.holder.output_ai_laws()
/client/proc/readmin()
set name = "Re-admin self"
set category = "Admin"
set desc = "Regain your admin powers."
var/list/rank_names = list()
for(var/datum/admin_rank/R in admin_ranks)
rank_names[R.name] = R
var/datum/admins/D = admin_datums[ckey]
var/rank = null
if(config.admin_legacy_system)
//load text from file
var/list/Lines = file2list("config/admins.txt")
for(var/line in Lines)
var/list/splitline = text2list(line, " = ")
if(splitline[1] == ckey)
if(splitline.len >= 2)
rank = ckeyEx(splitline[2])
break
continue
else
if(!dbcon.IsConnected())
message_admins("Warning, mysql database is not connected.")
src << "Warning, mysql database is not connected."
return
var/sql_ckey = sanitizeSQL(ckey)
var/DBQuery/query = dbcon.NewQuery("SELECT rank FROM [format_table_name("admin")] WHERE ckey = '[sql_ckey]'")
query.Execute()
while(query.NextRow())
rank = ckeyEx(query.item[1])
if(!D)
if(rank_names[rank] == null)
var/error_extra = ""
if(!config.admin_legacy_system)
error_extra = " Check mysql DB connection."
error("Error while re-adminning [src], admin rank ([rank]) does not exist.[error_extra]")
src << "Error while re-adminning, admin rank ([rank]) does not exist.[error_extra]"
return
D = new(rank_names[rank],ckey)
var/client/C = directory[ckey]
D.associate(C)
message_admins("[src] re-adminned themselves.")
log_admin("[src] re-adminned themselves.")
feedback_add_details("admin_verb","RAS")
verbs -= /client/proc/readmin
return
else
src << "You are already an admin."
verbs -= /client/proc/readmin
return