diff --git a/code/modules/admin/sql_message_system.dm b/code/modules/admin/sql_message_system.dm index 944fcb64bc6..ac3c94f13c8 100644 --- a/code/modules/admin/sql_message_system.dm +++ b/code/modules/admin/sql_message_system.dm @@ -629,6 +629,19 @@ browser.set_content(jointext(output, "")) browser.open() +/// Represents a message stored in the db +/datum/admin_message + /// The uid of this message + var/id + /// The admin who left this message + var/admin_key + /// The text of this message + var/text + /// The time this message was first created + var/timestamp + /// The admin who last edited this message + var/editor_key + /proc/get_message_output(type, target_ckey, show_secret = TRUE, after_timestamp) if(!SSdbcore.Connect()) to_chat(usr, span_danger("Failed to establish database connection."), confidential = TRUE) @@ -660,29 +673,50 @@ if(!query_get_message_output.warn_execute()) qdel(query_get_message_output) return + var/list/datum/admin_message/messages = list() while(query_get_message_output.NextRow()) - var/message_id = query_get_message_output.item[1] - var/admin_key = query_get_message_output.item[2] - var/text = query_get_message_output.item[3] - var/timestamp = query_get_message_output.item[4] - var/editor_key = query_get_message_output.item[5] - switch(type) - if("message") - output += "Admin message left by [span_prefix("[admin_key]")] on [timestamp]" - output += "
[text] (Click here to verify you have read this message)
" - if("note") - output += "Note left by [span_prefix("[admin_key]")] on [timestamp]" - output += "
[text]
" - if("watchlist entry") - message_admins("Notice: [key_name_admin(target_ckey)] has been on the watchlist since [timestamp] and has just connected - Reason: [text]") - send2tgs_adminless_only("Watchlist", "[key_name(target_ckey)] is on the watchlist and has just connected - Reason: [text]") - if("memo") - output += "[span_memo("Memo by [admin_key]")] on [timestamp]" - if(editor_key) - output += "
[span_memoedit("Last edit by [editor_key] (Click here to see edit log)")]" - output += "
[text]

" + var/datum/admin_message/message = new() + message.id = query_get_message_output.item[1] + message.admin_key = query_get_message_output.item[2] + message.text = query_get_message_output.item[3] + message.timestamp = query_get_message_output.item[4] + message.editor_key = query_get_message_output.item[5] + messages += message qdel(query_get_message_output) - return output + if(!length(messages)) + return + return messages + +/proc/display_admin_messages(client/display_to) + var/list/text = list() + for(var/datum/admin_message/message in get_message_output("message", display_to.ckey)) + text += "Admin message left by [span_prefix("[message.admin_key]")] on [message.timestamp]" + text += "
[message.text] (Click here to verify you have read this message)
" + if(length(text)) + to_chat(display_to, text.Join()) + +/proc/display_unread_notes(client/display_to, show_after) + var/list/text = list() + for(var/datum/admin_message/message in get_message_output("note", display_to.ckey, FALSE, show_after)) + text += "Note left by [span_prefix("[message.admin_key]")] on [message.timestamp]" + text += "
[message.text]
" + if(length(text)) + to_chat(display_to, text.Join()) + +/proc/display_admin_memos(client/display_to) + var/list/text = list() + for(var/datum/admin_message/message in get_message_output("memo", display_to.ckey)) + text += "[span_memo("Memo by [message.admin_key]")] on [message.timestamp]" + if(message.editor_key) + text += "
[span_memoedit("Last edit by [message.editor_key] (Click here to see edit log)")]" + text += "
[message.text]

" + if(length(text)) + to_chat(display_to, text.Join()) + +/proc/scream_about_watchlists(client/read_from) + for(var/datum/admin_message/message in get_message_output("watchlist entry", read_from.ckey)) + message_admins("Notice: [key_name_admin(read_from.ckey)] has been on the watchlist since [message.timestamp] and has just connected - Reason: [message.text]") + send2tgs_adminless_only("Watchlist", "[key_name(read_from.ckey)] is on the watchlist and has just connected - Reason: [message.text]") #define NOTESFILE "data/player_notes.sav" //if the AUTOCONVERT_NOTES is turned on, anytime a player connects this will be run to try and add all their notes to the databas diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index d7e1b5b2d95..6196e2c94b6 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -361,19 +361,6 @@ var/target = href_list["showmessageckeylinkless"] browse_messages(target_ckey = target, linkless = 1) - else if(href_list["messageread"]) - if(!isnum(href_list["message_id"])) - return - var/rounded_message_id = round(href_list["message_id"], 1) - var/datum/db_query/query_message_read = SSdbcore.NewQuery( - "UPDATE [format_table_name("messages")] SET type = 'message sent' WHERE targetckey = :player_key AND id = :id", - list("id" = rounded_message_id, "player_key" = usr.ckey) - ) - if(!query_message_read.warn_execute()) - qdel(query_message_read) - return - qdel(query_message_read) - else if(href_list["messageedits"]) if(!check_rights(R_ADMIN)) return diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index da3a733cf50..3c0b5aa1db3 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -104,6 +104,18 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( if (href_list["player_ticket_panel"]) view_latest_ticket() return + // Admin message + if(href_list["messageread"]) + var/message_id = round(text2num(href_list["messageread"]), 1) + if(!isnum(message_id)) + return + var/datum/db_query/query_message_read = SSdbcore.NewQuery( + "UPDATE [format_table_name("messages")] SET type = 'message sent' WHERE targetckey = :player_key AND id = :id", + list("id" = message_id, "player_key" = usr.ckey) + ) + query_message_read.warn_execute() + return + // TGUIless adminhelp if(href_list["tguiless_adminhelp"]) no_tgui_adminhelp(input(src, "Enter your ahelp", "Ahelp") as null|message) @@ -432,9 +444,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( if(holder) add_admin_verbs() - var/memo_message = get_message_output("memo") - if(memo_message) - to_chat(src, memo_message) + display_admin_memos(src) adminGreet() if (mob && reconnecting) var/stealth_admin = mob.client?.holder?.fakekey @@ -451,9 +461,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( if(query_last_connected.warn_execute() && length(query_last_connected.rows)) query_last_connected.NextRow() var/time_stamp = query_last_connected.item[1] - var/unread_notes = get_message_output("note", ckey, FALSE, time_stamp) - if(unread_notes) - to_chat(src, unread_notes) + display_unread_notes(src, time_stamp) qdel(query_last_connected) var/cached_player_age = set_client_age_from_db(tdata) //we have to cache this because other shit may change it and we need it's current value now down below. @@ -482,7 +490,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( "new_byond_user", "[key_name(src)] (IP: [address], ID: [computer_id]) is a new BYOND account [account_age] day[(account_age == 1?"":"s")] old, created on [account_join_date].[new_player_alert_role ? " <@&[new_player_alert_role]>" : ""]" ) - get_message_output("watchlist entry", ckey) + scream_about_watchlists(src) check_ip_intel() validate_key_in_db() // If we aren't already generating a ban cache, fire off a build request @@ -508,9 +516,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( if(CONFIG_GET(flag/autoconvert_notes)) convert_notes_sql(ckey) - var/user_messages = get_message_output("message", ckey) - if(user_messages) - to_chat(src, user_messages) + display_admin_messages(src) if(!winexists(src, "asset_cache_browser")) // The client is using a custom skin, tell them. to_chat(src, span_warning("Unable to access asset cache browser, if you are using a custom skin file, please allow DS to download the updated version, if you are not, then make a bug report. This is not a critical issue but can cause issues with resource downloading, as it is impossible to know when extra resources arrived to you."))