6 function contact_remove($id) {
7 q("DELETE FROM `contact` WHERE `id` = %d LIMIT 1",
10 q("DELETE FROM `item` WHERE `contact-id` = %d ",
13 q("DELETE FROM `photo` WHERE `contact-id` = %d ",
19 // Contact has refused to recognise us as a friend. We will start a countdown.
20 // If they still don't recognise us in 32 days, the relationship is over,
21 // and we won't waste any more time trying to communicate with them.
22 // This provides for the possibility that their database is temporarily messed
23 // up or some other transient event and that there's a possibility we could recover from it.
25 if(! function_exists('mark_for_death')) {
26 function mark_for_death($contact) {
27 if($contact['term-date'] == '0000-00-00 00:00:00') {
28 q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d LIMIT 1",
29 dbesc(datetime_convert()),
30 intval($contact['id'])
34 $expiry = $contact['term-date'] . ' + 32 days ';
35 if(datetime_convert() > datetime_convert('UTC','UTC',$expiry)) {
37 // relationship is really truly dead.
39 contact_remove($contact['id']);
46 if(! function_exists('unmark_for_death')) {
47 function unmark_for_death($contact) {
48 // It's a miracle. Our dead contact has inexplicably come back to life.
49 q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d LIMIT 1",
50 dbesc('0000-00-00 00:00:00'),
51 intval($contact['id'])