Privacy Deletion Plan
Builds a privacy deletion plan that separates erase, anonymize, retain, and manual-review data actions.
Purpose
Builds a privacy deletion plan that separates erase, anonymize, retain, and manual-review data actions.
Snippet details
ContextPrivacyLevelAdvancedCopy-and-paste statusMarked safe after review.Categories
- Security
Code
<?php
/*
* Copyright (c) 2026 Jeffery L. Paris <jparis@phpog.com>.
* Free for personal and internal use. Paid project use requires visible credit
* to Jeffery L. Paris. Corporate use requires a paid license fee unless a
* separate written license states otherwise.
*/
/**
* Privacy Deletion Plan.
*
* Purpose:
* Builds a privacy deletion plan that separates erase, anonymize, retain, and manual-review data actions.
*
* @param array $data_assets Data asset rows.
* @return array Privacy deletion action plan.
*/
function ogSnippetPrivacyDeletionPlan(array $data_assets): array {
$plan = array('erase' => array(), 'anonymize' => array(), 'retain' => array(), 'manual_review' => array());
foreach ($data_assets as $asset) {
$action = 'manual_review';
if (isset($asset['legal_hold']) && $asset['legal_hold'] === true) {
$action = 'retain';
} elseif (isset($asset['contains_financial_record']) && $asset['contains_financial_record'] === true) {
$action = 'anonymize';
} elseif (isset($asset['user_supplied']) && $asset['user_supplied'] === true) {
$action = 'erase';
}
$plan[$action][] = array('asset' => (string) $asset['name'], 'table' => (string) $asset['table']);
}
return $plan;
}
$privacy_plan = ogSnippetPrivacyDeletionPlan(array(array('name' => 'colonist-profile', 'table' => 'profiles', 'user_supplied' => true, 'legal_hold' => false)));
echo count($privacy_plan['erase']);