Skip to content
wiki.fftac.org

Participants Database - Source Excerpt 01

Back to Participants Database

Summary

This source excerpt preserves a bounded section of Anti-Christ.org/wp-content/plugins/fftac-foundation-core/inc/participants-database.php so readers can inspect the evidence without opening the full source file.

**Source path:** Anti-Christ.org/wp-content/plugins/fftac-foundation-core/inc/participants-database.php

<?php
/**
 * Participants Database bridge for Foundation-owned intake and member profiles.
 *
 * @package FFTAC_Foundation_Core
 */

if (!defined('ABSPATH')) {
    exit;
}

/**
 * Returns whether the Participants Database API is loaded enough for syncing.
 *
 * @return bool
 */
function antichrist_engine_foundation_participants_database_is_available()
{
    return class_exists('Participants_Db')
        && method_exists('Participants_Db', 'write_participant')
        && method_exists('Participants_Db', 'add_blank_field');
}

/**
 * Returns whether the Participants Database plugin files are present locally.
 *
 * @return bool
 */
function antichrist_engine_foundation_participants_database_is_installed()
{
    $plugin_file = dirname(FFTAC_FOUNDATION_CORE_PLUGIN_DIR) . '/participants-database/participants-database.php';

    return is_readable($plugin_file);
}

/**
 * Defines the FFTAC mirror fields expected in Participants Database.
 *
 * @return array<string, array<string, scalar>>
 */
function antichrist_engine_foundation_participants_database_expected_fields()
{
    return array(
        'fftac_site_project' => array(
            'title'        => __('FFTAC Site Project', 'antichrist-engine'),
            'group'        => 'admin',
            'form_element' => 'text-line',
            'CSV'          => 1,
            'readonly'     => 1,
            'sortable'     => 1,
            'order'        => 900,
        ),
        'fftac_record_kind' => array(
            'title'        => __('FFTAC Record Kind', 'antichrist-engine'),
            'group'        => 'admin',
            'form_element' => 'text-line',
            'CSV'          => 1,
            'readonly'     => 1,
            'sortable'     => 1,
            'order'        => 901,
        ),
        'fftac_intake_source' => array(
            'title'        => __('FFTAC Intake Source', 'antichrist-engine'),
            'group'        => 'admin',
            'form_element' => 'text-line',
            'CSV'          => 1,
            'readonly'     => 1,
            'sortable'     => 1,
            'order'        => 902,
        ),
        'fftac_intake_record_id' => array(
            'title'        => __('FFTAC Intake Record ID', 'antichrist-engine'),
            'group'        => 'admin',
            'form_element' => 'text-line',
            'CSV'          => 1,
            'readonly'     => 1,
            'sortable'     => 1,
            'order'        => 903,
        ),
        'fftac_intake_post_id' => array(
            'title'        => __('FFTAC Intake Post ID', 'antichrist-engine'),
            'group'        => 'admin',
            'form_element' => 'text-line',
            'CSV'          => 1,
            'readonly'     => 1,
            'sortable'     => 1,
            'order'        => 904,
        ),
        'fftac_intake_lane' => array(
            'title'        => __('FFTAC Intake Lane', 'antichrist-engine'),
            'group'        => 'admin',
            'form_element' => 'text-line',
            'CSV'          => 1,
            'readonly'     => 1,
            'sortable'     => 1,
            'order'        => 905,
        ),
        'fftac_intake_context' => array(
            'title'        => __('FFTAC Intake Context', 'antichrist-engine'),
            'group'        => 'admin',
            'form_element' => 'text-line',
            'CSV'          => 1,
            'readonly'     => 1,
            'order'        => 906,
        ),
        'fftac_intake_subject' => array(
            'title'        => __('FFTAC Intake Subject', 'antichrist-engine'),
            'group'        => 'admin',
            'form_element' => 'text-line',
            'CSV'          => 1,
            'readonly'     => 1,
            'order'        => 907,
        ),
        'fftac_intake_message' => array(
            'title'        => __('FFTAC Intake Message', 'antichrist-engine'),
            'group'        => 'admin',
            'form_element' => 'text-area',
            'CSV'          => 1,
            'readonly'     => 1,
            'order'        => 908,
        ),
        'fftac_intake_notes' => array(
            'title'        => __('FFTAC Intake Notes', 'antichrist-engine'),
            'group'        => 'admin',
            'form_element' => 'text-area',
            'CSV'          => 1,
            'readonly'     => 1,
            'order'        => 909,
        ),
        'fftac_member_record_id' => array(
            'title'        => __('FFTAC Member Record ID', 'antichrist-engine'),
            'group'        => 'admin',
            'form_element' => 'text-line',
            'CSV'          => 1,
            'readonly'     => 1,
            'sortable'     => 1,
            'order'        => 920,
        ),
        'fftac_wp_user_id' => array(
            'title'        => __('FFTAC WP User ID', 'antichrist-engine'),
            'group'        => 'admin',
            'form_element' => 'text-line',
            'CSV'          => 1,
            'readonly'     => 1,
            'sortable'     => 1,
            'order'        => 921,
        ),
        'fftac_wp_user_login' => array(
            'title'        => __('FFTAC WP User Login', 'antichrist-engine'),
            'group'        => 'admin',
            'form_element' => 'text-line',
            'CSV'          => 1,
            'readonly'     => 1,
            'sortable'     => 1,
            'order'        => 922,
        ),
        'fftac_member_status' => array(
            'title'        => __('FFTAC Member Status', 'antichrist-engine'),
            'group'        => 'admin',
            'form_element' => 'text-line',
            'CSV'          => 1,
            'readonly'     => 1,
            'sortable'     => 1,
            'order'        => 923,
        ),
        'fftac_member_registered_at' => array(
            'title'        => __('FFTAC Member Registered At', 'antichrist-engine'),
            'group'        => 'admin',
            'form_element' => 'text-line',
            'CSV'          => 1,
            'readonly'     => 1,
            'sortable'     => 1,
            'order'        => 924,
        ),
        'fftac_member_public_alias' => array(
            'title'        => __('FFTAC Member Public Alias', 'antichrist-engine'),
            'group'        => 'main',
            'form_element' => 'text-line',
            'CSV'          => 1,
            'readonly'     => 1,
            'sortable'     => 1,
            'order'        => 925,
        ),
        'fftac_member_profile_summary' => array(
            'title'        => __('FFTAC Member Profile Summary', 'antichrist-engine'),
            'group'        => 'main',
            'form_element' => 'text-area',
            'CSV'          => 1,
            'readonly'     => 1,
            'order'        => 926,
        ),
    );
}

/**
 * Clears Participants Database field-definition caches after schema changes.
 *
 * @return void
 */
function antichrist_engine_foundation_participants_database_flush_field_cache()
{
    if (!function_exists('wp_cache_delete')) {
        return;
    }

    if (class_exists('PDb_Form_Field_Def')) {
        wp_cache_delete(PDb_Form_Field_Def::def_cache);
    }

    wp_cache_delete('pdb_field_def_array');
    wp_cache_delete('pdb-db-field-list');
    wp_cache_delete('pdb-field_list');
    wp_cache_delete('pdb-field_list1');
}

/**
 * Checks whether a Participants Database field definition exists.
 *
 * @param string $field_name Field name.
 * @return bool
 */
function antichrist_engine_foundation_participants_database_field_exists($field_name)
{
    $field_name = sanitize_key((string) $field_name);

    if (!$field_name || !class_exists('Participants_Db')) {
        return false;
    }

    if (isset(Participants_Db::$fields[$field_name])) {
        return true;
    }

    global $wpdb;

    if (!is_object($wpdb) || empty(Participants_Db::$fields_table) || !method_exists($wpdb, 'get_var') || !method_exists($wpdb, 'prepare')) {
        return false;
    }

    $count = $wpdb->get_var($wpdb->prepare(
        'SELECT COUNT(*) FROM ' . Participants_Db::$fields_table . ' WHERE `name` = %s',
        $field_name
    ));

    return (int) $count > 0;
}

/**
 * Ensures Participants Database has the FFTAC mirror fields.
 *
 * @return array<string, mixed>
 */
function antichrist_engine_foundation_participants_database_ensure_schema()
{
    $result = array(
        'available' => antichrist_engine_foundation_participants_database_is_available(),
        'added'     => 0,
        'missing'   => array(),
    );

    if (empty($result['available'])) {
        $result['missing'] = array_keys(antichrist_engine_foundation_participants_database_expected_fields());

        return $result;
    }