"
dat += ""
dat += "| ISSUED TO | "
dat += "ISSUED BY | "
dat += "TIME ISSUED | "
dat += "REASON | "
dat += "
"
var/list/query_details = list(":a_ckey", ":ckey")
var/paramone = ""
var/paramtwo = ""
if(adminckey)
paramone = "AND a_ckey = :a_ckey "
query_details[":a_ckey"] = adminckey
if(playerckey)
paramtwo = "AND ckey = :ckey "
query_details[":ckey"] = playerckey
var/DBQuery/search_query = dbcon.NewQuery("SELECT id, time, severity, reason, notes, ckey, a_ckey, acknowledged, expired, edited, lasteditor, lasteditdate FROM ss13_warnings WHERE visible = 1 [paramone] [paramtwo] ORDER BY time DESC;")
search_query.Execute(query_details, 1)
while (search_query.NextRow())
var/id = text2num(search_query.item[1])
var/time = search_query.item[2]
var/severity = text2num(search_query.item[3])
var/reason = search_query.item[4]
var/notes = search_query.item[5]
var/ckey = search_query.item[6]
var/a_ckey = search_query.item[7]
var/ackn = text2num(search_query.item[8])
var/expired = text2num(search_query.item[9])
var/edited = text2num(search_query.item[10])
var/bgcolor = lcolor
if(severity)
bgcolor = dcolor
if(expired)
bgcolor = ecolor
dat += ""
dat += "| [ckey] | "
dat += "[a_ckey] | "
dat += "[time] | "
dat += "[reason] | "
dat += "
"
dat += ""
dat += "| Staff Notes: \"[notes]\" | "
dat += "
"
if(!ackn)
dat += "| Warning has not been acknolwedged by recipient. |
"
if(expired)
dat += "| The warning has expired. |
"
if(edited)
var/lastEditor = search_query.item[11]
var/lastEditDate = search_query.item[12]
dat += "| Warning last edited: [lastEditDate], by: [lastEditor]. |
"
dat += ""
dat += "| Options: "
if(check_rights(R_ADMIN) || a_ckey == sanitizeSQL(ckey))
dat += "Edit Reason "
dat += "Edit Note "
dat += "Delete Warning"
else
dat += "You can only edit or delete notes that you have issued."
dat += " | "
dat += "
"
dat += ""
dat += "|   | "
dat += "
"
dat +="
"
usr << browse(dat, "window=lookupwarns;size=900x500")
feedback_add_details("admin_verb","WARN-LKUP")
/*
* A proc for editing and deleting warnings issued
*/
/proc/warningsEdit(var/warning_id, var/warning_edit)
if(!warning_id || !warning_edit)
return
establish_db_connection(dbcon)
if(!dbcon.IsConnected())
alert("Connection to the SQL database lost. Aborting. Please alert the database admin!")
return
var/count = 0 //failsafe
var/ckey
var/reason
var/notes
var/list/query_details = list(":warning_id" = warning_id, ":a_ckey" = usr.ckey)
var/DBQuery/initial_query = dbcon.NewQuery("SELECT ckey, reason, notes FROM ss13_warnings WHERE id = :warning_id")
initial_query.Execute(query_details, 1)
while (initial_query.NextRow())
ckey = initial_query.item[1]
reason = initial_query.item[2]
notes = initial_query.item[3]
count++
if (count == 0)
usr << "\red Database update failed due to a warning id not being present in the database."
error("Database update failed due to a warning id not being present in the database.")
return
if (count > 1)
usr << "\red Database update failed due to multiple warnings having the same ID. Contact the database admin."
error("Database update failed due to multiple warnings having the same ID. Contact the database admin.")
return
switch (warning_edit)
if ("delete")
if(alert("Delete this warning?", "Delete?", "Yes", "No") == "Yes")
var/DBQuery/deleteQuery = dbcon.NewQuery("UPDATE ss13_warnings SET visible = 0 WHERE id = :warning_id")
deleteQuery.Execute(query_details, 1)
message_admins("\blue [key_name_admin(usr)] deleted one of [ckey]'s warnings.")
log_admin("[key_name(usr)] deleted one of [ckey]'s warnings.")
else
usr << "Cancelled"
return
if ("editReason")
query_details += ":new_reason"
query_details[":new_reason"] = input("Edit this warning's reason.", "New Reason", reason, null) as null|text
if(!query_details[":new_reason"] || query_details[":new_reason"] == reason)
usr << "Cancelled"
return
var/DBQuery/reason_query = dbcon.NewQuery("UPDATE ss13_warnings SET reason = :new_reason, edited = 1, lasteditor = :a_ckey, lasteditdate = NOW() WHERE id = :warning_id")
reason_query.Execute(query_details, 1)
message_admins("\blue [key_name_admin(usr)] edited one of [ckey]'s warning reasons.")
log_admin("[key_name(usr)] edited one of [ckey]'s warning reasons.")
if("editNotes")
query_details += ":new_notes"
query_details[":new_notes"] = input("Edit this warning's notes.", "New Notes", notes, null) as null|text
if(!query_details[":new_notes"] || query_details[":new_notes"] == notes)
usr << "Cancelled"
return
var/DBQuery/notes_query = dbcon.NewQuery("UPDATE ss13_warnings SET notes = :new_notes, edited = 1, lasteditor = :a_ckey, lasteditdate = NOW() WHERE id = :warning_id")
notes_query.Execute(query_details, 1)
message_admins("\blue [key_name_admin(usr)] edited one of [ckey]'s warning notes.")
log_admin("[key_name(usr)] edited one of [ckey]'s warning notes.")