From 01225fa3fc5d731649735d66bdbccd13725566a5 Mon Sep 17 00:00:00 2001 From: skull132 Date: Tue, 16 Jun 2015 19:50:23 +0300 Subject: [PATCH] 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. --- code/modules/admin/verbs/warning.dm | 64 +++++++++++++++++++++++++---- code/modules/client/client procs.dm | 9 ++++ 2 files changed, 65 insertions(+), 8 deletions(-) diff --git a/code/modules/admin/verbs/warning.dm b/code/modules/admin/verbs/warning.dm index 322b1a50..4ca5ccbc 100644 --- a/code/modules/admin/verbs/warning.dm +++ b/code/modules/admin/verbs/warning.dm @@ -118,7 +118,7 @@ feedback_add_details("admin_verb","WARN-DB") if(C) - C << "You have been formally warned by an administrator.
You can look up your warnings through the OOC panel, with the 'My Warnings' button.
" + C << "You have been formally warned by an administrator.
Click here to review and acknowledge them!
" 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 += "" @@ -171,6 +173,11 @@ dat += "[reason]" dat += "" + if(!ackn) + dat += "(Acknowledge Warning)" + else + dat += "Warning Acknowledged!" + dat += "" dat += " " dat += "" @@ -178,6 +185,47 @@ dat += "" 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 << "
" + src << "You have [count] unread [count > 1 ? "warnings" : "warning"]! Click here to review and acknowledge them!" + /* * A proc for an admin/moderator to look up a member's warnings. */ diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index d7456e40..968e885a 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -79,6 +79,13 @@ var/queryid = sanitizeSQL(href_list["directiveview"]) directiveslookup(2, queryid) + if(href_list["warnacknowledge"]) + var/queryid = text2num(href_list["warnacknowledge"]) + warnings_acknowledge(queryid) + + if(href_list["warnview"]) + warnings_check() + ..() //redirect to hsrc.Topic() /client/proc/handle_spam_prevention(var/message, var/mute_type) @@ -175,6 +182,8 @@ if(!dsay_allowed) src << "Deadchat is Disabled" + warnings_alert() + log_client_to_db() send_resources()