From 9d3a44d110f3090010bcf360c710330cf3e428c4 Mon Sep 17 00:00:00 2001 From: wrongecho Date: Thu, 6 Nov 2025 15:10:25 +0000 Subject: [PATCH] Contacts API - Archiving & Un-archiving --- api/v1/contacts/archive.php | 52 +++++++++++++++++++++++++++++++++++ api/v1/contacts/unarchive.php | 46 +++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 api/v1/contacts/archive.php create mode 100644 api/v1/contacts/unarchive.php diff --git a/api/v1/contacts/archive.php b/api/v1/contacts/archive.php new file mode 100644 index 00000000..831df469 --- /dev/null +++ b/api/v1/contacts/archive.php @@ -0,0 +1,52 @@ + 0) { + mysqli_query($mysqli, "UPDATE users SET user_archived_at = NOW() WHERE user_id = $contact_user_id"); + } + + // Archive contact + $update_sql = mysqli_query($mysqli, " + UPDATE contacts SET + contact_important = 0, + contact_billing = 0, + contact_technical = 0, + contact_archived_at = NOW() + WHERE contact_id = $contact_id AND contact_client_id = $client_id + "); + + if ($update_sql) { + $update_count = mysqli_affected_rows($mysqli); + + // Logging + logAction("Contact", "Archive", "$contact_name archived via API ($api_key_name)", $client_id, $contact_id); + } + } +} + +// Output +require_once '../update_output.php'; \ No newline at end of file diff --git a/api/v1/contacts/unarchive.php b/api/v1/contacts/unarchive.php new file mode 100644 index 00000000..adc57d60 --- /dev/null +++ b/api/v1/contacts/unarchive.php @@ -0,0 +1,46 @@ + 0) { + mysqli_query($mysqli, "UPDATE users SET user_archived_at = NULL WHERE user_id = $contact_user_id"); + } + + // Un-archive contact + $update_sql = mysqli_query($mysqli, "UPDATE contacts SET contact_archived_at = NULL WHERE contact_id = $contact_id AND contact_client_id = $client_id + "); + + if ($update_sql) { + $update_count = mysqli_affected_rows($mysqli); + + // Logging + logAction("Contact", "Unarchive", "$contact_name unarchived via API ($api_key_name)", $client_id, $contact_id); + } + } +} + +// Output +require_once '../update_output.php'; \ No newline at end of file