mirror of
https://github.com/Aurorastation/Aurora-Old.git
synced 2026-08-23 20:56:20 +01:00
Warning verb update
Adds the ability to edit warnings, and to delete them (only if you're an admin, or if you are the person who issued it). Also adds a method for automatically making old warnings (3 months) expire, on the condition that they are already acknowledged.
This commit is contained in:
@@ -2874,4 +2874,13 @@
|
||||
var/playerckey = href_list["notessearchckey"]
|
||||
|
||||
show_notes_sql(playerckey, adminckey)
|
||||
return
|
||||
return
|
||||
|
||||
else if(href_list["dbwarningedit"])
|
||||
var/warningEdit = href_list["dbwarningedit"]
|
||||
var/warningId = text2num(href_list["dbwarningid"])
|
||||
if(!warningEdit || !warningId)
|
||||
return
|
||||
|
||||
warningsEdit(warningId, warningEdit)
|
||||
return
|
||||
|
||||
@@ -65,9 +65,6 @@
|
||||
if(!check_rights(R_ADMIN|R_MOD)) return
|
||||
|
||||
if(!warned_ckey || !istext(warned_ckey)) return
|
||||
// if(warned_ckey in admin_datums)
|
||||
// usr << "<font color='red'>Error: warn(): You can't warn admins.</font>"
|
||||
// return
|
||||
|
||||
var/datum/preferences/D
|
||||
var/client/C = directory[warned_ckey]
|
||||
@@ -87,11 +84,11 @@
|
||||
|
||||
// Let's begin data gathering and conversion!
|
||||
|
||||
var/reason = input("Add Warning Reason") as null|text
|
||||
var/reason = input("Add Warning Reason. This is visible to the player.") as null|text
|
||||
if(!reason)
|
||||
return
|
||||
|
||||
var/notes = input("Add Additional Information") as null|text
|
||||
var/notes = input("Add Additional Information. This is visible to staff only.") as null|text
|
||||
|
||||
var/severity
|
||||
switch(alert("Set Warning Severity",,"Standard","Severe"))
|
||||
@@ -108,9 +105,12 @@
|
||||
ip = C.address
|
||||
var/a_ckey = sanitizeSQL(ckey)
|
||||
|
||||
var/DBQuery/query_insert = dbcon.NewQuery("INSERT INTO ss13_warnings (id, time, severity, reason, notes, ckey, computerid, ip, a_ckey) VALUES (null, Now(), '[severity]', '[reason]', '[notes]', '[sqlkey]', '[computerid]', '[ip]', '[a_ckey]')")
|
||||
var/DBQuery/query_insert = dbcon.NewQuery("INSERT INTO ss13_warnings (id, time, severity, reason, notes, ckey, computerid, ip, a_ckey) VALUES (null, Now(), '[severity]', '[reason]', '[notes]', '[sqlkey]', '[computerid]', '[ip]', '[a_ckey]');")
|
||||
query_insert.Execute()
|
||||
|
||||
if(query_insert.ErrorMsg())
|
||||
error("SQL error while issuing warning. Error text: [query_insert.ErrorMsg()].")
|
||||
|
||||
if(config.ban_legacy_system)
|
||||
notes_add(warned_ckey, "Warning added by [a_ckey], for: [reason]. || Notes regarding the warning: [notes].")
|
||||
else
|
||||
@@ -131,8 +131,9 @@
|
||||
set category = "OOC"
|
||||
set desc = "Display warnings issued to you."
|
||||
|
||||
var/lcolor = "#ffeeee" //light colour, severity = 1
|
||||
var/dcolor = "#ffaaaa" //dark colour, severity = 2
|
||||
var/lcolor = "#ffeeee" //light colour, severity = 0
|
||||
var/dcolor = "#ffaaaa" //dark colour, severity = 1
|
||||
var/ecolor = "#808080" //gray colour, expired = 1
|
||||
|
||||
establish_db_connection()
|
||||
if(!dbcon.IsConnected())
|
||||
@@ -151,7 +152,7 @@
|
||||
|
||||
var/sqlkey = sanitizeSQL(ckey)
|
||||
|
||||
var/DBQuery/search_query = dbcon.NewQuery("SELECT id, time, severity, reason, a_ckey, acknowledged FROM ss13_warnings WHERE visible = '1' AND (ckey='[sqlkey]' OR computerid='[computer_id]' OR ip='[address]') ORDER BY time DESC")
|
||||
var/DBQuery/search_query = dbcon.NewQuery("SELECT id, time, severity, reason, a_ckey, acknowledged, expired FROM ss13_warnings WHERE visible = 1 AND (ckey='[sqlkey]' OR computerid='[computer_id]' OR ip='[address]') ORDER BY time DESC;")
|
||||
search_query.Execute()
|
||||
|
||||
while(search_query.NextRow())
|
||||
@@ -161,12 +162,16 @@
|
||||
var/reason = search_query.item[4]
|
||||
var/a_ckey = search_query.item[5]
|
||||
var/ackn = text2num(search_query.item[6])
|
||||
var/expired = text2num(search_query.item[7])
|
||||
|
||||
var/bgcolor = lcolor
|
||||
|
||||
if(severity)
|
||||
bgcolor = dcolor
|
||||
|
||||
if(expired)
|
||||
bgcolor = ecolor
|
||||
|
||||
dat += "<tr bgcolor='[bgcolor]' align='center'>"
|
||||
dat += "<td>[a_ckey]</td>"
|
||||
dat += "<td>[time]</td>"
|
||||
@@ -175,8 +180,10 @@
|
||||
|
||||
if(!ackn)
|
||||
dat += "<tr><td align='center' colspan='3'><b>(<a href='byond://?src=\ref[src];warnacknowledge=[id]'>Acknowledge Warning</a>)</b></td></tr>"
|
||||
else if(expired)
|
||||
dat += "<tr><td align='center' colspan='3'><b>Warning expired and no longer active!</b></td></tr>"
|
||||
else
|
||||
dat += "<tr><td align='center' colspan='3'><b>Warning Acknowledged!</b></td></tr>"
|
||||
dat += "<tr><td align='center' colspan='3'><b>Warning acknowledged!</b></td></tr>"
|
||||
|
||||
dat += "<tr>"
|
||||
dat += "<td colspan='5' bgcolor='white'> </td>"
|
||||
@@ -198,7 +205,7 @@
|
||||
error("Connection to SQL database failed while attempting to update a player's warnings.")
|
||||
return
|
||||
|
||||
var/DBQuery/query = dbcon.NewQuery("UPDATE ss13_warnings SET acknowledged = 1 WHERE id = '[id]'")
|
||||
var/DBQuery/query = dbcon.NewQuery("UPDATE ss13_warnings SET acknowledged = 1 WHERE id = '[id]';")
|
||||
query.Execute()
|
||||
|
||||
warnings_check()
|
||||
@@ -211,13 +218,21 @@
|
||||
/client/proc/warnings_alert()
|
||||
var/sqlkey = sanitizeSQL(ckey)
|
||||
var/count = 0
|
||||
var/countExpire = 0
|
||||
|
||||
establish_db_connection()
|
||||
if(!dbcon.IsConnected())
|
||||
error("Connection to SQL database failed while attempting to alert a player of their warnings.")
|
||||
return
|
||||
|
||||
var/DBQuery/query = dbcon.NewQuery("SELECT id FROM ss13_warnings WHERE (visible = '1' AND acknowledged = '0') AND (ckey='[sqlkey]' OR computerid='[computer_id]' OR ip='[address]')")
|
||||
var/DBQuery/expireQuery = dbcon.NewQuery("SELECT id FROM ss13_warnings WHERE (acknowledged = 1 AND expired = 0 AND DATE_SUB(CURDATE(),INTERVAL 3 MONTH) > time) AND (ckey='[sqlkey]' OR computerid='[computer_id]' OR ip='[address]');")
|
||||
expireQuery.Execute()
|
||||
while(expireQuery.NextRow())
|
||||
var/id = text2num(expireQuery.item[1])
|
||||
var/DBQuery/updateQuery = dbcon.NewQuery("UPDATE ss13_warnings SET expired = 1 WHERE id = [id];")
|
||||
updateQuery.Execute()
|
||||
|
||||
var/DBQuery/query = dbcon.NewQuery("SELECT id FROM ss13_warnings WHERE (visible = 1 AND acknowledged = 0 AND expired = 0) AND (ckey='[sqlkey]' OR computerid='[computer_id]' OR ip='[address]');")
|
||||
query.Execute()
|
||||
while(query.NextRow())
|
||||
count++
|
||||
@@ -225,6 +240,9 @@
|
||||
if(count)
|
||||
src << "<br>"
|
||||
src << "<font color=red><b>You have [count] unread [count > 1 ? "warnings" : "warning"]! Click <a href='byond://?src=\ref[src];warnview=1'>here</a> to review and acknowledge them!</b></font>"
|
||||
if(countExpire)
|
||||
src << "<br>"
|
||||
src << "<font color=blue><b>[countExpire] of your warnings expired.</b></font>"
|
||||
|
||||
/*
|
||||
* A proc for an admin/moderator to look up a member's warnings.
|
||||
@@ -243,8 +261,9 @@
|
||||
/datum/admins/proc/warning_panel(var/adminckey = null, var/playerckey = null)
|
||||
if(!check_rights(R_ADMIN|R_MOD)) return
|
||||
|
||||
var/lcolor = "#ffeeee" //light colour, severity = 1
|
||||
var/dcolor = "#ffdddd" //dark colour, severity = 2
|
||||
var/lcolor = "#ffeeee" //light colour, severity = 0
|
||||
var/dcolor = "#ffdddd" //dark colour, severity = 1
|
||||
var/ecolor = "#808080" //gray colour, expired = 1
|
||||
|
||||
establish_db_connection()
|
||||
if(!dbcon.IsConnected())
|
||||
@@ -273,8 +292,8 @@
|
||||
dat += "<th width='60%'>REASON</th>"
|
||||
dat += "</tr>"
|
||||
|
||||
adminckey = ckey(adminckey)
|
||||
playerckey = ckey(playerckey)
|
||||
adminckey = sanitizeSQL(adminckey)
|
||||
playerckey = sanitizeSQL(playerckey)
|
||||
var/paramone = ""
|
||||
var/paramtwo = ""
|
||||
if(adminckey)
|
||||
@@ -282,21 +301,30 @@
|
||||
if(playerckey)
|
||||
paramtwo = "AND ckey = '[playerckey]' "
|
||||
|
||||
var/DBQuery/search_query = dbcon.NewQuery("SELECT time, severity, reason, notes, ckey, a_ckey FROM ss13_warnings WHERE 1 [paramone] [paramtwo] ORDER BY time DESC")
|
||||
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()
|
||||
|
||||
if(search_query.ErrorMsg())
|
||||
error("SQL error while activating admin warnings panel. Error text: [search_query.ErrorMsg()].")
|
||||
|
||||
while(search_query.NextRow())
|
||||
var/time = search_query.item[1]
|
||||
var/severity = search_query.item[2]
|
||||
var/reason = search_query.item[3]
|
||||
var/notes = search_query.item[4]
|
||||
var/ckey = search_query.item[5]
|
||||
var/a_ckey = search_query.item[6]
|
||||
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 == "1")
|
||||
if(severity)
|
||||
bgcolor = dcolor
|
||||
if(expired)
|
||||
bgcolor = ecolor
|
||||
|
||||
dat += "<tr bgcolor='[bgcolor]' align='center'>"
|
||||
dat += "<td>[ckey]</td>"
|
||||
@@ -307,6 +335,28 @@
|
||||
dat += "<tr>"
|
||||
dat += "<td align='center' colspan='5'><b>Staff Notes:</b> <cite>\"[notes]\"</cite></td>"
|
||||
dat += "</tr>"
|
||||
if(ackn)
|
||||
dat += "<tr><td align='center' colspan='5'>Warning has been acknolwedged by recipient.</td></tr>"
|
||||
else
|
||||
dat += "<tr><td align='center' colspan='5'>Warning has not been acknolwedged by recipient.</td></tr>"
|
||||
if(expired)
|
||||
dat += "<tr><td align='center' colspan='5'>The warning has expired.</td></tr>"
|
||||
else
|
||||
dat += "<tr><td align='center' colspan='5'>The warning is currently active.</td></tr>"
|
||||
if(edited)
|
||||
var/lastEditor = search_query.item[11]
|
||||
var/lastEditDate = search_query.item[12]
|
||||
dat += "<tr><td align='center' colspan='5'><b>Warning last edited: [lastEditDate], by: [lastEditor].</b></td></tr>"
|
||||
dat += "<tr>"
|
||||
dat += "<td align='center' colspan='5'><b>Options:</b> "
|
||||
if(check_rights(R_ADMIN) || a_ckey == sanitizeSQL(ckey))
|
||||
dat += "<a href=\"byond://?src=\ref[src];dbwarningedit=editReason;dbwarningid=[id]\">Edit Message</a> "
|
||||
dat += "<a href=\"byond://?src=\ref[src];dbwarningedit=editNotes;dbwarningid[id]\">Edit Note</a> "
|
||||
dat += "<a href=\"byond://?src=\ref[src];dbwarningedit=delete;dbwarningid[id]\">Delete Warning</a>"
|
||||
else
|
||||
dat += "You can only edit or delete notes that you have issued."
|
||||
dat += "</td>"
|
||||
dat += "</tr>"
|
||||
|
||||
dat += "<tr>"
|
||||
dat += "<td colspan='5' bgcolor='white'> </td>"
|
||||
@@ -316,3 +366,72 @@
|
||||
|
||||
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/warningId, var/warningEdit)
|
||||
if(!warningId || !warningEdit)
|
||||
return
|
||||
|
||||
establish_db_connection()
|
||||
if(!dbcon.IsConnected())
|
||||
error("SQL connection failed while attempting to edit a note!")
|
||||
return
|
||||
|
||||
var/count = 0 //failsafe
|
||||
var/aCkey = sanitizeSQL(usr.ckey)
|
||||
var/ckey
|
||||
var/reason
|
||||
var/notes
|
||||
|
||||
var/DBQuery/initialQuery = dbcon.NewQuery("SELECT ckey, reason, notes FROM ss13_warnings WHERE id = '[warningId]';")
|
||||
initialQuery.Execute()
|
||||
while(initialQuery.NextRow())
|
||||
ckey = initialQuery.item[1]
|
||||
reason = initialQuery.item[2]
|
||||
notes = initialQuery.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(warningEdit)
|
||||
if("delete")
|
||||
if(alert("Delete this warning?", "Delete?", "Yes", "No") == "Yes")
|
||||
var/DBQuery/deleteQuery = dbcon.NewQuery("UPDATE ss13_warnings SET visible = 0 WHERE id = [warningId];")
|
||||
deleteQuery.Execute()
|
||||
|
||||
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")
|
||||
var/newReason = input("Edit this warning's reason.", "New Reason", "[reason]", null) as null|text
|
||||
newReason = sql_sanitize_text(newReason)
|
||||
if(!newReason || newReason == reason)
|
||||
usr << "Cancelled"
|
||||
return
|
||||
var/DBQuery/reasonQuery = dbcon.NewQuery("UPDATE ss13_warnings SET reason = '[newReason]', edited = 1, lasteditor = '[aCkey]', lasteditdate = NOW() WHERE id = '[warningId]';")
|
||||
reasonQuery.Execute()
|
||||
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")
|
||||
var/newNotes = input("Edit this warning's notes.", "New Notes", "[notes]", null) as null|text
|
||||
newNotes = sql_sanitize_text(newNotes)
|
||||
if(!newNotes || newNotes == notes)
|
||||
usr << "Cancelled"
|
||||
return
|
||||
var/DBQuery/notesQuery = dbcon.NewQuery("UPDATE ss13_warnings SET notes = '[newNotes]', edited = 1, lasteditor = '[aCkey]', lasteditdate = NOW() WHERE id = '[warningId]';")
|
||||
notesQuery.Execute()
|
||||
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.")
|
||||
|
||||
Reference in New Issue
Block a user