mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-01-19 05:53:00 +00:00
Adds public notes (#28373)
* Adds public notes * oops sorry CI * AA review * head of staff requests * darkmode + disclaimer
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/proc/add_note(target_ckey, notetext, timestamp, adminckey, logged = 1, checkrights = 1, show_after = TRUE, automated = FALSE, sanitise_html = TRUE) // Dont you EVER disable this last param unless you know what you're doing
|
||||
/proc/add_note(target_ckey, notetext, timestamp, adminckey, logged = 1, checkrights = 1, show_after = TRUE, automated = FALSE, sanitise_html = TRUE, public = FALSE) // Dont you EVER disable 'sanitise_html', only automated systems should use this
|
||||
if(checkrights && !check_rights(R_ADMIN|R_MOD))
|
||||
return
|
||||
if(IsAdminAdvancedProcCall() && !sanitise_html)
|
||||
@@ -51,6 +51,7 @@
|
||||
notetext = input(usr,"Write your note","Add Note") as message|null
|
||||
if(!notetext)
|
||||
return
|
||||
public = (alert(usr, "Would you like to make this note public?", "Public Note?", "Private", "Public") == "Public")
|
||||
|
||||
if(!adminckey)
|
||||
adminckey = usr.ckey
|
||||
@@ -66,8 +67,8 @@
|
||||
notetext = html_encode(notetext)
|
||||
|
||||
var/datum/db_query/query_noteadd = SSdbcore.NewQuery({"
|
||||
INSERT INTO notes (ckey, timestamp, notetext, adminckey, server, crew_playtime, round_id, automated)
|
||||
VALUES (:targetckey, NOW(), :notetext, :adminkey, :server, :crewnum, :roundid, :automated)
|
||||
INSERT INTO notes (ckey, timestamp, notetext, adminckey, server, crew_playtime, round_id, automated, public)
|
||||
VALUES (:targetckey, NOW(), :notetext, :adminkey, :server, :crewnum, :roundid, :automated, :public)
|
||||
"}, list(
|
||||
"targetckey" = target_ckey,
|
||||
"notetext" = notetext,
|
||||
@@ -75,15 +76,16 @@
|
||||
"server" = GLOB.configuration.system.instance_id,
|
||||
"crewnum" = crew_number,
|
||||
"roundid" = GLOB.round_id,
|
||||
"automated" = automated
|
||||
"automated" = automated,
|
||||
"public" = public
|
||||
))
|
||||
if(!query_noteadd.warn_execute())
|
||||
qdel(query_noteadd)
|
||||
return
|
||||
qdel(query_noteadd)
|
||||
if(logged)
|
||||
log_admin("[usr ? key_name(usr) : adminckey] has added a note to [target_ckey]: [notetext]")
|
||||
message_admins("[usr ? key_name_admin(usr) : adminckey] has added a note to [target_ckey]:<br>[notetext]")
|
||||
log_admin("[usr ? key_name(usr) : adminckey] has added a [public ? "public" : "private"] note to [target_ckey]: [notetext]")
|
||||
message_admins("[usr ? key_name_admin(usr) : adminckey] has added a [public ? "public" : "private"] note to [target_ckey]:<br>[notetext]")
|
||||
if(show_after)
|
||||
show_note(target_ckey)
|
||||
|
||||
@@ -193,7 +195,7 @@
|
||||
if(target_ckey)
|
||||
var/target_sql_ckey = ckey(target_ckey)
|
||||
var/datum/db_query/query_get_notes = SSdbcore.NewQuery({"
|
||||
SELECT id, timestamp, notetext, adminckey, last_editor, server, crew_playtime, round_id, automated
|
||||
SELECT id, timestamp, notetext, adminckey, last_editor, server, crew_playtime, round_id, automated, public
|
||||
FROM notes WHERE ckey=:targetkey AND deleted=0 ORDER BY timestamp"}, list(
|
||||
"targetkey" = target_sql_ckey
|
||||
))
|
||||
@@ -214,6 +216,7 @@
|
||||
var/mins = text2num(query_get_notes.item[7])
|
||||
var/round_id = text2num(query_get_notes.item[8])
|
||||
var/automated = text2num(query_get_notes.item[9]) // 0/1 bool stored in table
|
||||
var/public = text2num(query_get_notes.item[10]) // 0/1 bool stored in table
|
||||
output += "<b>[timestamp][round_id ? " (Round [round_id])" : ""] | [server] | [adminckey]"
|
||||
if(mins)
|
||||
var/playstring = get_exp_format(mins)
|
||||
@@ -221,7 +224,14 @@
|
||||
output += "</b>"
|
||||
|
||||
if(!linkless)
|
||||
output += " <a href='byond://?_src_=holder;removenote=[id]'>\[Remove Note\]</a> [automated ? "\[Automated Note\]" : "<a href='byond://?_src_=holder;editnote=[id]'>\[Edit Note\]</a>"]"
|
||||
var/note_publicity = (public ? "Public Note" : "PRIVATE Note")
|
||||
if(adminckey == usr.ckey)
|
||||
note_publicity = "<a href='byond://?_src_=holder;toggle_note_publicity=[id]'>\[[note_publicity]]</a>"
|
||||
|
||||
output += " <a href='byond://?_src_=holder;removenote=[id]'>\[Remove Note\]</a> \
|
||||
[automated ? "\[Automated Note\]" : "<a href='byond://?_src_=holder;editnote=[id]'>\[Edit Note\]</a>"] \
|
||||
[note_publicity]"
|
||||
|
||||
if(last_editor)
|
||||
output += " <font size='2'>Last edit by [last_editor] <a href='byond://?_src_=holder;noteedits=[id]'>(Click here to see edit log)</a></font>"
|
||||
output += "<br>[replacetext(notetext, "\n", "<br>")]<hr style='background:#000000; border:0; height:1px'>"
|
||||
@@ -257,3 +267,53 @@
|
||||
output += ruler
|
||||
usr << browse(output.Join(""), "window=show_notes;size=900x500")
|
||||
|
||||
/proc/toggle_note_publicity(note_id)
|
||||
if(!usr)
|
||||
return
|
||||
if(!check_rights(R_ADMIN|R_MOD))
|
||||
return
|
||||
if(!SSdbcore.IsConnected())
|
||||
if(usr)
|
||||
to_chat(usr, "<span class='danger'>Failed to establish database connection.</span>")
|
||||
return
|
||||
if(!note_id)
|
||||
return
|
||||
note_id = text2num(note_id)
|
||||
var/datum/db_query/query_find_note_edit = SSdbcore.NewQuery("SELECT ckey, notetext, adminckey, automated, public FROM notes WHERE id=:note_id", list(
|
||||
"note_id" = note_id
|
||||
))
|
||||
if(!query_find_note_edit.warn_execute())
|
||||
qdel(query_find_note_edit)
|
||||
return
|
||||
if(query_find_note_edit.NextRow())
|
||||
var/target_ckey = query_find_note_edit.item[1]
|
||||
var/text = query_find_note_edit.item[2]
|
||||
var/adminckey = query_find_note_edit.item[3]
|
||||
var/automated = query_find_note_edit.item[4]
|
||||
var/public = query_find_note_edit.item[5]
|
||||
if((!adminckey || adminckey != usr.ckey) && !check_rights(R_PERMISSIONS))
|
||||
to_chat(usr, "<span class='notice'>You cannot toggle the publicity of notes created by other users.</span>")
|
||||
return
|
||||
if(automated)
|
||||
to_chat(usr, "<span class='notice'>That note is generated automatically. You can't edit it.</span>")
|
||||
return
|
||||
|
||||
if(public)
|
||||
if(alert(usr, "Are you sure you want to make this note private?", "Private Note?", "Yes", "No") != "Yes")
|
||||
return
|
||||
else
|
||||
if(alert(usr, "Are you sure you want to make this note public?", "Public Note?", "Yes", "No") != "Yes")
|
||||
return
|
||||
|
||||
public = !public
|
||||
var/datum/db_query/query_update_note = SSdbcore.NewQuery("UPDATE notes SET public=:new_public WHERE id=:note_id", list(
|
||||
"new_public" = public,
|
||||
"note_id" = note_id
|
||||
))
|
||||
if(!query_update_note.warn_execute())
|
||||
qdel(query_update_note)
|
||||
return
|
||||
log_admin("[key_name(usr)] has made [target_ckey]'s note [public ? "public" : "private"], contents are \"[text]\".")
|
||||
message_admins("[key_name_admin(usr)] has edited [target_ckey]'s note [public ? "public" : "private"], contents are \"[text]\".")
|
||||
show_note(target_ckey)
|
||||
qdel(query_update_note)
|
||||
|
||||
Reference in New Issue
Block a user