Skip to content

Commit

Permalink
Add Note severity and changes UI of administrative notes (tgstation#3…
Browse files Browse the repository at this point in the history
…9808)

* Adds note_severity and updates dbconfig. New SQL stuff too.

* whoops please don't hack into my database >:^(

* UI change, changed how it's stored in the DB, removed some queries when it returns, changed stuff to key.

* Update sql_message_system.dm

* this was not defined

* random indent

* wait how did this get here

* okay enough web edits I promise

* just kidding I got u

* Update common.css

* Added buttons, changed UI again, standardized the inputs, added severity for appearance bans, fed the dog

* forgot about the banning panel

* added an asset cache

* corrects asset datum var name
  • Loading branch information
CitrusGender authored and Jordie0608 committed Aug 26, 2018
1 parent 8c4b825 commit bb2c823
Show file tree
Hide file tree
Showing 15 changed files with 173 additions and 62 deletions.
13 changes: 10 additions & 3 deletions SQL/database_changelog.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
Any time you make a change to the schema files, remember to increment the database schema version. Generally increment the minor number, major should be reserved for significant changes to the schema. Both values go up to 255.

The latest database version is 4.6; The query to update the schema revision table is:
The latest database version is 4.7; The query to update the schema revision table is:

INSERT INTO `schema_revision` (`major`, `minor`) VALUES (4, 6);
INSERT INTO `schema_revision` (`major`, `minor`) VALUES (4, 7);
or
INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (4, 6);
INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (4, 7);

In any query remember to add a prefix to the table names if you use one.

----------------------------------------------------

Version 4.7, 18 August 2018, by CitrusGender
Modified table `messages`, adding column `severity` to classify notes based on their severity.

ALTER TABLE `messages` ADD `severity` enum('high','medium','minor','none') DEFAULT NULL AFTER `expire_timestamp`

----------------------------------------------------

Version 4.6, 11 August 2018, by Jordie0608
Modified table `messages`, adding column `expire_timestamp` to allow for auto-"deleting" messages.

Expand Down
1 change: 1 addition & 0 deletions SQL/tgstation_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ CREATE TABLE `messages` (
`round_id` int(11) unsigned NOT NULL,
`secret` tinyint(1) unsigned NOT NULL,
`expire_timestamp` datetime DEFAULT NULL,
`severity` enum('high','medium','minor','none') DEFAULT NULL,
`lasteditor` varchar(32) DEFAULT NULL,
`edits` text,
`deleted` tinyint(1) unsigned NOT NULL DEFAULT '0',
Expand Down
1 change: 1 addition & 0 deletions SQL/tgstation_schema_prefixed.sql
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ CREATE TABLE `SS13_messages` (
`round_id` int(11) unsigned NOT NULL,
`secret` tinyint(1) unsigned NOT NULL,
`expire_timestamp` datetime DEFAULT NULL,
`severity` enum('high','medium','minor','none') DEFAULT NULL,
`lasteditor` varchar(32) DEFAULT NULL,
`edits` text,
`deleted` tinyint(1) unsigned NOT NULL DEFAULT '0',
Expand Down
2 changes: 1 addition & 1 deletion code/__DEFINES/subsystems.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//Update this whenever the db schema changes
//make sure you add an update to the schema_version stable in the db changelog
#define DB_MAJOR_VERSION 4
#define DB_MINOR_VERSION 6
#define DB_MINOR_VERSION 7

//Timing subsystem
//Don't run if there is an identical unique timer active
Expand Down
6 changes: 6 additions & 0 deletions code/modules/admin/DB_ban/functions.dm
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,12 @@
output += "<tr><td><b>IP:</b> <input type='text' name='dbbanaddip'></td>"
output += "<td><b>Computer id:</b> <input type='text' name='dbbanaddcid'></td></tr>"
output += "<tr><td><b>Duration:</b> <input type='text' name='dbbaddduration'></td>"
output += "<tr><td><b>Severity:</b><select name='dbbanaddseverity'>"
output += "<option value=''>--</option>"
output += "<option value='High'>High Severity</option>"
output += "<option value='Medium'>Medium Severity</option>"
output += "<option value='Minor'>Minor Severity</option>"
output += "<option value='None'>No Severity</option>"
output += "<td><b>Job:</b><select name='dbbanaddjob'>"
output += "<option value=''>--</option>"
for(var/j in get_all_jobs())
Expand Down
4 changes: 2 additions & 2 deletions code/modules/admin/NewBan.dm
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ GLOBAL_PROTECT(Banlist)
if (temp)
WRITE_FILE(GLOB.Banlist["minutes"], bantimestamp)
if(!temp)
create_message("note", key, bannedby, "Permanently banned - [reason]", null, null, 0, 0, null, 0)
create_message("note", key, bannedby, "Permanently banned - [reason]", null, null, 0, 0, null, 0, 0)
else
create_message("note", key, bannedby, "Banned for [minutes] minutes - [reason]", null, null, 0, 0, null, 0)
create_message("note", key, bannedby, "Banned for [minutes] minutes - [reason]", null, null, 0, 0, null, 0, 0)
return 1

/proc/RemoveBan(foldername)
Expand Down
130 changes: 93 additions & 37 deletions code/modules/admin/sql_message_system.dm

Large diffs are not rendered by default.

54 changes: 36 additions & 18 deletions code/modules/admin/topic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -213,37 +213,38 @@
var/banduration = text2num(href_list["dbbaddduration"])
var/banjob = href_list["dbbanaddjob"]
var/banreason = href_list["dbbanreason"]
var/banseverity = href_list["dbbanaddseverity"]

switch(bantype)
if(BANTYPE_PERMA)
if(!banckey || !banreason)
to_chat(usr, "Not enough parameters (Requires ckey and reason).")
if(!banckey || !banreason || !banseverity)
to_chat(usr, "Not enough parameters (Requires ckey, severity, and reason).")
return
banduration = null
banjob = null
if(BANTYPE_TEMP)
if(!banckey || !banreason || !banduration)
to_chat(usr, "Not enough parameters (Requires ckey, reason and duration).")
if(!banckey || !banreason || !banduration || !banseverity)
to_chat(usr, "Not enough parameters (Requires ckey, reason, severity and duration).")
return
banjob = null
if(BANTYPE_JOB_PERMA)
if(!banckey || !banreason || !banjob)
to_chat(usr, "Not enough parameters (Requires ckey, reason and job).")
if(!banckey || !banreason || !banjob || !banseverity)
to_chat(usr, "Not enough parameters (Requires ckey, severity, reason and job).")
return
banduration = null
if(BANTYPE_JOB_TEMP)
if(!banckey || !banreason || !banjob || !banduration)
to_chat(usr, "Not enough parameters (Requires ckey, reason and job).")
if(!banckey || !banreason || !banjob || !banduration || !banseverity)
to_chat(usr, "Not enough parameters (Requires ckey, severity, reason and job).")
return
if(BANTYPE_ADMIN_PERMA)
if(!banckey || !banreason)
to_chat(usr, "Not enough parameters (Requires ckey and reason).")
if(!banckey || !banreason || !banseverity)
to_chat(usr, "Not enough parameters (Requires ckey, severity and reason).")
return
banduration = null
banjob = null
if(BANTYPE_ADMIN_TEMP)
if(!banckey || !banreason || !banduration)
to_chat(usr, "Not enough parameters (Requires ckey, reason and duration).")
if(!banckey || !banreason || !banduration || !banseverity)
to_chat(usr, "Not enough parameters (Requires ckey, severity, reason and duration).")
return
banjob = null

Expand All @@ -268,7 +269,7 @@
if(!DB_ban_record(bantype, playermob, banduration, banreason, banjob, bankey, banip, bancid ))
to_chat(usr, "<span class='danger'>Failed to apply ban.</span>")
return
create_message("note", bankey, null, banreason, null, null, 0, 0, null, 0)
create_message("note", bankey, null, banreason, null, null, 0, 0, null, 0, banseverity)

else if(href_list["editrightsbrowser"])
edit_admin_permissions(0)
Expand Down Expand Up @@ -597,14 +598,17 @@
var/reason = input(usr,"Please State Reason.","Reason") as message|null
if(!reason)
return
var/severity = input("Set the severity of the note/ban.", "Severity", null, null) as null|anything in list("High", "Medium", "Minor", "None")
if(!severity)
return
if(!DB_ban_record(BANTYPE_JOB_PERMA, M, -1, reason, "appearance"))
to_chat(usr, "<span class='danger'>Failed to apply ban.</span>")
return
if(M.client)
jobban_buildcache(M.client)
ban_unban_log_save("[key_name(usr)] appearance banned [key_name(M)]. reason: [reason]")
log_admin_private("[key_name(usr)] appearance banned [key_name(M)]. \nReason: [reason]")
create_message("note", M.key, null, "Appearance banned - [reason]", null, null, 0, 0, null, 0)
create_message("note", M.key, null, "Appearance banned - [reason]", null, null, 0, 0, null, 0, severity)
message_admins("<span class='adminnotice'>[key_name_admin(usr)] appearance banned [key_name_admin(M)].</span>")
to_chat(M, "<span class='boldannounce'><BIG>You have been appearance banned by [usr.client.key].</BIG></span>")
to_chat(M, "<span class='boldannounce'>The reason is: [reason]</span>")
Expand Down Expand Up @@ -967,6 +971,7 @@

//Banning comes first
if(notbannedlist.len) //at least 1 unbanned job exists in joblist so we have stuff to ban.
var/severity = null
switch(alert("Temporary Ban for [M.key]?",,"Yes","No", "Cancel"))
if("Yes")
var/mins = input(usr,"How long (in minutes)?","Ban time",1440) as num|null
Expand All @@ -976,7 +981,9 @@
var/reason = input(usr,"Please State Reason For Banning [M.key].","Reason") as message|null
if(!reason)
return

severity = input("Set the severity of the note/ban.", "Severity", null, null) as null|anything in list("High", "Medium", "Minor", "None")
if(!severity)
return
var/msg
for(var/job in notbannedlist)
if(!DB_ban_record(BANTYPE_JOB_TEMP, M, mins, reason, job))
Expand All @@ -990,7 +997,7 @@
msg = job
else
msg += ", [job]"
create_message("note", M.key, null, "Banned from [msg] - [reason]", null, null, 0, 0, null, 0)
create_message("note", M.key, null, "Banned from [msg] - [reason]", null, null, 0, 0, null, 0, severity)
message_admins("<span class='adminnotice'>[key_name_admin(usr)] banned [key_name_admin(M)] from [msg] for [mins] minutes.</span>")
to_chat(M, "<span class='boldannounce'><BIG>You have been [(msg == ("ooc" || "appearance")) ? "banned" : "jobbanned"] by [usr.client.key] from: [msg].</BIG></span>")
to_chat(M, "<span class='boldannounce'>The reason is: [reason]</span>")
Expand All @@ -999,6 +1006,9 @@
return 1
if("No")
var/reason = input(usr,"Please State Reason For Banning [M.key].","Reason") as message|null
severity = input("Set the severity of the note/ban.", "Severity", null, null) as null|anything in list("High", "Medium", "Minor", "None")
if(!severity)
return
if(reason)
var/msg
for(var/job in notbannedlist)
Expand All @@ -1013,7 +1023,7 @@
msg = job
else
msg += ", [job]"
create_message("note", M.key, null, "Banned from [msg] - [reason]", null, null, 0, 0, null, 0)
create_message("note", M.key, null, "Banned from [msg] - [reason]", null, null, 0, 0, null, 0, severity)
message_admins("<span class='adminnotice'>[key_name_admin(usr)] banned [key_name_admin(M)] from [msg].</span>")
to_chat(M, "<span class='boldannounce'><BIG>You have been [(msg == ("ooc" || "appearance")) ? "banned" : "jobbanned"] by [usr.client.key] from: [msg].</BIG></span>")
to_chat(M, "<span class='boldannounce'>The reason is: [reason]</span>")
Expand Down Expand Up @@ -1150,6 +1160,12 @@
var/message_id = href_list["editmessageexpiryempty"]
edit_message_expiry(message_id, browse = 1)

else if(href_list["editmessageseverity"])
if(!check_rights(R_ADMIN))
return
var/message_id = href_list["editmessageseverity"]
edit_message_severity(message_id)

else if(href_list["secretmessage"])
if(!check_rights(R_ADMIN))
return
Expand Down Expand Up @@ -1214,7 +1230,9 @@
if(query_get_message_edits.NextRow())
var/edit_log = query_get_message_edits.item[1]
if(!QDELETED(usr))
usr << browse(edit_log,"window=noteedits")
var/datum/browser/browser = new(usr, "Note edits", "Note edits")
browser.set_content(jointext(edit_log, ""))
browser.open()
qdel(query_get_message_edits)

else if(href_list["newban"])
Expand Down
8 changes: 8 additions & 0 deletions code/modules/client/asset_cache.dm
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,14 @@ GLOBAL_LIST_EMPTY(asset_datums)
"padlock.png" = 'html/padlock.png'
)

/datum/asset/simple/notes
assets = list(
"high_button.png" = 'html/high_button.png',
"medium_button.png" = 'html/medium_button.png',
"minor_button.png" = 'html/minor_button.png',
"none_button.png" = 'html/none_button.png',
)

//this exists purely to avoid meta by pre-loading all language icons.
/datum/asset/language/register()
for(var/path in typesof(/datum/language))
Expand Down
2 changes: 1 addition & 1 deletion code/modules/client/client_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ GLOBAL_LIST_EMPTY(external_rsc_urls)
qdel(query_get_notes)
return
qdel(query_get_notes)
create_message("note", key, system_ckey, message, null, null, 0, 0, null, 0)
create_message("note", key, system_ckey, message, null, null, 0, 0, null, 0, 0)


/client/proc/check_ip_intel()
Expand Down
14 changes: 14 additions & 0 deletions html/browser/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -396,3 +396,17 @@ ul.sparse {
.slider.round:before {
border-radius: 50%;
}

.severity {
margin:0px;
padding: 1px 8px 1px 8px;
border-radius: 25px;
border: 1px solid #161616;
background: #40628a;
color: #ffffff;
}

.severity img {
display: inline-block;
vertical-align: middle;
}
Binary file added html/high_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added html/medium_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added html/minor_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added html/none_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit bb2c823

Please sign in to comment.