]> git.mxchange.org Git - friendica.git/blob - include/Contact.php
compatibility: version discovery
[friendica.git] / include / Contact.php
1 <?php
2
3
4 // Included here for completeness, but this is a very dangerous operation.
5 // It is the caller's responsibility to confirm the requestor's intent and
6 // authorisation to do this.
7
8 function user_remove($uid) {
9         q("DELETE FROM `contact` WHERE `uid` = %d", intval($uid));
10         q("DELETE FROM `group` WHERE `uid` = %d", intval($uid));
11         q("DELETE FROM `group_member` WHERE `uid` = %d", intval($uid));
12         q("DELETE FROM `intro` WHERE `uid` = %d", intval($uid));
13         q("DELETE FROM `item` WHERE `uid` = %d", intval($uid));
14         q("DELETE FROM `mail` WHERE `uid` = %d", intval($uid));
15         q("DELETE FROM `photo` WHERE `uid` = %d", intval($uid));
16         q("DELETE FROM `profile` WHERE `uid` = %d", intval($uid));
17         q("DELETE FROM `profile_check` WHERE `uid` = %d", intval($uid));
18         q("DELETE FROM `user` WHERE `uid` = %d", intval($uid));
19         if($uid == local_user()) {
20                 unset($_SESSION['authenticated']);
21                 unset($_SESSION['uid']);
22                 killme();
23         }
24 }
25
26
27 function contact_remove($id) {
28         q("DELETE FROM `contact` WHERE `id` = %d LIMIT 1",
29                 intval($id)
30         );
31         q("DELETE FROM `item` WHERE `contact-id` = %d ",
32                 intval($id)
33         );
34         q("DELETE FROM `photo` WHERE `contact-id` = %d ",
35                 intval($id)
36         );
37         q("DELETE FROM `mail` WHERE `contact-id` = %d ",
38                 intval($id)
39         );
40 }
41
42
43 // Contact has refused to recognise us as a friend. We will start a countdown.
44 // If they still don't recognise us in 32 days, the relationship is over,
45 // and we won't waste any more time trying to communicate with them.
46 // This provides for the possibility that their database is temporarily messed
47 // up or some other transient event and that there's a possibility we could recover from it.
48  
49 if(! function_exists('mark_for_death')) {
50 function mark_for_death($contact) {
51         if($contact['term-date'] == '0000-00-00 00:00:00') {
52                 q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d LIMIT 1",
53                                 dbesc(datetime_convert()),
54                                 intval($contact['id'])
55                 );
56         }
57         else {
58                 $expiry = $contact['term-date'] . ' + 32 days ';
59                 if(datetime_convert() > datetime_convert('UTC','UTC',$expiry)) {
60
61                         // relationship is really truly dead. 
62
63                         contact_remove($contact['id']);
64
65                 }
66         }
67
68 }}
69
70 if(! function_exists('unmark_for_death')) {
71 function unmark_for_death($contact) {
72         // It's a miracle. Our dead contact has inexplicably come back to life.
73         q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d LIMIT 1",
74                 dbesc('0000-00-00 00:00:00'),
75                 intval($contact['id'])
76         );
77 }}
78