2016-11-28 22:44:04 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @file include/remove_contact.php
|
|
|
|
* @brief Removes orphaned data from deleted contacts
|
|
|
|
*/
|
2017-01-18 22:45:32 +01:00
|
|
|
|
|
|
|
use \Friendica\Core\Config;
|
|
|
|
|
2016-11-28 22:44:04 +01:00
|
|
|
function remove_contact_run($argv, $argc) {
|
|
|
|
if ($argc != 2) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$id = intval($argv[1]);
|
|
|
|
|
|
|
|
// Only delete if the contact doesn't exist (anymore)
|
|
|
|
$r = q("SELECT `id` FROM `contact` WHERE `id` = %d", intval($id));
|
|
|
|
if (dbm::is_result($r)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
q("DELETE FROM `item` WHERE `contact-id` = %d", intval($id));
|
|
|
|
|
|
|
|
q("DELETE FROM `photo` WHERE `contact-id` = %d", intval($id));
|
|
|
|
|
|
|
|
q("DELETE FROM `mail` WHERE `contact-id` = %d", intval($id));
|
|
|
|
|
|
|
|
q("DELETE FROM `event` WHERE `cid` = %d", intval($id));
|
|
|
|
|
|
|
|
q("DELETE FROM `queue` WHERE `cid` = %d", intval($id));
|
|
|
|
}
|
|
|
|
?>
|