diff --git a/SQL/database_changelog.txt b/SQL/database_changelog.txt
index e75ec546930..9a56620e157 100644
--- a/SQL/database_changelog.txt
+++ b/SQL/database_changelog.txt
@@ -1,3 +1,15 @@
+19 July 2015, by Jordie0608
+
+Added new table 'memo' for use with admin memos.
+
+To create this new table run the following command:
+
+CREATE TABLE `memo` (`id` int(11) NOT NULL AUTO_INCREMENT, `ckey` varchar(32) NOT NULL, `memotext` text NOT NULL, `timestamp` datetime NOT NULL, `last_editor` varchar(32), `edits` text, PRIMARY KEY (`id`))
+
+Remember to add prefix to the table name if you use them.
+
+----------------------------------------------------
+
7 July 2015, by MrStonedOne
Removed the privacy poll and related table. Existing codebases may safely delete the privacy table after updating:
diff --git a/SQL/tgstation_schema.sql b/SQL/tgstation_schema.sql
index bfac8fd54d0..b6797101692 100644
--- a/SQL/tgstation_schema.sql
+++ b/SQL/tgstation_schema.sql
@@ -321,4 +321,23 @@ CREATE TABLE `watch` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `memo`
+--
+
+DROP TABLE IF EXISTS `memo`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `memo` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `ckey` varchar(32) NOT NULL,
+ `memotext` text NOT NULL,
+ `timestamp` datetime NOT NULL,
+ `last_editor` varchar(32),
+ `edits` text,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+
-- Dump completed on 2013-03-24 18:02:35
diff --git a/SQL/tgstation_schema_prefixed.sql b/SQL/tgstation_schema_prefixed.sql
index 9724a3edd68..70e02e2c304 100644
--- a/SQL/tgstation_schema_prefixed.sql
+++ b/SQL/tgstation_schema_prefixed.sql
@@ -316,4 +316,23 @@ CREATE TABLE `SS13_watch` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `SS13_memo`
+--
+
+DROP TABLE IF EXISTS `SS13_memo`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `SS13_memo` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `ckey` varchar(32) NOT NULL,
+ `memotext` text NOT NULL,
+ `timestamp` datetime NOT NULL,
+ `last_editor` varchar(32),
+ `edits` text,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+
-- Dump completed on 2013-03-24 18:02:35
diff --git a/code/__HELPERS/time.dm b/code/__HELPERS/time.dm
index c297d043a30..d3f9b6c1868 100644
--- a/code/__HELPERS/time.dm
+++ b/code/__HELPERS/time.dm
@@ -33,3 +33,7 @@ proc/time_stamp()
// Uncomment this out when debugging!
//else
//return 1
+
+//returns time in a sql and ISO 8601 friendly format
+/proc/SQLtime()
+ return time2text(world.realtime, "YYYY-MM-DD hh:mm:ss")
\ No newline at end of file
diff --git a/code/modules/admin/admin_memo.dm b/code/modules/admin/admin_memo.dm
index 89f9116aeaf..64ede615a6c 100644
--- a/code/modules/admin/admin_memo.dm
+++ b/code/modules/admin/admin_memo.dm
@@ -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 << "Failed to establish database connection."
+ 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("[src.ckey] removed their own Memo")
- 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,"