//System will now support SQL pulls for fetching player notes. //Yay! /proc/notes_add_sql(var/player_ckey, var/note, var/mob/user, var/player_address, var/player_computerid) if(!player_ckey || !note) return var/list/query_details = list("game_id" = game_id, "ckey" = player_ckey, "address" = player_address ? player_address : null, "computer_id" = player_computerid ? player_computerid : null, "a_ckey" = null, "note" = note) if (!user) query_details["a_ckey"] = "Adminbot" else query_details["a_ckey"] = user.ckey establish_db_connection(dbcon) if (!dbcon.IsConnected()) alert("SQL connection failed while trying to add a note!") return if (!player_address || !player_computerid) var/DBQuery/init_query = dbcon.NewQuery("SELECT ip, computerid FROM ss13_player WHERE ckey = :ckey:") init_query.Execute(list("ckey" = player_ckey)) if (init_query.NextRow()) if (!query_details["address"]) query_details["address"] = init_query.item[1] if (!query_details["computer_id"]) query_details["computer_id"] = init_query.item[2] var/DBQuery/insert_query = dbcon.NewQuery("INSERT INTO ss13_notes (id, adddate, game_id, ckey, ip, computerid, a_ckey, content) VALUES (null, Now(), :game_id:, :ckey:, :address:, :computer_id:, :a_ckey:, :note:)") insert_query.Execute(query_details) message_admins("[key_name_admin(user)] has edited [player_ckey]'s notes.") log_admin("[key_name(user)] has edited [player_ckey]'s notes.",admin_key=key_name(user),ckey=player_ckey) /proc/notes_edit_sql(var/note_id, var/note_edit) if (!note_id || !note_edit) return establish_db_connection(dbcon) if (!dbcon.IsConnected()) error("SQL connection failed while attempting to delete a note!") return var/count = 0 //failsafe from unban procs var/ckey var/note var/DBQuery/init_query = dbcon.NewQuery("SELECT ckey, content FROM ss13_notes WHERE id = :note_id:") init_query.Execute(list("note_id" = note_id)) while (init_query.NextRow()) ckey = init_query.item[1] note = init_query.item[2] count++ if (count == 0) to_chat(usr, "Database update failed due to a note id not being present in the database.") error("Database update failed due to a note id not being present in the database.") return if (count > 1) to_chat(usr, "Database update failed due to multiple notes having the same ID. Contact the database admin.") error("Database update failed due to multiple notes having the same ID. Contact the database admin.") return switch (note_edit) if ("delete") if(alert("Delete this note?", "Delete?", "Yes", "No") == "Yes") var/DBQuery/deletequery = dbcon.NewQuery("UPDATE ss13_notes SET visible = 0 WHERE id = :note_id:") deletequery.Execute(list("note_id" = note_id)) message_admins("[key_name_admin(usr)] deleted one of [ckey]'s notes.") log_admin("[key_name(usr)] deleted one of [ckey]'s notes.",admin_key=key_name(usr),ckey=ckey) else to_chat(usr, "Cancelled") return if ("content") var/new_content = input("Edit this note's contents.", "New Contents", note, null) as null|text if (!new_content) to_chat(usr, "Cancelled") return var/DBQuery/editquery = dbcon.NewQuery("UPDATE ss13_notes SET content = :new_content:, lasteditor = :a_ckey:, lasteditdate = Now(), edited = 1 WHERE id = :note_id:") editquery.Execute(list("new_content" = new_content, "a_ckey" = usr.client.ckey, "note_id" = note_id)) /datum/admins/proc/show_notes_sql(var/player_ckey = null, var/admin_ckey = null) if (!check_rights(R_ADMIN|R_MOD)) return if (admin_ckey == "Adminbot") to_chat(usr, "Adminbot is not an actual admin. You were lied to.") //The fucking size of this request would be astronomical. Please do not! return player_ckey = ckey(player_ckey) admin_ckey = ckey(admin_ckey) establish_db_connection(dbcon) if (!dbcon.IsConnected()) error("SQL connection failed while attempting to view a player's notes!") return var/dat = "
| ISSUED TO | " dat += "ISSUED BY | " dat += "TIME ISSUED | " dat += "CONTENT | " dat += "
|---|---|---|---|
| Add Note | |||
| [p_ckey] | [a_ckey] | [date] | [content] |
| Note last edited: [editdate], by: [lasteditor]. | |||
| (Delete) (Edit) | |||
|   | |||
| [p_ckey] | [admin_ckey] | [date] | [content] |
| Note last edited: [editdate], by: [lasteditor]. | |||
| (Delete) (Edit) | |||
|   | |||