]> git.mxchange.org Git - friendica.git/blob - include/Contact.php
more lint
[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 }
38
39
40 // Contact has refused to recognise us as a friend. We will start a countdown.
41 // If they still don't recognise us in 32 days, the relationship is over,
42 // and we won't waste any more time trying to communicate with them.
43 // This provides for the possibility that their database is temporarily messed
44 // up or some other transient event and that there's a possibility we could recover from it.
45  
46 if(! function_exists('mark_for_death')) {
47 function mark_for_death($contact) {
48         if($contact['term-date'] == '0000-00-00 00:00:00') {
49                 q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d LIMIT 1",
50                                 dbesc(datetime_convert()),
51                                 intval($contact['id'])
52                 );
53         }
54         else {
55                 $expiry = $contact['term-date'] . ' + 32 days ';
56                 if(datetime_convert() > datetime_convert('UTC','UTC',$expiry)) {
57
58                         // relationship is really truly dead. 
59
60                         contact_remove($contact['id']);
61
62                 }
63         }
64
65 }}
66
67 if(! function_exists('unmark_for_death')) {
68 function unmark_for_death($contact) {
69         // It's a miracle. Our dead contact has inexplicably come back to life.
70         q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d LIMIT 1",
71                 dbesc('0000-00-00 00:00:00'),
72                 intval($contact['id'])
73         );
74 }}
75