mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-24 04:27:35 +01:00
Adds public notes (#28373)
* Adds public notes * oops sorry CI * AA review * head of staff requests * darkmode + disclaimer
This commit is contained in:
@@ -413,9 +413,11 @@ CREATE TABLE `notes` (
|
||||
`automated` TINYINT(3) UNSIGNED NULL DEFAULT '0',
|
||||
`deleted` TINYINT(4) NOT NULL DEFAULT '0',
|
||||
`deletedby` VARCHAR(32) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci',
|
||||
`public` TINYINT(4) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `ckey` (`ckey`),
|
||||
KEY `deleted` (`deleted`)
|
||||
KEY `deleted` (`deleted`),
|
||||
KEY `public` (`public`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
# Updating DB from 64-65 ~Contrabang
|
||||
# Adds a new column to the notes table for public notes
|
||||
ALTER TABLE `notes`
|
||||
ADD COLUMN `public` TINYINT NOT NULL DEFAULT 0 AFTER `deletedby`,
|
||||
ADD INDEX `public` (`public`);
|
||||
@@ -431,7 +431,7 @@
|
||||
#define INVESTIGATE_HOTMIC "hotmic"
|
||||
|
||||
// The SQL version required by this version of the code
|
||||
#define SQL_VERSION 64
|
||||
#define SQL_VERSION 65
|
||||
|
||||
// Vending machine stuff
|
||||
#define CAT_NORMAL (1<<0)
|
||||
|
||||
@@ -283,4 +283,52 @@ GLOBAL_VAR_INIT(admin_ooc_colour, "#b82e00")
|
||||
|
||||
init_verbs()
|
||||
|
||||
/client/verb/show_own_notes()
|
||||
set name = "Show My Notes"
|
||||
set desc = "View your public notes."
|
||||
set category = "OOC"
|
||||
|
||||
if(!key)
|
||||
return
|
||||
if(!SSdbcore.IsConnected())
|
||||
to_chat(src, "<span class='danger'>Failed to establish database connection.</span>")
|
||||
return
|
||||
var/list/output = list("<!DOCTYPE html>")
|
||||
var/datum/db_query/query_get_notes = SSdbcore.NewQuery({"
|
||||
SELECT timestamp, notetext, adminckey, last_editor, server, crew_playtime, round_id
|
||||
FROM notes WHERE ckey=:targetkey AND deleted=0 AND public=1 ORDER BY timestamp"}, list(
|
||||
"targetkey" = ckey
|
||||
))
|
||||
if(!query_get_notes.warn_execute())
|
||||
to_chat(src, "<span class='danger'>Unfortunately, we were not able to retrieve your notes.</span>")
|
||||
qdel(query_get_notes)
|
||||
return
|
||||
output += "<h2><center>Notes of [ckey]</center></h2><br><center><font size='1'>Don't discuss warnings or other punishments from the admins in Paradise Discord.</font></center>"
|
||||
output += "<hr style='background:#000000; border:0; height:3px'>"
|
||||
var/found_notes = FALSE
|
||||
while(query_get_notes.NextRow())
|
||||
found_notes = TRUE
|
||||
var/timestamp = query_get_notes.item[1]
|
||||
var/notetext = query_get_notes.item[2]
|
||||
var/adminckey = query_get_notes.item[3]
|
||||
var/last_editor = query_get_notes.item[4]
|
||||
var/server = query_get_notes.item[5]
|
||||
var/mins = text2num(query_get_notes.item[6])
|
||||
var/round_id = text2num(query_get_notes.item[7])
|
||||
output += "<b>[timestamp][round_id ? " (Round [round_id])" : ""] | [server] | [adminckey]"
|
||||
if(mins)
|
||||
var/playstring = get_exp_format(mins)
|
||||
output += " | [playstring] as Crew"
|
||||
output += "</b>"
|
||||
|
||||
if(last_editor)
|
||||
output += " <font size='1'>Last edit by [last_editor].</font>"
|
||||
output += "<br>[replacetext(notetext, "\n", "<br>")]<hr style='background:#000000; border:0; height:1px'>"
|
||||
if(!found_notes)
|
||||
output += "<b>You have no public notes.</b>"
|
||||
qdel(query_get_notes)
|
||||
var/datum/browser/popup = new(mob, "show_public_notes", "Public Notes", 900, 500)
|
||||
popup.set_content(output.Join(""))
|
||||
popup.open()
|
||||
|
||||
#undef DEFAULT_PLAYER_OOC_COLOUR
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -866,6 +866,10 @@
|
||||
var/note_id = href_list["editnote"]
|
||||
edit_note(note_id)
|
||||
|
||||
else if(href_list["toggle_note_publicity"])
|
||||
var/note_id = href_list["toggle_note_publicity"]
|
||||
toggle_note_publicity(note_id)
|
||||
|
||||
else if(href_list["shownote"])
|
||||
var/target = href_list["shownote"]
|
||||
show_note(index = target)
|
||||
|
||||
@@ -173,7 +173,7 @@ ipc_screens = [
|
||||
# Enable/disable the database on a whole
|
||||
sql_enabled = false
|
||||
# SQL version. If this is a mismatch, round start will be delayed
|
||||
sql_version = 64
|
||||
sql_version = 65
|
||||
# SQL server address. Can be an IP or DNS name
|
||||
sql_address = "127.0.0.1"
|
||||
# SQL server port
|
||||
|
||||
Reference in New Issue
Block a user