]> git.mxchange.org Git - friendica.git/blob - include/Contact.php
you and me babe
[friendica.git] / include / Contact.php
1 <?php
2
3
4
5
6 function contact_remove($id) {
7         q("DELETE FROM `contact` WHERE `id` = %d LIMIT 1",
8                 intval($id)
9         );
10         q("DELETE FROM `item` WHERE `contact-id` = %d ",
11                 intval($id)
12         );
13         q("DELETE FROM `photo` WHERE `contact-id` = %d ",
14                 intval($id)
15         );
16 }
17
18
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.
24  
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'])
31                 );
32         }
33         else {
34                 $expiry = $contact['term-date'] . ' + 32 days ';
35                 if(datetime_convert() > datetime_convert('UTC','UTC',$expiry)) {
36
37                         // relationship is really truly dead. 
38
39                         contact_remove($contact['id']);
40
41                 }
42         }
43
44 }}
45
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'])
52         );
53 }}
54