diff --git a/SQL/bubber_schema.sql b/SQL/bubber_schema.sql index 324bd19e6f6..1691b77fc15 100644 --- a/SQL/bubber_schema.sql +++ b/SQL/bubber_schema.sql @@ -45,3 +45,12 @@ CREATE TABLE `stored_faxes` ( COLLATE='utf8mb4_general_ci' ENGINE=InnoDB ; + +DROP TABLE IF EXISTS `privacy_policy_acceptances`; +CREATE TABLE `privacy_policy_acceptances` ( + `id` INT NOT NULL AUTO_INCREMENT, + `ckey` VARCHAR(32) NOT NULL, + `policy_key` VARCHAR(64) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE INDEX `ckey_policy_unique` (`ckey`, `policy_key`) +); diff --git a/SQL/database_changelog.md b/SQL/database_changelog.md index 12b2e47340a..69c1d1eb57a 100644 --- a/SQL/database_changelog.md +++ b/SQL/database_changelog.md @@ -2,16 +2,16 @@ Any time you make a change to the schema files, remember to increment the databa Make sure to also update `DB_MAJOR_VERSION` and `DB_MINOR_VERSION`, which can be found in `code/__DEFINES/subsystem.dm`. -The latest database version is 5.35 (for bubberstation) (5.33 for /tg/); The query to update the schema revision table is: +The latest database version is 5.36 (for bubberstation) (5.33 for /tg/); The query to update the schema revision table is: ```sql -INSERT INTO `schema_revision` (`major`, `minor`) VALUES (5, 35); +INSERT INTO `schema_revision` (`major`, `minor`) VALUES (5, 36); ``` or ```sql -INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (5, 35); +INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (5, 36); ``` In any query remember to add a prefix to the table names if you use one. diff --git a/code/__DEFINES/~~bubber_defines/privacy_policy.dm b/code/__DEFINES/~~bubber_defines/privacy_policy.dm new file mode 100644 index 00000000000..35abc57c96b --- /dev/null +++ b/code/__DEFINES/~~bubber_defines/privacy_policy.dm @@ -0,0 +1 @@ +#define CURRENT_PRIVACY_KEY "privacy_v1" diff --git a/modular_skyrat/master_files/code/modules/mob/login.dm b/modular_skyrat/master_files/code/modules/mob/login.dm index d6b7292841b..44c84bc6b55 100644 --- a/modular_skyrat/master_files/code/modules/mob/login.dm +++ b/modular_skyrat/master_files/code/modules/mob/login.dm @@ -7,6 +7,12 @@ if(SSplayer_ranks.initialized) SSplayer_ranks.update_prefs_donator_status(client?.prefs) - if(!client.prefs.privacy_policy_acknowledged) - client.show_privacy_policy() + if(!SSprivacy.has_accepted(client?.ckey, CURRENT_PRIVACY_KEY)) + if(!Master.init_stage_completed) + spawn(600) + if(client) + client.show_privacy_policy() + else if(Master.init_stage_completed) + if(client) + client.show_privacy_policy() return TRUE diff --git a/modular_zubbers/code/controllers/subsystem/privacy_policy.dm b/modular_zubbers/code/controllers/subsystem/privacy_policy.dm new file mode 100644 index 00000000000..46fafa8a9c0 --- /dev/null +++ b/modular_zubbers/code/controllers/subsystem/privacy_policy.dm @@ -0,0 +1,51 @@ +SUBSYSTEM_DEF(privacy) + name = "Privacy Policy" + flags = SS_NO_FIRE + + VAR_PRIVATE/list/completed_by_ckey = list() + +/datum/controller/subsystem/privacy/Initialize() + if(!CONFIG_GET(flag/sql_enabled)) + return + load_initial_acceptances() + return SS_INIT_SUCCESS + +/datum/controller/subsystem/privacy/proc/load_initial_acceptances() + if(!SSdbcore.IsConnected()) + return + + var/datum/db_query/query = SSdbcore.NewQuery("SELECT ckey, policy_key FROM [format_table_name("privacy_policy_acceptances")]") + + if(!query.Execute()) + qdel(query) + return + + while(query.NextRow()) + var/ckey = query.item[1] + var/policy_key = query.item[2] + + completed_by_ckey[ckey] ||= list() + completed_by_ckey[ckey] += policy_key + + qdel(query) + +/datum/controller/subsystem/privacy/proc/has_accepted(ckey, policy_key) + return completed_by_ckey[ckey] && (policy_key in completed_by_ckey[ckey]) + +/datum/controller/subsystem/privacy/proc/mark_accepted(ckey, policy_key) + if(has_accepted(ckey, policy_key)) + return + + completed_by_ckey[ckey] ||= list() + completed_by_ckey[ckey] += policy_key + + var/datum/db_query/query = SSdbcore.NewQuery( + "INSERT IGNORE INTO [format_table_name("privacy_policy_acceptances")] (ckey, policy_key) VALUES (:ckey, :policy_key)", + list( + "ckey" = ckey, + "policy_key" = policy_key + ) + ) + + query.Execute() + qdel(query) diff --git a/modular_zubbers/code/modules/client/preferences/preferences.dm b/modular_zubbers/code/modules/client/preferences/preferences.dm deleted file mode 100644 index ba8a3c18c97..00000000000 --- a/modular_zubbers/code/modules/client/preferences/preferences.dm +++ /dev/null @@ -1,2 +0,0 @@ -/datum/preferences - var/privacy_policy_acknowledged diff --git a/modular_zubbers/code/modules/client/preferences_savefile.dm b/modular_zubbers/code/modules/client/preferences_savefile.dm deleted file mode 100644 index 2e5a129fe82..00000000000 --- a/modular_zubbers/code/modules/client/preferences_savefile.dm +++ /dev/null @@ -1,7 +0,0 @@ -/datum/preferences/load_preferences() - . = ..() - savefile.get_entry("privacy_policy_acknowledged", privacy_policy_acknowledged) - -/datum/preferences/save_preferences() - . = ..() - savefile.set_entry("privacy_policy_acknowledged", privacy_policy_acknowledged) diff --git a/modular_zubbers/code/modules/privacy_policy/privacy_policy.dm b/modular_zubbers/code/modules/privacy_policy/privacy_policy.dm index e801043c711..5955e35d716 100644 --- a/modular_zubbers/code/modules/privacy_policy/privacy_policy.dm +++ b/modular_zubbers/code/modules/privacy_policy/privacy_policy.dm @@ -1,5 +1,3 @@ -#define CURRENT_PRIVACY_VERSION 1 - /datum/privacy_policy_ui var/client/owner @@ -11,6 +9,10 @@ return GLOB.always_state /datum/privacy_policy_ui/ui_close(mob/user) + if(!SSprivacy.has_accepted(owner.ckey, CURRENT_PRIVACY_KEY)) + if(owner) + to_chat(owner, span_danger("You must accept the Privacy Policy to continue playing.")) + qdel(owner) qdel(src) /datum/privacy_policy_ui/ui_data(mob/user) @@ -22,9 +24,8 @@ . = ..() switch(action) if("accept") - if(owner?.prefs) - owner.prefs.privacy_policy_acknowledged = TRUE - owner.prefs.save_preferences() + if(owner?.ckey) + SSprivacy.mark_accepted(owner.ckey, CURRENT_PRIVACY_KEY) ui.close() return TRUE @@ -39,10 +40,16 @@ ui.open() /client/proc/show_privacy_policy() + if(!CONFIG_GET(flag/sql_enabled)) + return + if(!mob) return + if(SSprivacy.has_accepted(mob?.ckey, CURRENT_PRIVACY_KEY)) + return + + SStgui.close_user_uis(mob) + var/datum/privacy_policy_ui/ui = new(src) ui.ui_interact(mob) - -#undef CURRENT_PRIVACY_VERSION diff --git a/tgstation.dme b/tgstation.dme index 3e32aa469c2..7c6c533ec24 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -541,6 +541,7 @@ #include "code\__DEFINES\~~bubber_defines\mobs.dm" #include "code\__DEFINES\~~bubber_defines\mood.dm" #include "code\__DEFINES\~~bubber_defines\nanites.dm" +#include "code\__DEFINES\~~bubber_defines\privacy_policy.dm" #include "code\__DEFINES\~~bubber_defines\research_categories.dm" #include "code\__DEFINES\~~bubber_defines\robot_defines.dm" #include "code\__DEFINES\~~bubber_defines\role_preferences.dm" @@ -8879,6 +8880,7 @@ #include "modular_zubbers\code\controllers\subsystem\job.dm" #include "modular_zubbers\code\controllers\subsystem\map_vote.dm" #include "modular_zubbers\code\controllers\subsystem\mapping.dm" +#include "modular_zubbers\code\controllers\subsystem\privacy_policy.dm" #include "modular_zubbers\code\controllers\subsystem\research.dm" #include "modular_zubbers\code\controllers\subsystem\security_level.dm" #include "modular_zubbers\code\controllers\subsystem\ticker.dm" @@ -9297,7 +9299,6 @@ #include "modular_zubbers\code\modules\client\client_color.dm" #include "modular_zubbers\code\modules\client\client_procs.dm" #include "modular_zubbers\code\modules\client\preferences.dm" -#include "modular_zubbers\code\modules\client\preferences_savefile.dm" #include "modular_zubbers\code\modules\client\ssd.dm" #include "modular_zubbers\code\modules\client\autopunctuation\preferences.dm" #include "modular_zubbers\code\modules\client\flavor_text\flavor_text.dm" @@ -9305,7 +9306,6 @@ #include "modular_zubbers\code\modules\client\preferences\footstep_sound.dm" #include "modular_zubbers\code\modules\client\preferences\permanent_limp.dm" #include "modular_zubbers\code\modules\client\preferences\player_panel.dm" -#include "modular_zubbers\code\modules\client\preferences\preferences.dm" #include "modular_zubbers\code\modules\client\preferences\screen.dm" #include "modular_zubbers\code\modules\client\preferences\sounds.dm" #include "modular_zubbers\code\modules\client\preferences\unique_blood_color.dm" diff --git a/tgui/packages/tgui/interfaces/PrivacyPolicy.tsx b/tgui/packages/tgui/interfaces/PrivacyPolicy.tsx index 7feb174e365..6016360c333 100644 --- a/tgui/packages/tgui/interfaces/PrivacyPolicy.tsx +++ b/tgui/packages/tgui/interfaces/PrivacyPolicy.tsx @@ -1,5 +1,5 @@ -import { useBackend } from '../backend'; import { Button, Section } from 'tgui-core/components'; +import { useBackend } from '../backend'; import { Window } from '../layouts'; interface PrivacyPolicyData { @@ -11,21 +11,13 @@ export const PrivacyPolicy = () => { const { policy_text } = data; return ( - +
-
- {policy_text} -
+
{policy_text}
-