<?php /*

 Composr
 Copyright (c) Christopher Graham, 2004-2024

 See docs/LICENSE.md for full licensing information.


 NOTE TO PROGRAMMERS:
   Do not edit this file. If you need to make changes, save your changed file to the appropriate *_custom folder
   **** If you ignore this advice, then your website upgrades (e.g. for bug fixes) will likely kill your changes ****

*/

/**
 * @license    http://opensource.org/licenses/cpal_1.0 Common Public Attribution License
 * @copyright  Christopher Graham
 * @package    core_privacy
 */

/**
 * Hook class.
 */
class Hook_privacy_core extends Hook_privacy_base
{
    /**
     * Find privacy details.
     *
     * @return ?array A map of privacy details in a standardised format (null: disabled)
     */
    public function info() : ?array
    {
        global $MIGHT_BE_USING_CF;

        $deletion_exemptions = '';
        $deletion_exemptions .= '<ul>';
        $deletion_exemptions .= '<li>' . do_lang('PERSONAL_DATA_DELETION_EXPLANATION_EXEMPTION_logged') . '</li>';
        $deletion_exemptions .= '<li>' . do_lang('PERSONAL_DATA_DELETION_EXPLANATION_EXEMPTION_editorial') . '</li>';
        $deletion_exemptions .= '<li>' . do_lang('PERSONAL_DATA_DELETION_EXPLANATION_EXEMPTION_security') . '</li>';
        if (addon_installed('ecommerce')) {
            $deletion_exemptions .= '<li>' . do_lang('PERSONAL_DATA_DELETION_EXPLANATION_EXEMPTION_transactions') . '</li>';
        }
        $deletion_exemptions .= '</ul>';

        return [
            'label' => 'WEBSITE_SOFTWARE',

            'description' => 'privacy:DESCRIPTION_PRIVACY_WEBSITE_SOFTWARE',

            'cookies' => [
                'cms_autosave_*' => [
                    'reason' => do_lang_tempcode('COOKIE_autosave'),
                ],
                'has_cookies' => [
                    'reason' => do_lang_tempcode('COOKIE_has_cookies'),
                ],
                'has_js' => (get_option('detect_javascript') == '0') ? null : [
                    'reason' => do_lang_tempcode('COOKIE_has_js'),
                ],
                'last_visit' => [
                    'reason' => do_lang_tempcode('COOKIE_last_visit'),
                ],
                get_member_cookie() . ' & ' . get_pass_cookie() => [
                    'reason' => do_lang_tempcode('COOKIE_automatic_login'),
                ],
                get_member_cookie() . '_invisible' => [
                    'reason' => do_lang_tempcode('COOKIE_invisible'),
                ],
                get_session_cookie() => [
                    'reason' => do_lang_tempcode('COOKIE_session'),
                ],
                'tray_*, hide*, og_*' => [
                    'reason' => do_lang_tempcode('COOKIE_trays'),
                ],
                'use_wysiwyg' => [
                    'reason' => do_lang_tempcode('COOKIE_use_wysiwyg'),
                ],
                'client_time*' => (get_option('is_on_timezone_detection') == '0') ? null : [
                    'reason' => do_lang_tempcode('COOKIE_client_time'),
                ],
                'font_size' => [
                    'reason' => do_lang_tempcode('COOKIE_font_size'),
                ],
                '__ut*, _ga, _gid' => (get_option('google_analytics') == '') ? null : [
                    'reason' => do_lang_tempcode('COOKIE_ga'),
                ],
            ],

            'positive' => [
                [
                    'heading' => do_lang('INFORMATION_STORAGE'),
                    'explanation' => do_lang_tempcode('CORRECTIONS_EXPLANATION'),
                ],
                [
                    'heading' => do_lang('INFORMATION_STORAGE'),
                    'explanation' => do_lang_tempcode('PERSONAL_DATA_DOWNLOAD_EXPLANATION'),
                ],
                [
                    'heading' => do_lang('INFORMATION_STORAGE'),
                    'explanation' => do_lang_tempcode('PERSONAL_DATA_DELETION_EXPLANATION', protect_from_escaping($deletion_exemptions)),
                ],
            ],

            'general' => [
                ((get_option('spam_check_level') == 'NEVER') || (get_option('spam_check_stopforumspam') == '0' && (get_option('stopforumspam_api_key') == ''))) ? null : [
                    'heading' => do_lang('INFORMATION_TRANSFER'),
                    'action' => do_lang_tempcode('PRIVACY_ACTION_stopforumspam'),
                    'reason' => do_lang_tempcode('PRIVACY_REASON_stopforumspam'),
                ],
                ((get_option('spam_check_level') == 'NEVER') || ((get_option('spam_use_tornevall') == '0') && strpos(get_option('spam_block_lists'), 'dnsbl.tornevall.org') === false)) ? null : [
                    'heading' => do_lang('INFORMATION_TRANSFER'),
                    'action' => do_lang_tempcode('PRIVACY_ACTION_tornevall'),
                    'reason' => do_lang_tempcode('PRIVACY_REASON_tornevall'),
                ],
                ((get_option('spam_check_level') == 'NEVER') || (get_option('spam_block_lists') == '')) ? null : [
                    'heading' => do_lang('INFORMATION_TRANSFER'),
                    'action' => do_lang_tempcode('PRIVACY_ACTION_dnsbl'),
                    'reason' => do_lang_tempcode('PRIVACY_REASON_dnsbl'),
                ],
                (empty($MIGHT_BE_USING_CF)) ? null : [
                    'heading' => do_lang('INFORMATION_TRANSFER'),
                    'action' => do_lang_tempcode('PRIVACY_ACTION_cloudflare', escape_html(get_site_name())),
                    'reason' => do_lang_tempcode('PRIVACY_REASON_cloudflare'),
                ],
                [
                    'heading' => do_lang('INFORMATION_STORAGE'),
                    'action' => do_lang_tempcode('PRIVACY_ACTION_metadata'),
                    'reason' => do_lang_tempcode('PRIVACY_REASON_metadata'),
                ],
                [
                    'heading' => do_lang('INFORMATION_STORAGE'),
                    'action' => do_lang_tempcode('PRIVACY_ACTION_editorial'),
                    'reason' => do_lang_tempcode('PRIVACY_REASON_editorial'),
                ],
                [
                    'heading' => do_lang('INFORMATION_STORAGE'),
                    'action' => do_lang_tempcode('PRIVACY_ACTION_bans'),
                    'reason' => do_lang_tempcode('PRIVACY_REASON_bans'),
                ],
                [ // We define this here, not in newsletters hook, as webmasters are likely to use newsletters using external software
                    'heading' => do_lang('GENERAL'),
                    'action' => do_lang_tempcode('PRIVACY_ACTION_newsletter', escape_html(get_site_name()), escape_html(get_option('site_scope'))),
                    'reason' => do_lang_tempcode('PRIVACY_REASON_newsletter'),
                ],
                [
                    'heading' => do_lang('INFORMATION_DISCLOSURE'),
                    'action' => do_lang_tempcode((get_option('is_on_invisibility') == '1') ? 'PRIVACY_ACTION_online_status_invisible' : 'PRIVACY_ACTION_online_status'),
                    'reason' => do_lang_tempcode('PRIVACY_REASON_online_status'),
                ],
                [
                    'heading' => do_lang('GENERAL'),
                    'action' => do_lang_tempcode('PRIVACY_ACTION_no_dnt'),
                    'reason' => do_lang_tempcode('PRIVACY_REASON_no_dnt'),
                ],
                [
                    'heading' => do_lang('INFORMATION_TRANSFER'),
                    'action' => do_lang_tempcode('PRIVACY_ACTION_ip_lookup'),
                    'reason' => do_lang_tempcode('PRIVACY_REASON_ip_lookup'),
                ],
                [
                    'heading' => do_lang('INFORMATION_TRANSFER'),
                    'action' => do_lang_tempcode('PRIVACY_ACTION_web_code'),
                    'reason' => do_lang_tempcode('PRIVACY_REASON_web_code'),
                ],
                (get_option('gravatars') == '0') ? null : [
                    'heading' => do_lang('INFORMATION_DISCLOSURE'),
                    'action' => do_lang_tempcode('PRIVACY_ACTION_gravatar'),
                    'reason' => do_lang_tempcode('PRIVACY_REASON_gravatar'),
                ],
            ],

            'database_records' => [
                'email_bounces' => [
                    'timestamp_field' => 'b_time',
                    'retention_days' => null,
                    'retention_handle_method' => PRIVACY_METHOD__LEAVE,
                    'owner_id_field' => null,
                    'additional_member_id_fields' => [],
                    'ip_address_fields' => [],
                    'email_fields' => ['b_email_address'],
                    'username_fields' => [],
                    'file_fields' => [],
                    'additional_anonymise_fields' => [],
                    'extra_where' => null,
                    'removal_default_handle_method' => PRIVACY_METHOD__DELETE,
                    'removal_default_handle_method_member_override' => null,
                    'allowed_handle_methods' => PRIVACY_METHOD__DELETE,
                ],
                'unsubscribed_emails' => [
                    'timestamp_field' => 'b_time',
                    'retention_days' => null,
                    'retention_handle_method' => PRIVACY_METHOD__LEAVE,
                    'owner_id_field' => null,
                    'additional_member_id_fields' => [],
                    'ip_address_fields' => [],
                    'email_fields' => ['b_email_address'],
                    'username_fields' => [],
                    'file_fields' => [],
                    'additional_anonymise_fields' => [],
                    'extra_where' => null,
                    'removal_default_handle_method' => PRIVACY_METHOD__DELETE,
                    'removal_default_handle_method_member_override' => null,
                    'allowed_handle_methods' => PRIVACY_METHOD__DELETE,
                ],
                'actionlogs' => [
                    'timestamp_field' => 'date_and_time',
                    'retention_days' => null,
                    'retention_handle_method' => PRIVACY_METHOD__LEAVE,
                    'owner_id_field' => 'member_id',
                    'additional_member_id_fields' => [],
                    'ip_address_fields' => ['ip'],
                    'email_fields' => [],
                    'username_fields' => [],
                    'file_fields' => [],
                    'additional_anonymise_fields' => ['param_a', 'param_b'],
                    'extra_where' => null,
                    'removal_default_handle_method' => PRIVACY_METHOD__ANONYMISE,
                    'removal_default_handle_method_member_override' => null,
                    'allowed_handle_methods' => PRIVACY_METHOD__ANONYMISE | PRIVACY_METHOD__DELETE,
                ],
                'logged_mail_messages' => [
                    'timestamp_field' => 'm_date_and_time',
                    'retention_days' => null,//intval(get_option('email_log_store_time')),
                    'retention_handle_method' => PRIVACY_METHOD__LEAVE, // Happens automatically
                    'owner_id_field' => 'm_member_id',
                    'additional_member_id_fields' => ['m_as_member'],
                    'ip_address_fields' => [],
                    'email_fields' => ['m_from_email', 'm_sender_email'], // TODO: need special functions for m_to_email (serialised) in this hook
                    'username_fields' => [],
                    'file_fields' => [],
                    'additional_anonymise_fields' => ['m_to_name', 'm_from_name'],
                    'extra_where' => null,
                    'removal_default_handle_method' => PRIVACY_METHOD__ANONYMISE,
                    'removal_default_handle_method_member_override' => null,
                    'allowed_handle_methods' => PRIVACY_METHOD__ANONYMISE,
                ],
                'rating' => [
                    'timestamp_field' => 'rating_time',
                    'retention_days' => null,
                    'retention_handle_method' => PRIVACY_METHOD__LEAVE,
                    'owner_id_field' => 'rating_member',
                    'additional_member_id_fields' => [],
                    'ip_address_fields' => ['rating_ip_address'],
                    'email_fields' => [],
                    'username_fields' => [],
                    'file_fields' => [],
                    'additional_anonymise_fields' => [],
                    'extra_where' => null,
                    'removal_default_handle_method' => PRIVACY_METHOD__ANONYMISE,
                    'removal_default_handle_method_member_override' => null,
                    'allowed_handle_methods' => PRIVACY_METHOD__ANONYMISE | PRIVACY_METHOD__DELETE,
                ],
                'trackbacks' => [
                    'timestamp_field' => 'trackback_time',
                    'retention_days' => null,
                    'retention_handle_method' => PRIVACY_METHOD__LEAVE,
                    'owner_id_field' => null,
                    'additional_member_id_fields' => [],
                    'ip_address_fields' => ['trackback_ip_address'],
                    'email_fields' => [],
                    'username_fields' => [],
                    'file_fields' => [],
                    'additional_anonymise_fields' => [],
                    'extra_where' => null,
                    'removal_default_handle_method' => PRIVACY_METHOD__DELETE,
                    'removal_default_handle_method_member_override' => null,
                    'allowed_handle_methods' => PRIVACY_METHOD__ANONYMISE | PRIVACY_METHOD__DELETE,
                ],
                'failedlogins' => [
                    'timestamp_field' => 'date_and_time',
                    'retention_days' => intval(get_option('website_activity_store_time')),
                    'retention_handle_method' => PRIVACY_METHOD__ANONYMISE,
                    'owner_id_field' => null,
                    'additional_member_id_fields' => [],
                    'ip_address_fields' => ['ip'],
                    'email_fields' => [],
                    'username_fields' => ['failed_account'/*Could contain valid usernames of those who did not type their password in correctly*/],
                    'file_fields' => [],
                    'additional_anonymise_fields' => [],
                    'extra_where' => null,
                    'removal_default_handle_method' => PRIVACY_METHOD__ANONYMISE,
                    'removal_default_handle_method_member_override' => PRIVACY_METHOD__LEAVE, // Security
                    'allowed_handle_methods' => PRIVACY_METHOD__ANONYMISE | PRIVACY_METHOD__DELETE,
                ],
                'post_tokens' => [
                    'timestamp_field' => 'generation_time',
                    'retention_days' => intval(ceil(floatval(get_option('csrf_token_expire_new')) / 24.0)),
                    'retention_handle_method' => PRIVACY_METHOD__DELETE,
                    'owner_id_field' => 'member_id',
                    'additional_member_id_fields' => [],
                    'ip_address_fields' => ['ip_address'],
                    'email_fields' => [],
                    'username_fields' => [],
                    'file_fields' => [],
                    'additional_anonymise_fields' => ['session_id', 'token'],
                    'extra_where' => null,
                    'removal_default_handle_method' => PRIVACY_METHOD__DELETE,
                    'removal_default_handle_method_member_override' => null,
                    'allowed_handle_methods' => PRIVACY_METHOD__DELETE,
                ],
                'sessions' => [
                    'timestamp_field' => 'last_activity_time',
                    'retention_days' => intval(ceil(floatval(get_option('session_expiry_time')) / 24.0)),
                    'retention_handle_method' => PRIVACY_METHOD__DELETE,
                    'owner_id_field' => 'member_id',
                    'additional_member_id_fields' => [],
                    'ip_address_fields' => ['ip'],
                    'email_fields' => [],
                    'username_fields' => ['cache_username'],
                    'file_fields' => [],
                    'additional_anonymise_fields' => ['the_session'],
                    'extra_where' => null,
                    'removal_default_handle_method' => PRIVACY_METHOD__DELETE,
                    'removal_default_handle_method_member_override' => null,
                    'allowed_handle_methods' => PRIVACY_METHOD__DELETE,
                ],
                'attachments' => [
                    'timestamp_field' => 'a_add_time',
                    'retention_days' => null,
                    'retention_handle_method' => PRIVACY_METHOD__LEAVE,
                    'owner_id_field' => 'a_member_id',
                    'additional_member_id_fields' => [],
                    'ip_address_fields' => [],
                    'email_fields' => [],
                    'username_fields' => [],
                    'file_fields' => ['a_thumb_url', 'a_url'],
                    'additional_anonymise_fields' => [],
                    'extra_where' => null,
                    'removal_default_handle_method' => PRIVACY_METHOD__ANONYMISE,
                    'removal_default_handle_method_member_override' => null,
                    'allowed_handle_methods' => PRIVACY_METHOD__ANONYMISE | PRIVACY_METHOD__DELETE,
                ],
                'staff_tips_dismissed' => [
                    'timestamp_field' => null,
                    'retention_days' => null,
                    'retention_handle_method' => PRIVACY_METHOD__LEAVE,
                    'owner_id_field' => 't_member',
                    'additional_member_id_fields' => [],
                    'ip_address_fields' => [],
                    'email_fields' => [],
                    'username_fields' => [],
                    'file_fields' => [],
                    'additional_anonymise_fields' => [],
                    'extra_where' => null,
                    'removal_default_handle_method' => PRIVACY_METHOD__DELETE,
                    'removal_default_handle_method_member_override' => null,
                    'allowed_handle_methods' => PRIVACY_METHOD__DELETE,
                ],
                'member_tracking' => [
                    'timestamp_field' => 'mt_time',
                    'retention_days' => intval(ceil(floatval(get_option('users_online_time')) / 24.0)),
                    'retention_handle_method' => PRIVACY_METHOD__DELETE,
                    'owner_id_field' => 'mt_member_id',
                    'additional_member_id_fields' => [],
                    'ip_address_fields' => [],
                    'email_fields' => [],
                    'username_fields' => ['mt_cache_username'],
                    'file_fields' => [],
                    'additional_anonymise_fields' => [],
                    'extra_where' => null,
                    'removal_default_handle_method' => PRIVACY_METHOD__DELETE,
                    'removal_default_handle_method_member_override' => null,
                    'allowed_handle_methods' => PRIVACY_METHOD__DELETE,
                ],
                'member_privileges' => [
                    'timestamp_field' => 'active_until',
                    'retention_days' => intval(get_option('website_activity_store_time')),
                    'retention_handle_method' => PRIVACY_METHOD__DELETE,
                    'owner_id_field' => 'member_id',
                    'additional_member_id_fields' => [],
                    'ip_address_fields' => [],
                    'email_fields' => [],
                    'username_fields' => [],
                    'file_fields' => [],
                    'additional_anonymise_fields' => [],
                    'extra_where' => 'the_value!=0',
                    'removal_default_handle_method' => PRIVACY_METHOD__DELETE,
                    'removal_default_handle_method_member_override' => null,
                    'allowed_handle_methods' => PRIVACY_METHOD__DELETE,
                ],
                'member_zone_access' => [
                    'timestamp_field' => 'active_until',
                    'retention_days' => intval(get_option('website_activity_store_time')),
                    'retention_handle_method' => PRIVACY_METHOD__DELETE,
                    'owner_id_field' => 'member_id',
                    'additional_member_id_fields' => [],
                    'ip_address_fields' => [],
                    'email_fields' => [],
                    'username_fields' => [],
                    'file_fields' => [],
                    'additional_anonymise_fields' => [],
                    'extra_where' => null,
                    'removal_default_handle_method' => PRIVACY_METHOD__DELETE,
                    'removal_default_handle_method_member_override' => null,
                    'allowed_handle_methods' => PRIVACY_METHOD__DELETE,
                ],
                'member_page_access' => [
                    'timestamp_field' => 'active_until',
                    'retention_days' => intval(get_option('website_activity_store_time')),
                    'retention_handle_method' => PRIVACY_METHOD__DELETE,
                    'owner_id_field' => 'member_id',
                    'additional_member_id_fields' => [],
                    'ip_address_fields' => [],
                    'email_fields' => [],
                    'username_fields' => [],
                    'file_fields' => [],
                    'additional_anonymise_fields' => [],
                    'extra_where' => null,
                    'removal_default_handle_method' => PRIVACY_METHOD__DELETE,
                    'removal_default_handle_method_member_override' => null,
                    'allowed_handle_methods' => PRIVACY_METHOD__DELETE,
                ],
                'member_category_access' => [
                    'timestamp_field' => 'active_until',
                    'retention_days' => intval(get_option('website_activity_store_time')),
                    'retention_handle_method' => PRIVACY_METHOD__DELETE,
                    'owner_id_field' => 'member_id',
                    'additional_member_id_fields' => [],
                    'ip_address_fields' => [],
                    'email_fields' => [],
                    'username_fields' => [],
                    'file_fields' => [],
                    'additional_anonymise_fields' => [],
                    'extra_where' => null,
                    'removal_default_handle_method' => PRIVACY_METHOD__DELETE,
                    'removal_default_handle_method_member_override' => null,
                    'allowed_handle_methods' => PRIVACY_METHOD__DELETE,
                ],
                'autosave' => [
                    'timestamp_field' => 'a_time',
                    'retention_days' => 1,
                    'retention_handle_method' => PRIVACY_METHOD__DELETE,
                    'owner_id_field' => 'a_member_id',
                    'additional_member_id_fields' => [],
                    'ip_address_fields' => [],
                    'email_fields' => [],
                    'username_fields' => [],
                    'file_fields' => [],
                    'additional_anonymise_fields' => [],
                    'extra_where' => null,
                    'removal_default_handle_method' => PRIVACY_METHOD__DELETE,
                    'removal_default_handle_method_member_override' => null,
                    'allowed_handle_methods' => PRIVACY_METHOD__DELETE,
                ],
                'comcode_pages' => [
                    'timestamp_field' => 'p_add_date',
                    'retention_days' => null,
                    'retention_handle_method' => PRIVACY_METHOD__LEAVE,
                    'owner_id_field' => 'p_submitter',
                    'additional_member_id_fields' => [],
                    'ip_address_fields' => [],
                    'email_fields' => [],
                    'username_fields' => [],
                    'file_fields' => [],
                    'additional_anonymise_fields' => [],
                    'extra_where' => null,
                    'removal_default_handle_method' => PRIVACY_METHOD__ANONYMISE,
                    'removal_default_handle_method_member_override' => null,
                    'allowed_handle_methods' => PRIVACY_METHOD__ANONYMISE | PRIVACY_METHOD__DELETE,
                ],
                'incoming_uploads' => [
                    'timestamp_field' => 'i_date_and_time',
                    'retention_days' => 2,
                    'retention_handle_method' => PRIVACY_METHOD__DELETE,
                    'owner_id_field' => 'i_submitter',
                    'additional_member_id_fields' => [],
                    'ip_address_fields' => [],
                    'email_fields' => [],
                    'username_fields' => [],
                    'file_fields' => ['i_save_url'],
                    'additional_anonymise_fields' => [],
                    'extra_where' => null,
                    'removal_default_handle_method' => PRIVACY_METHOD__DELETE,
                    'removal_default_handle_method_member_override' => null,
                    'allowed_handle_methods' => PRIVACY_METHOD__DELETE,
                ],
                'cron_caching_requests' => [
                    'timestamp_field' => null,
                    'retention_days' => null,
                    'retention_handle_method' => PRIVACY_METHOD__LEAVE,
                    'owner_id_field' => 'c_member',
                    'additional_member_id_fields' => [],
                    'ip_address_fields' => [],
                    'email_fields' => [],
                    'username_fields' => [],
                    'file_fields' => [],
                    'additional_anonymise_fields' => [],
                    'extra_where' => null,
                    'removal_default_handle_method' => PRIVACY_METHOD__DELETE,
                    'removal_default_handle_method_member_override' => null,
                    'allowed_handle_methods' => PRIVACY_METHOD__DELETE,
                ],
                'cache' => [
                    'timestamp_field' => 'date_and_time',
                    'retention_days' => null,
                    'retention_handle_method' => PRIVACY_METHOD__LEAVE,
                    'owner_id_field' => 'the_member',
                    'additional_member_id_fields' => [],
                    'ip_address_fields' => [],
                    'email_fields' => [],
                    'username_fields' => [],
                    'file_fields' => [],
                    'additional_anonymise_fields' => [],
                    'extra_where' => null,
                    'removal_default_handle_method' => PRIVACY_METHOD__DELETE,
                    'removal_default_handle_method_member_override' => null,
                    'allowed_handle_methods' => PRIVACY_METHOD__DELETE,
                ],
                'notifications_enabled' => [
                    'timestamp_field' => null,
                    'retention_days' => null,
                    'retention_handle_method' => PRIVACY_METHOD__LEAVE,
                    'owner_id_field' => 'l_member_id',
                    'additional_member_id_fields' => [],
                    'ip_address_fields' => [],
                    'email_fields' => [],
                    'username_fields' => [],
                    'file_fields' => [],
                    'additional_anonymise_fields' => [],
                    'extra_where' => null,
                    'removal_default_handle_method' => PRIVACY_METHOD__DELETE,
                    'removal_default_handle_method_member_override' => null,
                    'allowed_handle_methods' => PRIVACY_METHOD__DELETE,
                ],
                'digestives_tin' => [
                    'timestamp_field' => 'd_date_and_time',
                    'retention_days' => null,
                    'retention_handle_method' => PRIVACY_METHOD__LEAVE,
                    'owner_id_field' => 'd_to_member_id', // The one who gets the notification is the one who owns it
                    'additional_member_id_fields' => ['d_from_member_id'],
                    'ip_address_fields' => [],
                    'email_fields' => [],
                    'username_fields' => [],
                    'file_fields' => [],
                    'additional_anonymise_fields' => [],
                    'extra_where' => null,
                    'removal_default_handle_method' => PRIVACY_METHOD__ANONYMISE,
                    'removal_default_handle_method_member_override' => null,
                    'allowed_handle_methods' => PRIVACY_METHOD__ANONYMISE | PRIVACY_METHOD__DELETE,
                ],
                'digestives_consumed' => [
                    'timestamp_field' => 'c_time',
                    'retention_days' => null,
                    'retention_handle_method' => PRIVACY_METHOD__LEAVE,
                    'owner_id_field' => 'c_member_id',
                    'additional_member_id_fields' => [],
                    'ip_address_fields' => [],
                    'email_fields' => [],
                    'username_fields' => [],
                    'file_fields' => [],
                    'additional_anonymise_fields' => [],
                    'extra_where' => null,
                    'removal_default_handle_method' => PRIVACY_METHOD__DELETE,
                    'removal_default_handle_method_member_override' => null,
                    'allowed_handle_methods' => PRIVACY_METHOD__DELETE,
                ],
                'task_queue' => [
                    'timestamp_field' => 't_add_time',
                    'retention_days' => null,
                    'retention_handle_method' => PRIVACY_METHOD__LEAVE,
                    'owner_id_field' => 't_member_id',
                    'additional_member_id_fields' => [],
                    'ip_address_fields' => [],
                    'email_fields' => [],
                    'username_fields' => [],
                    'file_fields' => [],
                    'additional_anonymise_fields' => [],
                    'extra_where' => null,
                    'removal_default_handle_method' => PRIVACY_METHOD__DELETE,
                    'removal_default_handle_method_member_override' => null,
                    'allowed_handle_methods' => PRIVACY_METHOD__DELETE,
                ],
                'translate' => [
                    'timestamp_field' => null,
                    'retention_days' => null,
                    'retention_handle_method' => PRIVACY_METHOD__LEAVE,
                    'owner_id_field' => 'source_user',
                    'additional_member_id_fields' => [],
                    'ip_address_fields' => [],
                    'email_fields' => [],
                    'username_fields' => [],
                    'file_fields' => [],
                    'additional_anonymise_fields' => [],
                    'extra_where' => null,
                    'removal_default_handle_method' => PRIVACY_METHOD__ANONYMISE,
                    'removal_default_handle_method_member_override' => null,
                    'allowed_handle_methods' => PRIVACY_METHOD__ANONYMISE,
                ],
                'edit_pings' => [
                    'timestamp_field' => 'the_time',
                    'retention_days' => 1,
                    'retention_handle_method' => PRIVACY_METHOD__DELETE,
                    'owner_id_field' => 'the_member',
                    'additional_member_id_fields' => [],
                    'ip_address_fields' => [],
                    'email_fields' => [],
                    'username_fields' => [],
                    'file_fields' => [],
                    'additional_anonymise_fields' => [],
                    'extra_where' => null,
                    'removal_default_handle_method' => PRIVACY_METHOD__DELETE,
                    'removal_default_handle_method_member_override' => null,
                    'allowed_handle_methods' => PRIVACY_METHOD__DELETE,
                ],
                'daily_visits' => [
                    'timestamp_field' => 'd_date_and_time',
                    'retention_days' => null,
                    'retention_handle_method' => PRIVACY_METHOD__LEAVE,
                    'owner_id_field' => 'd_member_id',
                    'additional_member_id_fields' => [],
                    'ip_address_fields' => [],
                    'email_fields' => [],
                    'username_fields' => [],
                    'file_fields' => [],
                    'additional_anonymise_fields' => [],
                    'extra_where' => null,
                    'removal_default_handle_method' => PRIVACY_METHOD__DELETE,
                    'removal_default_handle_method_member_override' => null,
                    'allowed_handle_methods' => PRIVACY_METHOD__DELETE,
                ],
            ],
        ];
    }

    /**
     * Serialise a row.
     *
     * @param  ID_TEXT $table_name Table name
     * @param  array $row Row raw from the database
     * @return array Row in a cleanly serialised format
     */
    public function serialise(string $table_name, array $row) : array
    {
        $ret = parent::serialise($table_name, $row);

        switch ($table_name) {
            case 'rating':
                require_code('content');
                list($title, , $info) = content_get_details($row['rating_for_type'], $row['rating_for_id']);
                $ret += [
                    'content_type__dereferenced' => do_lang($info['content_type_label']),
                    'content_title__dereferenced' => $title,
                ];
                break;

            case 'trackbacks':
                require_code('content');
                list($title, , $info) = content_get_details($row['trackback_for_type'], $row['trackback_for_id']);
                $ret += [
                    'content_type__dereferenced' => do_lang($info['content_type_label']),
                    'content_title__dereferenced' => $title,
                ];
                break;
        }

        return $ret;
    }

    /**
     * Delete a row.
     *
     * @param  ID_TEXT $table_name Table name
     * @param  array $table_details Details of the table from the info function
     * @param  array $row Row raw from the database
     */
    public function delete(string $table_name, array $table_details, array $row)
    {
        switch ($table_name) {
            case 'attachments':
                require_code('attachments3');
                _delete_attachment($row['id'], $GLOBALS['SITE_DB']);
                break;

            case 'comcode_pages':
                require_code('zones3');
                delete_cms_page($row['the_zone'], $row['the_page'], 'comcode_custom', false);
                break;

            case 'incoming_uploads':
                parent::delete($table_name, $table_details, $row);
                @unlink(get_custom_file_base() . '/' . $row['i_save_url']);
                break;

            default:
                parent::delete($table_name, $table_details, $row);
                break;
        }
    }
}
