Exclude settings-type user options from the export
authorAlexander Ebert <ebert@woltlab.com>
Mon, 21 May 2018 20:42:06 +0000 (22:42 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 21 May 2018 20:42:06 +0000 (22:42 +0200)
wcfsetup/install/files/lib/acp/action/UserExportGdprAction.class.php

index af5d8f229a744d9fc0f9492260ad7003770ec3c6..b5f86a37f8a0f9b6e19173963bac6b9186198b36 100644 (file)
@@ -42,6 +42,13 @@ class UserExportGdprAction extends AbstractAction {
         */
        public $exportUserPropertiesIfNotEmpty = array('username', 'email', 'registrationDate', 'oldUsername', 'lastUsernameChange', 'signature', 'lastActivityTime', 'userTitle');
        
+       /**
+        * list of user options that are associated with a settings.* category, but should be included
+        * in the export regardless
+        * @var string[]
+        */
+       public $exportUserOptionSettingsIfNotEmpty = array('timezone');
+       
        /**
         * list of database tables that hold ip addresses, the identifier is used to check if the
         * package is installed and on success exports the data from all listed table names
@@ -285,6 +292,13 @@ class UserExportGdprAction extends AbstractAction {
                                        continue;
                                }
                                
+                               // ignore settings unless they are explicitly white-listed
+                               if (strpos($option->categoryName, 'settings.') === 0) {
+                                       if (!in_array($option->optionName, $this->exportUserOptionSettingsIfNotEmpty)) {
+                                               continue;
+                                       }
+                               }
+                               
                                $optionValue = $this->user->getUserOption($option->optionName);
                                if ($option->optionType === 'boolean') {
                                        $optionValue = ($optionValue == 1);
@@ -294,6 +308,11 @@ class UserExportGdprAction extends AbstractAction {
                                        if ($formattedValue) $optionValue = $formattedValue;
                                }
                                
+                               // skip empty string values (but not values that resolve to `false` or `0`
+                               if ($optionValue === '') {
+                                       continue;
+                               }
+                               
                                $data[$option->optionName] = $optionValue;
                        }
                }