From c3ef612490b9e23a75ae6669499f24ba9f3ed402 Mon Sep 17 00:00:00 2001
From: LetterJay
Date: Mon, 11 Sep 2017 23:07:30 -0500
Subject: [PATCH] Ports MSO's fading note system
---
SQL/database_changelog.txt | 58 ++++++++++++++------
SQL/errofreedatabase.sql | 2 +-
SQL/optimisations_2017-02-19.sql | 68 ++++++++++++------------
SQL/tgstation_schema.sql | 9 ++--
SQL/tgstation_schema.sql.rej | 9 ----
SQL/tgstation_schema_prefixed.sql | 11 ++--
SQL/tgstation_schema_prefixed.sql.rej | 9 ----
code/controllers/configuration.dm | 6 +++
code/modules/admin/sql_message_system.dm | 57 ++++++++++++++------
code/modules/admin/topic.dm | 5 +-
code/modules/client/client_procs.dm | 4 +-
code/modules/client/verbs/ooc.dm | 2 +-
12 files changed, 142 insertions(+), 98 deletions(-)
delete mode 100644 SQL/tgstation_schema.sql.rej
delete mode 100644 SQL/tgstation_schema_prefixed.sql.rej
diff --git a/SQL/database_changelog.txt b/SQL/database_changelog.txt
index c2625e2663..7063273378 100644
--- a/SQL/database_changelog.txt
+++ b/SQL/database_changelog.txt
@@ -1,13 +1,52 @@
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 3.1; The query to update the schema revision table is:
+The latest database version is 3.4; The query to update the schema revision table is:
-INSERT INTO `schema_revision` (`major`, `minor`) VALUES (3, 1);
+INSERT INTO `schema_revision` (`major`, `minor`) VALUES (3, 4);
or
-INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (3, 1);
+INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (3, 4);
+
+In any query remember to add a prefix to the table names if you use one.
----------------------------------------------------
+28 August 2017, by MrStonedOne
+Modified table 'messages', adding a deleted column and editing all indexes to include it
+
+ALTER TABLE `messages`
+ADD COLUMN `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `edits`,
+DROP INDEX `idx_msg_ckey_time`,
+DROP INDEX `idx_msg_type_ckeys_time`,
+DROP INDEX `idx_msg_type_ckey_time_odr`,
+ADD INDEX `idx_msg_ckey_time` (`targetckey`,`timestamp`, `deleted`),
+ADD INDEX `idx_msg_type_ckeys_time` (`type`,`targetckey`,`adminckey`,`timestamp`, `deleted`),
+ADD INDEX `idx_msg_type_ckey_time_odr` (`type`,`targetckey`,`timestamp`, `deleted`);
+
+----------------------------------------------------
+
+25 August 2017, by Jordie0608
+
+Modified tables 'connection_log', 'legacy_population', 'library', 'messages' and 'player' to add additional 'round_id' tracking in various forms and 'server_ip' and 'server_port' to the table 'messages'.
+
+ALTER TABLE `connection_log` ADD COLUMN `round_id` INT(11) UNSIGNED NOT NULL AFTER `server_port`;
+ALTER TABLE `legacy_population` ADD COLUMN `round_id` INT(11) UNSIGNED NOT NULL AFTER `server_port`;
+ALTER TABLE `library` ADD COLUMN `round_id_created` INT(11) UNSIGNED NOT NULL AFTER `deleted`;
+ALTER TABLE `messages` ADD COLUMN `server_ip` INT(10) UNSIGNED NOT NULL AFTER `server`, ADD COLUMN `server_port` SMALLINT(5) UNSIGNED NOT NULL AFTER `server_ip`, ADD COLUMN `round_id` INT(11) UNSIGNED NOT NULL AFTER `server_port`;
+ALTER TABLE `player` ADD COLUMN `firstseen_round_id` INT(11) UNSIGNED NOT NULL AFTER `firstseen`, ADD COLUMN `lastseen_round_id` INT(11) UNSIGNED NOT NULL AFTER `lastseen`;
+
+----------------------------------------------------
+
+18 August 2017, by Cyberboss and nfreader
+
+Modified table 'death', adding the columns `last_words` and 'suicide'.
+
+ALTER TABLE `death`
+ADD COLUMN `last_words` varchar(255) DEFAULT NULL AFTER `staminaloss`,
+ADD COLUMN `suicide` tinyint(0) NOT NULL DEFAULT '0' AFTER `last_words`;
+
+Remember to add a prefix to the table name if you use them.
+
+----------------------------------------------------
20th July 2017, by Shadowlight213
Added role_time table to track time spent playing departments.
@@ -17,21 +56,10 @@ CREATE TABLE `role_time` ( `ckey` VARCHAR(32) NOT NULL , `job` VARCHAR(128) NOT
ALTER TABLE `player` ADD `flags` INT NOT NULL default '0' AFTER `accountjoindate`;
-
-UPDATE `schema_revision` SET minor = 1;
Remember to add a prefix to the table name if you use them.
----------------------------------------------------
-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 3.0; The query to update the schema revision table is:
-
-INSERT INTO `schema_revision` (`major`, `minor`) VALUES (3, 0);
-or
-INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (3, 0);
-
-----------------------------------------------------
28 June 2017, by oranges
Added schema_revision to store the current db revision, why start at 3.0?
@@ -336,4 +364,4 @@ UPDATE erro_library SET deleted = 1 WHERE id = someid
(Replace someid with the id of the book you want to soft delete.)
-----------------------------------------------------
+----------------------------------------------------
\ No newline at end of file
diff --git a/SQL/errofreedatabase.sql b/SQL/errofreedatabase.sql
index 7f23fcc861..7d6ea4561c 100644
--- a/SQL/errofreedatabase.sql
+++ b/SQL/errofreedatabase.sql
@@ -12,4 +12,4 @@ ALTER TABLE erro_poll_option RENAME TO SS13_poll_option;
ALTER TABLE erro_poll_question RENAME TO SS13_poll_question;
ALTER TABLE erro_poll_textreply RENAME TO SS13_poll_textreply;
ALTER TABLE erro_poll_vote RENAME TO SS13_poll_vote;
-ALTER TABLE erro_watch RENAME TO SS13_watch;
+ALTER TABLE erro_watch RENAME TO SS13_watch;
\ No newline at end of file
diff --git a/SQL/optimisations_2017-02-19.sql b/SQL/optimisations_2017-02-19.sql
index 674cbcf9c6..b9017497ed 100644
--- a/SQL/optimisations_2017-02-19.sql
+++ b/SQL/optimisations_2017-02-19.sql
@@ -38,7 +38,7 @@ Take note some columns have been renamed, removed or changed type. Any services
----------------------------------------------------*/
START TRANSACTION;
-ALTER TABLE `feedback`.`ban`
+ALTER TABLE `ban`
DROP COLUMN `rounds`
, CHANGE COLUMN `bantype` `bantype` ENUM('PERMABAN', 'TEMPBAN', 'JOB_PERMABAN', 'JOB_TEMPBAN', 'ADMIN_PERMABAN', 'ADMIN_TEMPBAN') NOT NULL
, CHANGE COLUMN `reason` `reason` VARCHAR(2048) NOT NULL
@@ -51,14 +51,14 @@ ALTER TABLE `feedback`.`ban`
, ADD COLUMN `a_ipTEMP` INT UNSIGNED NOT NULL AFTER `a_ip`
, ADD COLUMN `unbanned_ipTEMP` INT UNSIGNED NULL DEFAULT NULL AFTER `unbanned_ip`;
SET SQL_SAFE_UPDATES = 0;
-UPDATE `feedback`.`ban`
+UPDATE `ban`
SET `server_ip` = INET_ATON(SUBSTRING_INDEX(IF(`serverip` = '', '0', IF(SUBSTRING_INDEX(`serverip`, ':', 1) LIKE '%_._%', `serverip`, '0')), ':', 1))
, `server_port` = IF(`serverip` LIKE '%:_%', CAST(SUBSTRING_INDEX(`serverip`, ':', -1) AS UNSIGNED), '0')
, `ipTEMP` = INET_ATON(IF(`ip` LIKE '%_._%', `ip`, '0'))
, `a_ipTEMP` = INET_ATON(IF(`a_ip` LIKE '%_._%', `a_ip`, '0'))
, `unbanned_ipTEMP` = INET_ATON(IF(`unbanned_ip` LIKE '%_._%', `unbanned_ip`, '0'));
SET SQL_SAFE_UPDATES = 1;
-ALTER TABLE `feedback`.`ban`
+ALTER TABLE `ban`
DROP COLUMN `unbanned_ip`
, DROP COLUMN `a_ip`
, DROP COLUMN `ip`
@@ -69,17 +69,17 @@ ALTER TABLE `feedback`.`ban`
COMMIT;
START TRANSACTION;
-ALTER TABLE `feedback`.`connection_log`
+ALTER TABLE `connection_log`
ADD COLUMN `server_ip` INT UNSIGNED NOT NULL AFTER `serverip`
, ADD COLUMN `server_port` SMALLINT UNSIGNED NOT NULL AFTER `server_ip`
, ADD COLUMN `ipTEMP` INT UNSIGNED NOT NULL AFTER `ip`;
SET SQL_SAFE_UPDATES = 0;
-UPDATE `feedback`.`connection_log`
+UPDATE `connection_log`
SET `server_ip` = INET_ATON(SUBSTRING_INDEX(IF(`serverip` = '', '0', IF(SUBSTRING_INDEX(`serverip`, ':', 1) LIKE '%_._%', `serverip`, '0')), ':', 1))
, `server_port` = IF(`serverip` LIKE '%:_%', CAST(SUBSTRING_INDEX(`serverip`, ':', -1) AS UNSIGNED), '0')
, `ipTEMP` = INET_ATON(IF(`ip` LIKE '%_._%', `ip`, '0'));
SET SQL_SAFE_UPDATES = 1;
-ALTER TABLE `feedback`.`connection_log`
+ALTER TABLE `connection_log`
DROP COLUMN `ip`
, DROP COLUMN `serverip`
, CHANGE COLUMN `ipTEMP` `ip` INT(10) UNSIGNED NOT NULL;
@@ -87,12 +87,12 @@ COMMIT;
START TRANSACTION;
SET SQL_SAFE_UPDATES = 0;
-UPDATE `feedback`.`death`
+UPDATE `death`
SET `bruteloss` = LEAST(`bruteloss`, 65535)
, `brainloss` = LEAST(`brainloss`, 65535)
, `fireloss` = LEAST(`fireloss`, 65535)
, `oxyloss` = LEAST(`oxyloss`, 65535);
-ALTER TABLE `feedback`.`death`
+ALTER TABLE `death`
CHANGE COLUMN `pod` `pod` VARCHAR(50) NOT NULL
, CHANGE COLUMN `coord` `coord` VARCHAR(32) NOT NULL
, CHANGE COLUMN `mapname` `mapname` VARCHAR(32) NOT NULL
@@ -109,39 +109,39 @@ ALTER TABLE `feedback`.`death`
, CHANGE COLUMN `oxyloss` `oxyloss` SMALLINT UNSIGNED NOT NULL
, ADD COLUMN `server_ip` INT UNSIGNED NOT NULL AFTER `server`
, ADD COLUMN `server_port` SMALLINT UNSIGNED NOT NULL AFTER `server_ip`;
-UPDATE `feedback`.`death`
+UPDATE `death`
SET `server_ip` = INET_ATON(SUBSTRING_INDEX(IF(`server` = '', '0', IF(SUBSTRING_INDEX(`server`, ':', 1) LIKE '%_._%', `server`, '0')), ':', 1))
, `server_port` = IF(`server` LIKE '%:_%', CAST(SUBSTRING_INDEX(`server`, ':', -1) AS UNSIGNED), '0');
SET SQL_SAFE_UPDATES = 1;
-ALTER TABLE `feedback`.`death`
+ALTER TABLE `death`
DROP COLUMN `server`;
COMMIT;
-ALTER TABLE `feedback`.`library`
+ALTER TABLE `library`
CHANGE COLUMN `category` `category` ENUM('Any', 'Fiction', 'Non-Fiction', 'Adult', 'Reference', 'Religion') NOT NULL
, CHANGE COLUMN `ckey` `ckey` VARCHAR(32) NOT NULL DEFAULT 'LEGACY'
, CHANGE COLUMN `datetime` `datetime` DATETIME NOT NULL
, CHANGE COLUMN `deleted` `deleted` TINYINT(1) UNSIGNED NULL DEFAULT NULL;
-ALTER TABLE `feedback`.`messages`
+ALTER TABLE `messages`
CHANGE COLUMN `type` `type` ENUM('memo', 'message', 'message sent', 'note', 'watchlist entry') NOT NULL
, CHANGE COLUMN `text` `text` VARCHAR(2048) NOT NULL
, CHANGE COLUMN `secret` `secret` TINYINT(1) UNSIGNED NOT NULL;
START TRANSACTION;
-ALTER TABLE `feedback`.`player`
+ALTER TABLE `player`
ADD COLUMN `ipTEMP` INT UNSIGNED NOT NULL AFTER `ip`;
SET SQL_SAFE_UPDATES = 0;
-UPDATE `feedback`.`player`
+UPDATE `player`
SET `ipTEMP` = INET_ATON(IF(`ip` LIKE '%_._%', `ip`, '0'));
SET SQL_SAFE_UPDATES = 1;
-ALTER TABLE `feedback`.`player`
+ALTER TABLE `player`
DROP COLUMN `ip`
, CHANGE COLUMN `ipTEMP` `ip` INT(10) UNSIGNED NOT NULL;
COMMIT;
START TRANSACTION;
-ALTER TABLE `feedback`.`poll_question`
+ALTER TABLE `poll_question`
CHANGE COLUMN `polltype` `polltype` ENUM('OPTION', 'TEXT', 'NUMVAL', 'MULTICHOICE', 'IRV') NOT NULL
, CHANGE COLUMN `adminonly` `adminonly` TINYINT(1) UNSIGNED NOT NULL
, CHANGE COLUMN `createdby_ckey` `createdby_ckey` VARCHAR(32) NULL DEFAULT NULL
@@ -149,36 +149,36 @@ ALTER TABLE `feedback`.`poll_question`
, ADD COLUMN `createdby_ipTEMP` INT UNSIGNED NOT NULL AFTER `createdby_ip`
, DROP COLUMN `for_trialmin`;
SET SQL_SAFE_UPDATES = 0;
-UPDATE `feedback`.`poll_question`
+UPDATE `poll_question`
SET `createdby_ipTEMP` = INET_ATON(IF(`createdby_ip` LIKE '%_._%', `createdby_ip`, '0'));
SET SQL_SAFE_UPDATES = 1;
-ALTER TABLE `feedback`.`poll_question`
+ALTER TABLE `poll_question`
DROP COLUMN `createdby_ip`
, CHANGE COLUMN `createdby_ipTEMP` `createdby_ip` INT(10) UNSIGNED NOT NULL;
COMMIT;
START TRANSACTION;
-ALTER TABLE `feedback`.`poll_textreply`
+ALTER TABLE `poll_textreply`
CHANGE COLUMN `replytext` `replytext` VARCHAR(2048) NOT NULL
, ADD COLUMN `ipTEMP` INT UNSIGNED NOT NULL AFTER `ip`;
SET SQL_SAFE_UPDATES = 0;
-UPDATE `feedback`.`poll_textreply`
+UPDATE `poll_textreply`
SET `ipTEMP` = INET_ATON(IF(`ip` LIKE '%_._%', `ip`, '0'));
SET SQL_SAFE_UPDATES = 1;
-ALTER TABLE `feedback`.`poll_textreply`
+ALTER TABLE `poll_textreply`
DROP COLUMN `ip`
, CHANGE COLUMN `ipTEMP` `ip` INT(10) UNSIGNED NOT NULL;
COMMIT;
START TRANSACTION;
-ALTER TABLE `feedback`.`poll_vote`
+ALTER TABLE `poll_vote`
CHANGE COLUMN `ckey` `ckey` VARCHAR(32) NOT NULL
, ADD COLUMN `ipTEMP` INT UNSIGNED NOT NULL AFTER `ip`;
SET SQL_SAFE_UPDATES = 0;
-UPDATE `feedback`.`poll_vote`
+UPDATE `poll_vote`
SET `ipTEMP` = INET_ATON(IF(`ip` LIKE '%_._%', `ip`, '0'));
SET SQL_SAFE_UPDATES = 1;
-ALTER TABLE `feedback`.`poll_vote`
+ALTER TABLE `poll_vote`
DROP COLUMN `ip`
, CHANGE COLUMN `ipTEMP` `ip` INT(10) UNSIGNED NOT NULL;
COMMIT;
@@ -191,39 +191,39 @@ You may find it helpful to modify or create your own indexes if you utilise addi
----------------------------------------------------*/
-ALTER TABLE `feedback`.`ban`
+ALTER TABLE `ban`
ADD INDEX `idx_ban_checkban` (`ckey` ASC, `bantype` ASC, `expiration_time` ASC, `unbanned` ASC, `job` ASC)
, ADD INDEX `idx_ban_isbanned` (`ckey` ASC, `ip` ASC, `computerid` ASC, `bantype` ASC, `expiration_time` ASC, `unbanned` ASC)
, ADD INDEX `idx_ban_count` (`id` ASC, `a_ckey` ASC, `bantype` ASC, `expiration_time` ASC, `unbanned` ASC);
-ALTER TABLE `feedback`.`ipintel`
+ALTER TABLE `ipintel`
ADD INDEX `idx_ipintel` (`ip` ASC, `intel` ASC, `date` ASC);
-ALTER TABLE `feedback`.`library`
+ALTER TABLE `library`
ADD INDEX `idx_lib_id_del` (`id` ASC, `deleted` ASC)
, ADD INDEX `idx_lib_del_title` (`deleted` ASC, `title` ASC)
, ADD INDEX `idx_lib_search` (`deleted` ASC, `author` ASC, `title` ASC, `category` ASC);
-ALTER TABLE `feedback`.`messages`
+ALTER TABLE `messages`
ADD INDEX `idx_msg_ckey_time` (`targetckey` ASC, `timestamp` ASC)
, ADD INDEX `idx_msg_type_ckeys_time` (`type` ASC, `targetckey` ASC, `adminckey` ASC, `timestamp` ASC)
, ADD INDEX `idx_msg_type_ckey_time_odr` (`type` ASC, `targetckey` ASC, `timestamp` ASC);
-ALTER TABLE `feedback`.`player`
+ALTER TABLE `player`
ADD INDEX `idx_player_cid_ckey` (`computerid` ASC, `ckey` ASC)
, ADD INDEX `idx_player_ip_ckey` (`ip` ASC, `ckey` ASC);
-ALTER TABLE `feedback`.`poll_option`
+ALTER TABLE `poll_option`
ADD INDEX `idx_pop_pollid` (`pollid` ASC);
-ALTER TABLE `feedback`.`poll_question`
+ALTER TABLE `poll_question`
ADD INDEX `idx_pquest_question_time_ckey` (`question` ASC, `starttime` ASC, `endtime` ASC, `createdby_ckey` ASC, `createdby_ip` ASC)
, ADD INDEX `idx_pquest_time_admin` (`starttime` ASC, `endtime` ASC, `adminonly` ASC)
, ADD INDEX `idx_pquest_id_time_type_admin` (`id` ASC, `starttime` ASC, `endtime` ASC, `polltype` ASC, `adminonly` ASC);
-ALTER TABLE `feedback`.`poll_vote`
+ALTER TABLE `poll_vote`
ADD INDEX `idx_pvote_pollid_ckey` (`pollid` ASC, `ckey` ASC)
, ADD INDEX `idx_pvote_optionid_ckey` (`optionid` ASC, `ckey` ASC);
-ALTER TABLE `feedback`.`poll_textreply`
- ADD INDEX `idx_ptext_pollid_ckey` (`pollid` ASC, `ckey` ASC);
+ALTER TABLE `poll_textreply`
+ ADD INDEX `idx_ptext_pollid_ckey` (`pollid` ASC, `ckey` ASC);
\ No newline at end of file
diff --git a/SQL/tgstation_schema.sql b/SQL/tgstation_schema.sql
index 12b0b93c6a..1edd5ad12b 100644
--- a/SQL/tgstation_schema.sql
+++ b/SQL/tgstation_schema.sql
@@ -254,10 +254,11 @@ CREATE TABLE `messages` (
`secret` tinyint(1) unsigned NOT NULL,
`lasteditor` varchar(32) DEFAULT NULL,
`edits` text,
+ `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
- KEY `idx_msg_ckey_time` (`targetckey`,`timestamp`),
- KEY `idx_msg_type_ckeys_time` (`type`,`targetckey`,`adminckey`,`timestamp`),
- KEY `idx_msg_type_ckey_time_odr` (`type`,`targetckey`,`timestamp`)
+ KEY `idx_msg_ckey_time` (`targetckey`,`timestamp`, `deleted`),
+ KEY `idx_msg_type_ckeys_time` (`type`,`targetckey`,`adminckey`,`timestamp`, `deleted`),
+ KEY `idx_msg_type_ckey_time_odr` (`type`,`targetckey`,`timestamp`, `deleted`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -430,4 +431,4 @@ CREATE TABLE `schema_revision` (
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
-/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
\ No newline at end of file
diff --git a/SQL/tgstation_schema.sql.rej b/SQL/tgstation_schema.sql.rej
deleted file mode 100644
index 51068bed4e..0000000000
--- a/SQL/tgstation_schema.sql.rej
+++ /dev/null
@@ -1,9 +0,0 @@
-diff a/SQL/tgstation_schema.sql b/SQL/tgstation_schema.sql (rejected hunks)
-@@ -268,7 +283,6 @@ CREATE TABLE `player` (
- `ip` int(10) unsigned NOT NULL,
- `computerid` varchar(32) NOT NULL,
- `lastadminrank` varchar(32) NOT NULL DEFAULT 'Player',
-- `exp` mediumtext,
- PRIMARY KEY (`id`),
- UNIQUE KEY `ckey` (`ckey`),
- KEY `idx_player_cid_ckey` (`computerid`,`ckey`),
diff --git a/SQL/tgstation_schema_prefixed.sql b/SQL/tgstation_schema_prefixed.sql
index 6c8ea19b0f..72045e50fb 100644
--- a/SQL/tgstation_schema_prefixed.sql
+++ b/SQL/tgstation_schema_prefixed.sql
@@ -31,7 +31,7 @@ CREATE TABLE `SS13_admin` (
-- Table structure for table `SS13_admin_log`
--
-DROP TABLE IF EXISTS `SS13_dmin_log`;
+DROP TABLE IF EXISTS `SS13_admin_log`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `SS13_admin_log` (
@@ -254,10 +254,11 @@ CREATE TABLE `SS13_messages` (
`secret` tinyint(1) unsigned NOT NULL,
`lasteditor` varchar(32) DEFAULT NULL,
`edits` text,
+ `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
- KEY `idx_msg_ckey_time` (`targetckey`,`timestamp`),
- KEY `idx_msg_type_ckeys_time` (`type`,`targetckey`,`adminckey`,`timestamp`),
- KEY `idx_msg_type_ckey_time_odr` (`type`,`targetckey`,`timestamp`)
+ KEY `idx_msg_ckey_time` (`targetckey`,`timestamp`, `deleted`),
+ KEY `idx_msg_type_ckeys_time` (`type`,`targetckey`,`adminckey`,`timestamp`, `deleted`),
+ KEY `idx_msg_type_ckey_time_odr` (`type`,`targetckey`,`timestamp`, `deleted`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -430,4 +431,4 @@ CREATE TABLE `SS13_schema_revision` (
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
-/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
\ No newline at end of file
diff --git a/SQL/tgstation_schema_prefixed.sql.rej b/SQL/tgstation_schema_prefixed.sql.rej
deleted file mode 100644
index dd4bc6a7f5..0000000000
--- a/SQL/tgstation_schema_prefixed.sql.rej
+++ /dev/null
@@ -1,9 +0,0 @@
-diff a/SQL/tgstation_schema_prefixed.sql b/SQL/tgstation_schema_prefixed.sql (rejected hunks)
-@@ -268,7 +297,6 @@ CREATE TABLE `SS13_player` (
- `ip` int(10) unsigned NOT NULL,
- `computerid` varchar(32) NOT NULL,
- `lastadminrank` varchar(32) NOT NULL DEFAULT 'Player',
-- `exp` mediumtext,
- PRIMARY KEY (`id`),
- UNIQUE KEY `ckey` (`ckey`),
- KEY `idx_player_cid_ckey` (`computerid`,`ckey`),
diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm
index bba82e6c8a..5da6c80b3a 100644
--- a/code/controllers/configuration.dm
+++ b/code/controllers/configuration.dm
@@ -108,6 +108,8 @@ GLOBAL_PROTECT(config_dir)
var/use_age_restriction_for_jobs = 0 //Do jobs use account age restrictions? --requires database
var/use_account_age_for_jobs = 0 //Uses the time they made the account for the job restriction stuff. New player joining alerts should be unaffected.
var/see_own_notes = 0 //Can players see their own admin notes (read-only)? Config option in config.txt
+ var/note_fresh_days
+ var/note_stale_days
var/use_exp_tracking = FALSE
var/use_exp_restrictions_heads = FALSE
@@ -484,6 +486,10 @@ GLOBAL_PROTECT(config_dir)
showircname = 1
if("see_own_notes")
see_own_notes = 1
+ if("note_fresh_days")
+ note_fresh_days = text2num(value)
+ if("note_stale_days")
+ note_stale_days = text2num(value)
if("soft_popcap")
soft_popcap = text2num(value)
if("hard_popcap")
diff --git a/code/modules/admin/sql_message_system.dm b/code/modules/admin/sql_message_system.dm
index b42fe93eef..ee13db8978 100644
--- a/code/modules/admin/sql_message_system.dm
+++ b/code/modules/admin/sql_message_system.dm
@@ -56,7 +56,7 @@
if(browse)
browse_messages("[type]")
else
- browse_messages(target_ckey = target_ckey)
+ browse_messages(target_ckey = target_ckey, agegate = TRUE)
/proc/delete_message(message_id, logged = 1, browse)
if(!SSdbcore.Connect())
@@ -68,14 +68,14 @@
var/type
var/target_ckey
var/text
- var/datum/DBQuery/query_find_del_message = SSdbcore.NewQuery("SELECT type, targetckey, adminckey, text FROM [format_table_name("messages")] WHERE id = [message_id]")
+ var/datum/DBQuery/query_find_del_message = SSdbcore.NewQuery("SELECT type, targetckey, adminckey, text FROM [format_table_name("messages")] WHERE id = [message_id] AND deleted = 0")
if(!query_find_del_message.warn_execute())
return
if(query_find_del_message.NextRow())
type = query_find_del_message.item[1]
target_ckey = query_find_del_message.item[2]
text = query_find_del_message.item[4]
- var/datum/DBQuery/query_del_message = SSdbcore.NewQuery("DELETE FROM [format_table_name("messages")] WHERE id = [message_id]")
+ var/datum/DBQuery/query_del_message = SSdbcore.NewQuery("UPDATE [format_table_name("messages")] SET deleted = 1 WHERE id = [message_id]")
if(!query_del_message.warn_execute())
return
if(logged)
@@ -84,7 +84,7 @@
if(browse)
browse_messages("[type]")
else
- browse_messages(target_ckey = target_ckey)
+ browse_messages(target_ckey = target_ckey, agegate = TRUE)
/proc/edit_message(message_id, browse)
if(!SSdbcore.Connect())
@@ -93,7 +93,7 @@
message_id = text2num(message_id)
if(!message_id)
return
- var/datum/DBQuery/query_find_edit_message = SSdbcore.NewQuery("SELECT type, targetckey, adminckey, text FROM [format_table_name("messages")] WHERE id = [message_id]")
+ var/datum/DBQuery/query_find_edit_message = SSdbcore.NewQuery("SELECT type, targetckey, adminckey, text FROM [format_table_name("messages")] WHERE id = [message_id] AND deleted = 0")
if(!query_find_edit_message.warn_execute())
return
if(query_find_edit_message.NextRow())
@@ -107,7 +107,7 @@
return
new_text = sanitizeSQL(new_text)
var/edit_text = sanitizeSQL("Edited by [editor_ckey] on [SQLtime()] from
[old_text]
to
[new_text]
")
- var/datum/DBQuery/query_edit_message = SSdbcore.NewQuery("UPDATE [format_table_name("messages")] SET text = '[new_text]', lasteditor = '[editor_ckey]', edits = CONCAT(IFNULL(edits,''),'[edit_text]') WHERE id = [message_id]")
+ var/datum/DBQuery/query_edit_message = SSdbcore.NewQuery("UPDATE [format_table_name("messages")] SET text = '[new_text]', lasteditor = '[editor_ckey]', edits = CONCAT(IFNULL(edits,''),'[edit_text]') WHERE id = [message_id] AND deleted = 0")
if(!query_edit_message.warn_execute())
return
log_admin_private("[key_name(usr)] has edited a [type] [(type == "note" || type == "message" || type == "watchlist entry") ? " for [target_ckey]" : ""] made by [admin_ckey] from [old_text] to [new_text]")
@@ -115,7 +115,7 @@
if(browse)
browse_messages("[type]")
else
- browse_messages(target_ckey = target_ckey)
+ browse_messages(target_ckey = target_ckey, agegate = TRUE)
/proc/toggle_message_secrecy(message_id)
if(!SSdbcore.Connect())
@@ -124,7 +124,7 @@
message_id = text2num(message_id)
if(!message_id)
return
- var/datum/DBQuery/query_find_message_secret = SSdbcore.NewQuery("SELECT type, targetckey, adminckey, secret FROM [format_table_name("messages")] WHERE id = [message_id]")
+ var/datum/DBQuery/query_find_message_secret = SSdbcore.NewQuery("SELECT type, targetckey, adminckey, secret FROM [format_table_name("messages")] WHERE id = [message_id] AND deleted = 0")
if(!query_find_message_secret.warn_execute())
return
if(query_find_message_secret.NextRow())
@@ -139,9 +139,9 @@
return
log_admin_private("[key_name(usr)] has toggled [target_ckey]'s [type] made by [admin_ckey] to [secret ? "not secret" : "secret"]")
message_admins("[key_name_admin(usr)] has toggled [target_ckey]'s [type] made by [admin_ckey] to [secret ? "not secret" : "secret"]")
- browse_messages(target_ckey = target_ckey)
+ browse_messages(target_ckey = target_ckey, agegate = TRUE)
-/proc/browse_messages(type, target_ckey, index, linkless = 0, filter)
+/proc/browse_messages(type, target_ckey, index, linkless = FALSE, filter, agegate = FALSE)
if(!SSdbcore.Connect())
to_chat(usr, "Failed to establish database connection.")
return
@@ -169,7 +169,7 @@
else
output += "|\[Filter offline clients\]"
output += ruler
- var/datum/DBQuery/query_get_type_messages = SSdbcore.NewQuery("SELECT id, targetckey, adminckey, text, timestamp, server, lasteditor FROM [format_table_name("messages")] WHERE type = '[type]'")
+ var/datum/DBQuery/query_get_type_messages = SSdbcore.NewQuery("SELECT id, targetckey, adminckey, text, timestamp, server, lasteditor FROM [format_table_name("messages")] WHERE type = '[type]' AND deleted = 0")
if(!query_get_type_messages.warn_execute())
return
while(query_get_type_messages.NextRow())
@@ -193,12 +193,13 @@
output += "
[text]
"
if(target_ckey)
target_ckey = sanitizeSQL(target_ckey)
- var/datum/DBQuery/query_get_messages = SSdbcore.NewQuery("SELECT type, secret, id, adminckey, text, timestamp, server, lasteditor FROM [format_table_name("messages")] WHERE type <> 'memo' AND targetckey = '[target_ckey]' ORDER BY timestamp DESC")
+ var/datum/DBQuery/query_get_messages = SSdbcore.NewQuery("SELECT type, secret, id, adminckey, text, timestamp, server, lasteditor, DATEDIFF(NOW(), timestamp) AS `age` FROM [format_table_name("messages")] WHERE type <> 'memo' AND targetckey = '[target_ckey]' AND deleted = 0 ORDER BY timestamp DESC")
if(!query_get_messages.warn_execute())
return
var/messagedata
var/watchdata
var/notedata
+ var/skipped = 0
while(query_get_messages.NextRow())
type = query_get_messages.item[1]
if(type == "memo")
@@ -212,8 +213,21 @@
var/timestamp = query_get_messages.item[6]
var/server = query_get_messages.item[7]
var/editor_ckey = query_get_messages.item[8]
+ var/age = text2num(query_get_messages.item[9])
+ var/alphatext = ""
+ if (agegate && type == "note" && isnum(config.note_stale_days) && isnum(config.note_fresh_days) && config.note_stale_days > config.note_fresh_days)
+ var/alpha = Clamp(100 - (age - config.note_fresh_days) * (85 / (config.note_stale_days - config.note_fresh_days)), 15, 100)
+ if (alpha < 100)
+ if (alpha <= 15)
+ if (skipped)
+ skipped++
+ continue
+ alpha = 10
+ skipped = TRUE
+ alphatext = "filter: alpha(opacity=[alpha]); opacity: [alpha/100];"
+
var/data
- data += "[timestamp] | [server] | [admin_ckey]"
+ data += " [timestamp] | [server] | [admin_ckey]"
if(!linkless)
data += " \[Delete\]"
if(type == "note")
@@ -226,7 +240,7 @@
data += " \[Edit\]"
if(editor_ckey)
data += " Last edit by [editor_ckey] (Click here to see edit log)"
- data += "
[text]
"
+ data += "
[text]
"
switch(type)
if("message")
messagedata += data
@@ -254,6 +268,15 @@
if(notedata)
output += "Notes
"
output += notedata
+ if(!linkless)
+ if (agegate)
+ if (skipped) //the first skipped message is still shown so that we can put this link over it.
+ output += " \[Show [skipped] hidden messages\]"
+ else
+ output += " \[Show All\]"
+
+ else
+ output += " \[Hide Old\]"
if(index)
var/index_ckey
var/search
@@ -268,7 +291,7 @@
search = "^\[^\[:alpha:\]\]"
else
search = "^[index]"
- var/datum/DBQuery/query_list_messages = SSdbcore.NewQuery("SELECT DISTINCT targetckey FROM [format_table_name("messages")] WHERE type <> 'memo' AND targetckey REGEXP '[search]' ORDER BY targetckey")
+ var/datum/DBQuery/query_list_messages = SSdbcore.NewQuery("SELECT DISTINCT targetckey FROM [format_table_name("messages")] WHERE type <> 'memo' AND targetckey REGEXP '[search]' AND deleted = 0 ORDER BY targetckey")
if(!query_list_messages.warn_execute())
return
while(query_list_messages.NextRow())
@@ -277,7 +300,7 @@
else if(!type && !target_ckey && !index)
output += " \[Add message\]\[Add watchlist entry\]\[Add note\]"
output += ruler
- usr << browse(output, "window=browse_messages;size=900x500")
+ usr << browse({"[output]"}, "window=browse_messages;size=900x500")
proc/get_message_output(type, target_ckey)
if(!SSdbcore.Connect())
@@ -288,7 +311,7 @@ proc/get_message_output(type, target_ckey)
var/output
if(target_ckey)
target_ckey = sanitizeSQL(target_ckey)
- var/query = "SELECT id, adminckey, text, timestamp, lasteditor FROM [format_table_name("messages")] WHERE type = '[type]'"
+ var/query = "SELECT id, adminckey, text, timestamp, lasteditor FROM [format_table_name("messages")] WHERE type = '[type]' AND deleted = 0"
if(type == "message" || type == "watchlist entry")
query += " AND targetckey = '[target_ckey]'"
var/datum/DBQuery/query_get_message_output = SSdbcore.NewQuery(query)
diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm
index f7b0f8b6ff..839bdfc5f0 100644
--- a/code/modules/admin/topic.dm
+++ b/code/modules/admin/topic.dm
@@ -1107,7 +1107,10 @@
else if(href_list["showmessageckey"])
var/target = href_list["showmessageckey"]
- browse_messages(target_ckey = target)
+ var/agegate = TRUE
+ if (href_list["showall"])
+ agegate = FALSE
+ browse_messages(target_ckey = target, agegate = agegate)
else if(href_list["showmessageckeylinkless"])
var/target = href_list["showmessageckeylinkless"]
diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm
index 6135e6ac9d..6fbc7d552f 100644
--- a/code/modules/client/client_procs.dm
+++ b/code/modules/client/client_procs.dm
@@ -577,13 +577,13 @@ GLOBAL_LIST(external_rsc_urls)
var/const/adminckey = "CID-Error"
var/sql_ckey = sanitizeSQL(ckey)
//check to see if we noted them in the last day.
- var/datum/DBQuery/query_get_notes = SSdbcore.NewQuery("SELECT id FROM [format_table_name("messages")] WHERE type = 'note' AND targetckey = '[sql_ckey]' AND adminckey = '[adminckey]' AND timestamp + INTERVAL 1 DAY < NOW()")
+ var/datum/DBQuery/query_get_notes = SSdbcore.NewQuery("SELECT id FROM [format_table_name("messages")] WHERE type = 'note' AND targetckey = '[sql_ckey]' AND adminckey = '[adminckey]' AND timestamp + INTERVAL 1 DAY < NOW() AND deleted = 0")
if(!query_get_notes.Execute())
return
if(query_get_notes.NextRow())
return
//regardless of above, make sure their last note is not from us, as no point in repeating the same note over and over.
- query_get_notes = SSdbcore.NewQuery("SELECT adminckey FROM [format_table_name("messages")] WHERE targetckey = '[sql_ckey]' ORDER BY timestamp DESC LIMIT 1")
+ query_get_notes = SSdbcore.NewQuery("SELECT adminckey FROM [format_table_name("messages")] WHERE targetckey = '[sql_ckey]' AND deleted = 0 ORDER BY timestamp DESC LIMIT 1")
if(!query_get_notes.Execute())
return
if(query_get_notes.NextRow())
diff --git a/code/modules/client/verbs/ooc.dm b/code/modules/client/verbs/ooc.dm
index cd0f893fa6..a86b30e605 100644
--- a/code/modules/client/verbs/ooc.dm
+++ b/code/modules/client/verbs/ooc.dm
@@ -234,7 +234,7 @@ GLOBAL_VAR_INIT(normal_ooc_colour, OOC_COLOR)
to_chat(usr, "Sorry, that function is not enabled on this server.")
return
- browse_messages(null, usr.ckey, null, 1)
+ browse_messages(null, usr.ckey, null, TRUE)
/client/proc/ignore_key(client)
var/client/C = client