Further CCIA Adaptations (#6750)

* Further CCIA Adaptations

Changes the CCIA Recorder to ask if there was Antag Involvement in the Incident and adds additional db changes.

* Implements Review Changes

* Recorder Interaction Changes

Changes the recorder click interaction for agents and adds the options to reset the recorder

* Displays the report topics

Shows the internal topic to the interviewing agent upon selection of the IR
Shows the public topic to the interviewee upon scanning of the fingerprint

* Update the status of the report if a user claims antag involvement.

* Asks the char how the antags influenced them.

* Fixes SQL Migration Error

* Fix SQL Migration and Query Bug

* Fixes a issue with the report selection and the query saving

* More sanitization
This commit is contained in:
Werner
2020-05-13 23:29:59 +02:00
committed by GitHub
parent 2925cf5622
commit b754c25195
6 changed files with 183 additions and 31 deletions

View File

@@ -11,6 +11,13 @@ var/global/enabled_spooking = 0
if((R_ADMIN|R_MOD) & C.holder.rights)
to_chat(C, msg)
/proc/message_cciaa(var/msg)
msg = "<span class=\"log_message\"><span class=\"prefix\">CCIA LOG:</span> <span class=\"message\">[msg]</span></span>"
for(var/s in staff)
var/client/C = s
if(R_CCIAA & C.holder.rights)
to_chat(C, msg)
/proc/msg_admin_attack(var/text,var/ckey="",var/ckey_target="") //Toggleable Attack Messages
log_attack(text,ckey=ckey,ckey_target=ckey_target)
var/rendered = "<span class=\"log_message\"><span class=\"prefix\">ATTACK:</span> <span class=\"message\">[text]</span></span>"

View File

@@ -0,0 +1,17 @@
/datum/ccia_report
var/id
var/report_date
var/title
var/public_topic
var/internal_topic
var/game_id
var/status
/datum/ccia_report/New(var/id, var/report_date, var/title, var/public_topic=null, var/internal_topic=null, var/game_id=null, var/status="new")
src.id = text2num(id)
src.report_date = report_date
src.title = title
src.public_topic = public_topic
src.internal_topic = internal_topic
src.game_id = game_id
src.status = status

View File

@@ -24,8 +24,10 @@
var/sLogFile = null
var/last_file_loc = null
var/report_id = null
var/report_name = null
var/antag_involvement = FALSE
var/antag_involvement_text = null
var/datum/ccia_report/selected_report = null
var/interviewee_id = null
var/interviewee_name = null
var/date_string = null
@@ -54,60 +56,65 @@
return
//If nothing has been done with the device yet
if(!report_id && !interviewee_id)
if(!selected_report && !interviewee_id)
if(config.sql_ccia_logs)
//Get the active cases from the database and display them
var/list/reports = list()
var/DBQuery/report_query = dbcon.NewQuery("SELECT id, report_date, title FROM ss13_ccia_reports WHERE status = 'approved' AND deleted_at IS NULL")
var/DBQuery/report_query = dbcon.NewQuery("SELECT id, report_date, title, public_topic, internal_topic, game_id, status FROM ss13_ccia_reports WHERE status IN ('in progress', 'approved') AND deleted_at IS NULL")
report_query.Execute()
while(report_query.NextRow())
CHECK_TICK
reports["[report_query.item[2]] - [report_query.item[3]]"] = "[report_query.item[1]]"
var/datum/ccia_report/R = new(report_query.item[1], report_query.item[2], report_query.item[3], report_query.item[4], report_query.item[5], report_query.item[6], report_query.item[7])
reports["[report_query.item[1]] - [report_query.item[2]] - [report_query.item[3]]"] = R
report_name = input(usr, "Select Report","Report Name") as null|anything in reports
if(!report_name || report_name == "")
var/selection = input(usr, "Select Report","Report Name") as null|anything in reports
if(!selection)
to_chat(usr, "<span class='notice'>The device beeps and flashes \"No data entered, Aborting\".</span>")
return
report_id = reports[report_name]
to_chat(usr,"<span class='notice'>The device flashes \"Report [report_name] selected, Finterprint of interviwee required\"</span>")
selected_report = reports[selection]
to_chat(usr,"<span class='notice'>The device flashes \"Report [selected_report.title] selected, fingerprint of interviewee required\"</span>")
if(selected_report.internal_topic)
send_link(usr, selected_report.internal_topic)
else
report_name = input(usr, "Select Report Name","Report Name") as null|text
var/report_name = input(usr, "Select Report Name","Report Name") as null|text
if(!report_name || report_name == "")
to_chat(usr, "<span class='notice'>The device beeps and flashes \"No data entered, Aborting\".</span>")
return
report_id = input(usr, "Select Report ID","Report ID") as null|text
if(!report_name || report_name == "")
var/report_id = input(usr, "Select Report ID","Report ID") as null|text
if(!report_id || report_id == "")
to_chat(usr, "<span class='notice'>The device beeps and flashes \"No data entered, Aborting\".</span>")
return
selected_report = new(report_id, time2text(world.realtime, "YYYY_MM_DD"), report_name)
return
//If we are ready to record, but no interviewee is selected
else if(report_id && !interviewee_id)
else if(!selected_report && !interviewee_id)
to_chat(usr,"<span class='notice'>The device beeps and flashes \"Fingerprint of interviewee required\"</span>")
return
//If the report has been selected and the person scanned their frinterprint
else if(report_id && interviewee_id)
else if(selected_report && interviewee_id)
date_string = time2text(world.realtime, "YYYY_MM_DD")
var/fileLoc = "data/dutylogs/[usr.ckey]/[date_string]-[report_id]-[interviewee_id].log"
var/fileName = "[date_string]-[report_id]-[interviewee_id].log"
var/fileLoc = "data/dutylogs/[usr.ckey]/[date_string]-[selected_report.id]-[interviewee_id].log"
var/fileName = "[date_string]-[selected_report.id]-[interviewee_id].log"
if(fexists(fileLoc))
var/safe = 0
var/i = 1
while(!safe)
fileLoc = "data/dutylogs/[usr.ckey]/[date_string]-[report_id]-[interviewee_id]-[i].log"
fileLoc = "data/dutylogs/[usr.ckey]/[date_string]-[selected_report.id]-[interviewee_id]-[i].log"
if(!fexists(fileLoc))
fileName = "[date_string]-[report_id]-[interviewee_id]-[i].log"
fileName = "[date_string]-[selected_report.id]-[interviewee_id]-[i].log"
safe = 1
break
i++
last_file_loc = fileLoc
sLogFile = file(fileLoc)
sLogFile << "[report_id]-[interviewee_id]"
sLogFile << "Case file: [report_name]"
sLogFile << "[selected_report.id]-[interviewee_id]"
sLogFile << "Case file: [selected_report.title]"
sLogFile << "--------------------------------"
sLogFile << "Date: [date_string]"
sLogFile << "--------------------------------"
sLogFile << "Interviewer: [usr.name]"
sLogFile << "Interviewee: [interviewee_name]"
sLogFile << "Antag involvement: [antag_involvement]"
sLogFile << "Recorder started: [get_time()]"
sLogFile << "--------------------------------"
@@ -141,19 +148,63 @@
//If we have sql ccia logs enabled, then persist it here
if(config.sql_ccia_logs && establish_db_connection(dbcon))
var/DBQuery/save_log = dbcon.NewQuery("INSERT INTO ss13_ccia_reports_transcripts (id, report_id, character_id, interviewer, text) VALUES (NULL, :report_id:, :character_id:, :interviewer:, :text:)")
save_log.Execute(list("report_id" = report_id, "character_id" = interviewee_id, "interviewer" = usr.name, "text" = P.info))
//This query is split up into multiple parts due to the length limitations of byond.
//To avoid this the text and the antag_involvement_text are saved separately
var/DBQuery/save_log = dbcon.NewQuery("INSERT INTO ss13_ccia_reports_transcripts (id, report_id, character_id, interviewer, antag_involvement, text) VALUES (NULL, :report_id:, :character_id:, :interviewer:, :antag_involvement:, :text:)")
save_log.Execute(list("report_id" = selected_report.id, "character_id" = interviewee_id, "interviewer" = usr.name, "antag_involvement" = antag_involvement, "text" = P.info))
//Run the query to get the inserted id
var/transcript_id = null
var/DBQuery/tid = dbcon.NewQuery("SELECT LAST_INSERT_ID() AS log_id")
tid.Execute()
if (tid.NextRow())
transcript_id = text2num(tid.item[1])
if(tid)
var/DBQuery/add_text = dbcon.NewQuery("UPDATE ss13_ccia_reports_transcripts SET text = :text: WHERE id = :id:")
add_text.Execute(list("id" = transcript_id, "text" = P.info))
var/DBQuery/add_antag_involvement_text = dbcon.NewQuery("UPDATE ss13_ccia_reports_transcripts SET antag_involvement_text = :antag_involvement_text: WHERE id = :id:")
add_antag_involvement_text.Execute(list("id" = transcript_id, "antag_involvement_text" = antag_involvement_text))
else
message_cciaa("Transcript could not be saved correctly. TiD Missing")
//Check if we need to update the status to review required
if(antag_involvement && selected_report.status == "in progress")
to_chat(usr, "<span class='notice'>The device beeps and flashes \"Liaison Review Required. Interviewee claimed antag involvement.\".</span>")
var/DBQuery/update_db = dbcon.NewQuery("UPDATE ss13_ccia_reports SET status = 'review required' WHERE id = :id:")
update_db.Execute(list("id" = selected_report.id))
sLogFile = null
report_id = null
report_name = null
selected_report = null
interviewee_id = null
interviewee_name = null
date_string = null
antag_involvement = null
to_chat(usr, "<span class='notice'>The device beeps and flashes \"Recording stopped log saved.\".</span>")
icon_state = "taperecorderidle"
return
/obj/item/device/taperecorder/cciaa/verb/reset_recorder()
set name = "Reset Recorder"
set category = "Recorder"
if(!check_rights(R_CCIAA,FALSE))
to_chat(usr, "<span class='notice'>The device beeps and flashes \"Unauthorised user.\".</span>")
return
var/confirmation = alert("Do you want to reset the recorder without saving?", "Reset Recorder", "Yes", "No")
if(confirmation != "Yes")
return
sLogFile = null
selected_report = null
interviewee_id = null
interviewee_name = null
date_string = null
antag_involvement = null
to_chat(usr, "<span class='notice'>The device beeps and flashes \"Recorder Reset.\".</span>")
icon_state = "taperecorderidle"
/obj/item/device/taperecorder/cciaa/proc/get_last_transcript()
var/list/lFile = file2list(last_file_loc)
@@ -193,7 +244,7 @@
return
/obj/item/device/taperecorder/cciaa/verb/pause_recording()
set name = "Pause"
set name = "Pause Recording"
set category = "Recorder"
if(use_check_and_message(usr))
@@ -218,10 +269,12 @@
return
/obj/item/device/taperecorder/cciaa/attack_self(mob/user)
if(!report_id)
//If we are a ccia agent, then always go to the record function (to prompt for the report or start the recording)
if(check_rights(R_CCIAA,FALSE))
record()
return
//Otherwise check if we already registered a interviewee
if(interviewee_id)
to_chat(user,"<span class='notice'>The device beeps and flashes \"A interviewee has already been associated with this interview\".</span>")
return
@@ -231,12 +284,28 @@
if(!H.character_id)
to_chat(user,"<span class='notice'>The device beeps and flashes \"Fingerprint is not recognized\".</span>")
return
//Sync the intervieweee_id and interviewee_name
interviewee_id = H.character_id
interviewee_name = H.name
//Show them the report they are interviewed about
if(selected_report.public_topic)
send_link(usr, selected_report.public_topic)
//Ask them if there was antag involvement
var/a = input(user, "Were your actions influenced by antagonists?", "Antagonist involvement") in list("yes","no")
if(a == "yes")
antag_involvement = TRUE
antag_involvement_text = sanitizeSafe(input("Describe how your actions were influenced by the antagonists.", "Antag involvement") as message|null)
message_cciaa("CCIA Interview: [user] claimed their actions were influenced by antagonists.", R_CCIAA)
else
interviewee_id = H.character_id
interviewee_name = H.name
to_chat(user,"<span class='notice'>The device beeps and flashes \"Fingerprint recognized, Employee: [interviewee_name], ID: [interviewee_id]\".</span>")
playsound(src.loc, 'sound/machines/ping.ogg', 50, 0)
return
antag_involvement = FALSE
to_chat(user,"<span class='notice'>The device beeps and flashes \"Fingerprint recognized, Employee: [interviewee_name], ID: [interviewee_id]\".</span>")
playsound(src.loc, 'sound/machines/ping.ogg', 50, 0)
else
to_chat(user,"<span class='notice'>The device beeps and flashes \"Unrecognized entity - Aborting\".</span>")
return