Warning additions

* Warnings can now be acknowledged from the my-warnings panel.
* If you have any warnings that you haven't acknowledged, then you will
be informed of them every single time you log in.
* Also fixed a minor logical issues due to me being a dumb upon initial
implementation.
This commit is contained in:
skull132
2015-06-16 19:50:23 +03:00
parent 1dc456fff5
commit 01225fa3fc
2 changed files with 65 additions and 8 deletions
+56 -8
View File
@@ -118,7 +118,7 @@
feedback_add_details("admin_verb","WARN-DB")
if(C)
C << "<font color='red'><BIG><B>You have been formally warned by an administrator.</B></BIG><br>You can look up your warnings through the OOC panel, with the 'My Warnings' button.</font>"
C << "<font color='red'><BIG><B>You have been formally warned by an administrator.</B></BIG><br>Click <a href='byond://?src=\ref[src];warnview=1'>here</a> to review and acknowledge them!</font>"
message_admins("[key_name_admin(src)] has warned [warned_ckey] for: [reason].")
message_mods("[key_name_admin(src)] has warned [warned_ckey].")
@@ -126,7 +126,7 @@
* A proc for a player to check their own warnings
*/
/client/verb/check_warns()
/client/verb/warnings_check()
set name = "My warnings"
set category = "OOC"
set desc = "Display warnings issued to you."
@@ -151,18 +151,20 @@
var/sqlkey = sanitizeSQL(ckey)
var/DBQuery/search_query = dbcon.NewQuery("SELECT time, severity, reason, a_ckey FROM aurora_warnings WHERE ckey='[sqlkey]' ORDER BY time DESC")
var/DBQuery/search_query = dbcon.NewQuery("SELECT id, time, severity, reason, a_ckey, acknowledged FROM aurora_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())
var/time = search_query.item[1]
var/severity = search_query.item[2]
var/reason = search_query.item[3]
var/a_ckey = search_query.item[4]
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/a_ckey = search_query.item[5]
var/ackn = text2num(search_query.item[6])
var/bgcolor = lcolor
if(severity == "1")
if(severity)
bgcolor = dcolor
dat += "<tr bgcolor='[bgcolor]' align='center'>"
@@ -171,6 +173,11 @@
dat += "<td>[reason]</td>"
dat += "</tr>"
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
dat += "<tr><td align='center' colspan='3'><b>Warning Acknowledged!</b></td></tr>"
dat += "<tr>"
dat += "<td colspan='5' bgcolor='white'>&nbsp</td>"
dat += "</tr>"
@@ -178,6 +185,47 @@
dat += "</table>"
usr << browse(dat, "window=mywarnings;size=900x500")
/*
* A proc for acknowledging a warning, so you don't get pestered about it anymore.
*/
/client/proc/warnings_acknowledge(id)
if(!id)
return
establish_db_connection()
if(!dbcon.IsConnected())
error("Connection to SQL database failed while attempting to update a player's warnings.")
return
var/DBQuery/query = dbcon.NewQuery("UPDATE aurora_warnings SET acknowledged = 1 WHERE id = '[id]'")
query.Execute()
warnings_check()
/*
* A proc to alert you if you have unacknowledged warnings.
* Called in /client/New (client procs.dm)
*/
/client/proc/warnings_alert()
var/sqlkey = sanitizeSQL(ckey)
var/count = 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 aurora_warnings WHERE (visible = '1' AND acknowledged = '0') AND (ckey='[sqlkey]' OR computerid='[computer_id]' OR ip='[address]')")
query.Execute()
while(query.NextRow())
count++
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>"
/*
* A proc for an admin/moderator to look up a member's warnings.
*/