Merge branch 'master' of https://github.com/tgstation/-tg-station into catsandpugs

Conflicts:
	_maps/map_files/TgStation/tgstation.2.1.3.dmm
This commit is contained in:
bgobandit
2015-07-24 11:58:52 -04:00
61 changed files with 1519 additions and 1194 deletions
+86 -52
View File
@@ -1,58 +1,92 @@
#define MEMOFILE "data/memo.sav" //where the memos are saved
#define ENABLE_MEMOS 1 //using a define because screw making a config variable for it. This is more efficient and purty.
//switch verb so we don't spam up the verb lists with like, 3 verbs for this feature.
/client/proc/admin_memo(task in list("write","show","delete"))
/client/proc/admin_memo(task in list("Show","Write","Edit","Remove"))
set name = "Memo"
set category = "Server"
if(!ENABLE_MEMOS) return
if(!check_rights(0)) return
if(!dbcon.IsConnected())
usr << "<span class='danger'>Failed to establish database connection.</span>"
return
var/sql_ckey = sanitizeSQL(src.ckey)
switch(task)
if("write") admin_memo_write()
if("show") admin_memo_show()
if("delete") admin_memo_delete()
//write a message
/client/proc/admin_memo_write()
var/savefile/F = new(MEMOFILE)
if(F)
var/memo = input(src,"Type your memo\n(Leaving it blank will delete your current memo):","Write Memo",null) as null|message
switch(memo)
if(null)
if("Write")
var/memotext = input(src,"Write your Memo","Memo") as text|null
if(!memotext)
return
if("")
message_admins("<span class='admin'>[src.ckey] removed their own Memo</span>")
log_admin("[src.ckey] removed their own Memo")
F.dir.Remove(ckey)
memotext = sanitizeSQL(memotext)
var/timestamp = SQLtime()
var/DBQuery/query_memoadd = dbcon.NewQuery("INSERT INTO [format_table_name("memo")] (ckey, memotext, timestamp) VALUES ('[sql_ckey]', '[memotext]', '[timestamp]')")
if(!query_memoadd.Execute())
var/err = query_memoadd.ErrorMsg()
log_game("SQL ERROR adding new memo. Error : \[[err]\]\n")
return
if( findtext(memo,"<script",1,0) )
return
F[ckey] << "[key] on [time2text(world.realtime,"(DDD) DD MMM hh:mm")]<br>[memo]"
message_admins("[key] set an admin memo:<br>[memo]")
log_admin("[key] set an admin memo:[memo]")
//show all memos
/client/proc/admin_memo_show()
if(ENABLE_MEMOS)
var/savefile/F = new(MEMOFILE)
if(F)
for(var/ckey in F.dir)
src << "<center><span class='motd'><span class='prefix'>Admin Memo</span><span class='emote'> by [F[ckey]]</span></span></center>"
//delete your own or somebody else's memo
/client/proc/admin_memo_delete()
var/savefile/F = new(MEMOFILE)
if(F)
var/ckey
if(check_rights(R_SERVER,0)) //high ranking admins can delete other admin's memos
ckey = input(src,"Whose memo shall we remove?","Remove Memo",null) as null|anything in F.dir
else
ckey = src.ckey
if(ckey)
message_admins("<span class='admin'>[src.ckey] removed [ckey]'s Memo.</span>")
log_admin("[src.ckey] removed Memo created by [ckey].")
for(var/memo in F.dir)
F.dir.Remove(ckey)
#undef MEMOFILE
#undef ENABLE_MEMOS
log_admin("[key_name(src)] has set a memo: [memotext]")
message_admins("[key_name_admin(src)] has set a memo:<br>[memotext]")
if("Edit")
var/DBQuery/query_memolist = dbcon.NewQuery("SELECT ckey FROM [format_table_name("memo")])") //should select all memos there are
query_memolist.Execute()
var/list/memolist = list()
while(query_memolist.NextRow())
var/ckey = query_memolist.item[2]
memolist += "[ckey]"
if(!memolist.len)
src << "No memos found in database."
return
var/target_ckey = input(src, "Select whose memo to edit", "Select memo") as null|anything in memolist
if(!target_ckey)
return
var/target_sql_ckey = sanitizeSQL(target_ckey)
var/DBQuery/query_memofind = dbcon.NewQuery("SELECT ckey, memotext FROM [format_table_name("memo")] WHERE (ckey = '[target_sql_ckey]')")
query_memofind.Execute()
if(query_memofind.NextRow())
var/old_memo = query_memofind.item[3]
var/new_memo = input("Input new memo", "New Memo", "[old_memo]", null) as null|text
if(!new_memo)
return
new_memo = sanitizeSQL(new_memo)
var/edit_text = "Edited by [sql_ckey] on [SQLtime()] from<br>[old_memo]<br>to<br>[new_memo]<hr>"
edit_text = sanitizeSQL(edit_text)
var/DBQuery/update_query = dbcon.NewQuery("UPDATE [format_table_name("memo")] SET memotext = '[new_memo]', last_editor = '[sql_ckey]', edits = CONCAT(edits,'[edit_text]') WHERE (ckey = '[target_sql_ckey]')")
if(!update_query.Execute())
var/err = update_query.ErrorMsg()
log_game("SQL ERROR editing memo. Error : \[[err]\]\n")
return
if(target_sql_ckey == sql_ckey)
log_admin("[key_name(src)] has edited their memo from [old_memo] to [new_memo]")
message_admins("[key_name_admin(src)] has edited their memo from<br>[old_memo]<br>to<br>[new_memo]")
else
log_admin("[key_name(src)] has edited [target_sql_ckey]'s memo from [old_memo] to [new_memo]")
message_admins("[key_name_admin(src)] has edited [target_sql_ckey]'s memo from<br>[old_memo]<br>to<br>[new_memo]")
if("Show")
var/DBQuery/query_memoshow = dbcon.NewQuery("SELECT id, ckey, memotext, timestamp, last_editor FROM [format_table_name("memo")])")
var/output
while(query_memoshow.NextRow())
var/id = query_memoshow.item[1]
var/ckey = query_memoshow.item[2]
var/memotext = query_memoshow.item[3]
var/timestamp = query_memoshow.item[4]
var/last_editor = query_memoshow.item[5]
output += "<span class='memo'>Memo by <span class='prefix'>[ckey]</span> on [timestamp]:"
if(last_editor)
output += "<br><span class='memoedit'>Last edit by [last_editor] <A href='?_src_=holder;memoeditlist=[id]'>(Click here to see edit log)</A></span>"
output += "<br>[memotext]</span><br>"
src << output
if("Remove")
var/DBQuery/query_memolist = dbcon.NewQuery("SELECT ckey FROM [format_table_name("memo")])") //should select all memos there are
query_memolist.Execute()
if(!query_memolist.NextRow())
src << "No memos found in database."
return
var/target_ckey = input(src, "Select whose memo to delete", "Select memo") as null|anything in query_memolist //does this work? it's not initialized as an actual list
if(!target_ckey)
return
var/target_sql_ckey = sanitizeSQL(target_ckey)
var/DBQuery/query_memodel = dbcon.NewQuery("DELETE FROM [format_table_name("memo")] WHERE ckey = '[target_sql_ckey]'")
if(!query_memodel.Execute())
var/err = query_memodel.ErrorMsg()
log_game("SQL ERROR removing memo. Error : \[[err]\]\n")
return
if(target_sql_ckey == sql_ckey)
log_admin("[key_name(src)] has removed their memo.")
message_admins("[key_name_admin(src)] has removed their memo.")
else
log_admin("[key_name(src)] has removed [target_sql_ckey]'s memo.")
message_admins("[key_name_admin(src)] has removed [target_sql_ckey]'s memo.")
+8 -1
View File
@@ -2057,6 +2057,13 @@
FM.locked ^= 1
src.access_news_network()
else if(href_list["memoeditlist"])
var/DBQuery/query_memoedits = dbcon.NewQuery("SELECT edits FROM [format_table_name("memo")] WHERE (id = '[href_list["id"]]")
query_memoedits.Execute()
if(query_memoedits.NextRow())
var/edit_log = query_memoedits.item[6]
usr << browse(edit_log,"window=memoeditlist")
else if(href_list["check_antagonist"])
if(!check_rights(R_ADMIN))
return
@@ -2078,4 +2085,4 @@
message_admins("[key_name_admin(usr)] has kicked [afkonly ? "all AFK" : "all"] clients from the lobby. [length(listkicked)] clients kicked: [strkicked ? strkicked : "--"]")
log_admin("[key_name(usr)] has kicked [afkonly ? "all AFK" : "all"] clients from the lobby. [length(listkicked)] clients kicked: [strkicked ? strkicked : "--"]")
else
usr << "You may only use this when the game is running"
usr << "You may only use this when the game is running"