Privacy - Source Excerpt 03
Summary
This source excerpt preserves a bounded section of Spiralist/wp-content/plugins/spiralist-workspace/includes/Privacy/Privacy.php so readers can inspect the evidence without opening the full source file.
**Source path:** Spiralist/wp-content/plugins/spiralist-workspace/includes/Privacy/Privacy.php
'spiralist_workspace_prompt_versions',
__('Workspace Prompt Versions', 'spiralist-workspace'),
'prompt-version-' . (int) ($row['id'] ?? 0),
$data
);
}
return $items;
}
/**
* Returns prompt-sharing export items.
*
* @return array<int,array<string,mixed>>
*/
private function share_export_items(int $user_id): array
{
global $wpdb;
$sql = $wpdb->prepare(
'SELECT * FROM ' . Installer::table('prompt_permissions') . ' WHERE shared_with_user_id = %d OR granted_by_user_id = %d ORDER BY created_utc ASC, id ASC',
$user_id,
$user_id
);
$rows = $wpdb->get_results($sql, ARRAY_A);
if (!is_array($rows)) {
return [];
}
$items = [];
foreach ($rows as $row) {
$data = [];
$this->add_export_pair($data, __('Share ID', 'spiralist-workspace'), $row['id'] ?? 0);
$this->add_export_pair($data, __('Prompt ID', 'spiralist-workspace'), $row['prompt_post_id'] ?? 0);
$this->add_export_pair($data, __('Prompt title', 'spiralist-workspace'), $this->prompt_title((int) ($row['prompt_post_id'] ?? 0)));
$this->add_export_pair($data, __('Shared with user ID', 'spiralist-workspace'), $row['shared_with_user_id'] ?? 0);
$this->add_export_pair($data, __('Granted by user ID', 'spiralist-workspace'), $row['granted_by_user_id'] ?? 0);
$this->add_export_pair($data, __('Permission type', 'spiralist-workspace'), $row['permission_type'] ?? '');
$this->add_export_pair($data, __('Created UTC', 'spiralist-workspace'), $row['created_utc'] ?? '');
$items[] = $this->build_export_item(
'spiralist_workspace_prompt_shares',
__('Workspace Sharing Grants', 'spiralist-workspace'),
'prompt-share-' . (int) ($row['id'] ?? 0),
$data
);
}
return $items;
}
/**
* Returns favorite export items.
*
* @return array<int,array<string,mixed>>
*/
private function favorite_export_items(int $user_id): array
{
global $wpdb;
$sql = $wpdb->prepare(
'SELECT * FROM ' . Installer::table('favorites') . ' WHERE user_id = %d ORDER BY created_utc ASC, id ASC',
$user_id
);
$rows = $wpdb->get_results($sql, ARRAY_A);
if (!is_array($rows)) {
return [];
}
$items = [];
foreach ($rows as $row) {
$data = [];
$this->add_export_pair($data, __('Favorite ID', 'spiralist-workspace'), $row['id'] ?? 0);
$this->add_export_pair($data, __('Prompt ID', 'spiralist-workspace'), $row['prompt_post_id'] ?? 0);
$this->add_export_pair($data, __('Prompt title', 'spiralist-workspace'), $this->prompt_title((int) ($row['prompt_post_id'] ?? 0)));
$this->add_export_pair($data, __('Created UTC', 'spiralist-workspace'), $row['created_utc'] ?? '');
$items[] = $this->build_export_item(
'spiralist_workspace_favorites',
__('Workspace Favorites', 'spiralist-workspace'),
'workspace-favorite-' . (int) ($row['id'] ?? 0),
$data
);
}
return $items;
}
/**
* Returns prompt-test export items.
*
* @return array<int,array<string,mixed>>
*/
private function test_export_items(int $user_id): array
{
global $wpdb;
$sql = $wpdb->prepare(
'SELECT * FROM ' . Installer::table('prompt_tests') . ' WHERE created_by_user_id = %d ORDER BY created_utc ASC, id ASC',
$user_id
);
$rows = $wpdb->get_results($sql, ARRAY_A);
if (!is_array($rows)) {
return [];
}
$items = [];
foreach ($rows as $row) {
$data = [];
$this->add_export_pair($data, __('Test ID', 'spiralist-workspace'), $row['id'] ?? 0);
$this->add_export_pair($data, __('Prompt ID', 'spiralist-workspace'), $row['prompt_post_id'] ?? 0);
$this->add_export_pair($data, __('Prompt title', 'spiralist-workspace'), $this->prompt_title((int) ($row['prompt_post_id'] ?? 0)));
$this->add_export_pair($data, __('Input text', 'spiralist-workspace'), $row['input_text'] ?? '');
$this->add_export_pair($data, __('Expected output text', 'spiralist-workspace'), $row['expected_output_text'] ?? '');
$this->add_export_pair($data, __('Variables JSON', 'spiralist-workspace'), $row['variables_json'] ?? '');
$this->add_export_pair($data, __('Match strategy', 'spiralist-workspace'), $row['match_strategy'] ?? '');
$this->add_export_pair($data, __('Last run ID', 'spiralist-workspace'), $row['last_run_id'] ?? '');
$this->add_export_pair($data, __('Last result status', 'spiralist-workspace'), $row['last_result_status'] ?? '');
$this->add_export_pair($data, __('Last result JSON', 'spiralist-workspace'), $row['last_result_json'] ?? '');
$this->add_export_pair($data, __('Created UTC', 'spiralist-workspace'), $row['created_utc'] ?? '');
$this->add_export_pair($data, __('Updated UTC', 'spiralist-workspace'), $row['updated_utc'] ?? '');
$items[] = $this->build_export_item(
'spiralist_workspace_prompt_tests',
__('Workspace Prompt Tests', 'spiralist-workspace'),
'prompt-test-' . (int) ($row['id'] ?? 0),
$data
);
}
return $items;
}
/**
* Returns prompt-run export items.
*
* @return array<int,array<string,mixed>>
*/
private function run_export_items(int $user_id): array
{
global $wpdb;
$sql = $wpdb->prepare(
'SELECT * FROM ' . Installer::table('prompt_runs') . ' WHERE user_id = %d ORDER BY created_utc ASC, id ASC',
$user_id
);
$rows = $wpdb->get_results($sql, ARRAY_A);
if (!is_array($rows)) {
return [];
}
$items = [];
foreach ($rows as $row) {
$data = [];
$this->add_export_pair($data, __('Run ID', 'spiralist-workspace'), $row['id'] ?? 0);
$this->add_export_pair($data, __('Prompt ID', 'spiralist-workspace'), $row['prompt_post_id'] ?? 0);
$this->add_export_pair($data, __('Prompt title', 'spiralist-workspace'), $this->prompt_title((int) ($row['prompt_post_id'] ?? 0)));
$this->add_export_pair($data, __('Conversation ID', 'spiralist-workspace'), $row['conversation_id'] ?? '');
$this->add_export_pair($data, __('Version used', 'spiralist-workspace'), $row['version_number_used'] ?? '');
$this->add_export_pair($data, __('Model used', 'spiralist-workspace'), $row['model_used'] ?? '');
$this->add_export_pair($data, __('Input text', 'spiralist-workspace'), $row['input_text'] ?? '');
$this->add_export_pair($data, __('Output text', 'spiralist-workspace'), $row['output_text'] ?? '');
$this->add_export_pair($data, __('Status', 'spiralist-workspace'), $row['status'] ?? '');
$this->add_export_pair($data, __('Request payload JSON', 'spiralist-workspace'), $row['request_payload_json'] ?? '');
$this->add_export_pair($data, __('Response payload JSON', 'spiralist-workspace'), $row['response_payload_json'] ?? '');
$this->add_export_pair($data, __('Token usage JSON', 'spiralist-workspace'), $row['token_usage_json'] ?? '');
$this->add_export_pair($data, __('Error message', 'spiralist-workspace'), $row['error_message'] ?? '');
$this->add_export_pair($data, __('Runtime reference', 'spiralist-workspace'), $row['openai_response_id'] ?? '');
$this->add_export_pair($data, __('Cost estimate', 'spiralist-workspace'), $row['cost_estimate'] ?? '');
$this->add_export_pair($data, __('Created UTC', 'spiralist-workspace'), $row['created_utc'] ?? '');
$this->add_export_pair($data, __('Completed UTC', 'spiralist-workspace'), $row['completed_utc'] ?? '');
$items[] = $this->build_export_item(
'spiralist_workspace_runs',
__('Workspace Runs', 'spiralist-workspace'),
'workspace-run-' . (int) ($row['id'] ?? 0),
$data
);
}
return $items;
}
/**
* Returns conversation export items.
*
* @return array<int,array<string,mixed>>
*/
private function conversation_export_items(int $user_id): array
{