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