Files
CHOMPStation2/code/modules/admin/admin_report.dm
Cael_Aislinn 31349fb7d3 Merge branch 'incremental_tg' r5067 into bs12_with_tgport
removed extraneous admin attack messages, temporarily disabled much moderator stuff (will be re-enabled in future updates)

Conflicts:
	baystation12.dme
	code/__HELPERS/type2type.dm
	code/controllers/configuration.dm
	code/datums/datumvars.dm
	code/datums/helper_datums/getrev.dm
	code/defines/obj.dm
	code/game/gamemodes/events/black_hole.dm
	code/game/gamemodes/events/space_ninja.dm
	code/game/gamemodes/wizard/rightandwrong.dm
	code/game/jobs/job/captain.dm
	code/game/jobs/job/job.dm
	code/game/jobs/job_controller.dm
	code/game/machinery/bots/medbot.dm
	code/game/machinery/computer/card.dm
	code/game/machinery/telecomms/traffic_control.dm
	code/game/machinery/turrets.dm
	code/game/machinery/wishgranter.dm
	code/game/objects/items/blueprints.dm
	code/game/objects/items/devices/uplinks.dm
	code/game/objects/items/stacks/stack.dm
	code/game/objects/items/weapons/surgery_tools.dm
	code/game/turfs/turf.dm
	code/game/verbs/ooc.dm
	code/global.dm
	code/modules/admin/IsBanned.dm
	code/modules/admin/admin.dm
	code/modules/admin/admin_memo.dm
	code/modules/admin/admin_verbs.dm
	code/modules/admin/holder2.dm
	code/modules/admin/player_panel.dm
	code/modules/admin/verbs/adminpm.dm
	code/modules/admin/verbs/diagnostics.dm
	code/modules/assembly/igniter.dm
	code/modules/client/client defines.dm
	code/modules/client/client procs.dm
	code/modules/clothing/spacesuits/miscellaneous.dm
	code/modules/clothing/suits/armor.dm
	code/modules/clothing/suits/jobs.dm
	code/modules/mining/mine_turfs.dm
	code/modules/mob/living/carbon/human/say.dm
	code/modules/mob/living/carbon/human/update_icons.dm
	code/modules/mob/living/living.dm
	code/modules/mob/living/living_defense.dm
	code/modules/mob/living/silicon/robot/emote.dm
	code/modules/mob/living/silicon/robot/life.dm
	code/modules/mob/mob_cleanup.dm
	code/modules/mob/new_player/new_player.dm
	code/modules/mob/new_player/preferences.dm
	code/modules/paperwork/paper.dm
	code/modules/paperwork/photocopier.dm
	code/modules/projectiles/guns/projectile/automatic.dm
	code/modules/reagents/Chemistry-Machinery.dm
	code/setup.dm
	code/stylesheet.dm
	code/world.dm
	config/admins.txt
	config/config.txt
	html/changelog.html
	icons/mob/items_lefthand.dmi
	icons/mob/items_righthand.dmi
	icons/mob/suit.dmi
	icons/obj/clothing/suits.dmi
	icons/turf/areas.dmi

Signed-off-by: Cael_Aislinn <cael_aislinn@yahoo.com.au>
2012-12-28 14:13:11 +10:00

181 lines
4.4 KiB
Plaintext

// Reports are a way to notify admins of wrongdoings that happened
// while no admin was present. They work a bit similar to news, but
// they can only be read by admins and moderators.
// a single admin report
datum/admin_report/var
ID // the ID of the report
body // the content of the report
author // key of the author
date // date on which this was created
done // whether this was handled
offender_key // store the key of the offender
offender_cid // store the cid of the offender
datum/report_topic_handler
Topic(href,href_list)
..()
var/client/C = locate(href_list["client"])
if(href_list["action"] == "show_reports")
C.display_admin_reports()
else if(href_list["action"] == "remove")
C.mark_report_done(text2num(href_list["ID"]))
else if(href_list["action"] == "edit")
C.edit_report(text2num(href_list["ID"]))
var/datum/report_topic_handler/report_topic_handler
world/New()
..()
report_topic_handler = new
// add a new news datums
proc/make_report(body, author, okey, cid)
var/savefile/Reports = new("data/reports.sav")
var/list/reports
var/lastID
Reports["reports"] >> reports
Reports["lastID"] >> lastID
if(!reports) reports = list()
if(!lastID) lastID = 0
var/datum/admin_report/created = new()
created.ID = ++lastID
created.body = body
created.author = author
created.date = world.realtime
created.done = 0
created.offender_key = okey
created.offender_cid = cid
reports.Insert(1, created)
Reports["reports"] << reports
Reports["lastID"] << lastID
// load the reports from disk
proc/load_reports()
var/savefile/Reports = new("data/reports.sav")
var/list/reports
Reports["reports"] >> reports
if(!reports) reports = list()
return reports
// check if there are any unhandled reports
client/proc/unhandled_reports()
if(!src.holder) return 0
var/list/reports = load_reports()
for(var/datum/admin_report/N in reports)
if(N.done)
continue
else return 1
return 0
// checks if the player has an unhandled report against him
client/proc/is_reported()
var/list/reports = load_reports()
for(var/datum/admin_report/N in reports) if(!N.done)
if(N.offender_key == src.key)
return 1
return 0
// display only the reports that haven't been handled
client/proc/display_admin_reports()
set category = "Admin"
set name = "Display Admin Reports"
if(!src.holder) return
var/list/reports = load_reports()
var/output = ""
if(unhandled_reports())
// load the list of unhandled reports
for(var/datum/admin_report/N in reports)
if(N.done)
continue
output += "<b>Reported player:</b> [N.offender_key](CID: [N.offender_cid])<br>"
output += "<b>Offense:</b>[N.body]<br>"
output += "<small>Occured at [time2text(N.date,"MM/DD hh:mm:ss")]</small><br>"
output += "<small>authored by <i>[N.author]</i></small><br>"
output += " <a href='?src=\ref[report_topic_handler];client=\ref[src];action=remove;ID=[N.ID]'>Flag as Handled</a>"
if(src.key == N.author)
output += " <a href='?src=\ref[report_topic_handler];client=\ref[src];action=edit;ID=[N.ID]'>Edit</a>"
output += "<br>"
output += "<br>"
else
output += "Whoops, no reports!"
usr << browse(output, "window=news;size=600x400")
client/proc/Report(mob/M as mob in world)
set category = "Admin"
if(!src.holder)
return
var/CID = "Unknown"
if(M.client)
CID = M.client.computer_id
var/body = input(src.mob, "Describe in detail what you're reporting [M] for", "Report") as null|text
if(!body) return
make_report(body, key, M.key, CID)
spawn(1)
display_admin_reports()
client/proc/mark_report_done(ID as num)
if(!src.holder || src.holder.level < 0)
return
var/savefile/Reports = new("data/reports.sav")
var/list/reports
Reports["reports"] >> reports
var/datum/admin_report/found
for(var/datum/admin_report/N in reports)
if(N.ID == ID)
found = N
if(!found) src << "<b>* An error occured, sorry.</b>"
found.done = 1
Reports["reports"] << reports
client/proc/edit_report(ID as num)
if(!src.holder || src.holder.level < 0)
src << "<b>You tried to modify the news, but you're not an admin!"
return
var/savefile/Reports = new("data/reports.sav")
var/list/reports
Reports["reports"] >> reports
var/datum/admin_report/found
for(var/datum/admin_report/N in reports)
if(N.ID == ID)
found = N
if(!found) src << "<b>* An error occured, sorry.</b>"
var/body = input(src.mob, "Enter a body for the news", "Body") as null|message
if(!body) return
found.body = body
Reports["reports"] << reports