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.
8 function user_remove($uid) {
12 logger('Removing user: ' . $uid);
14 $r = q("select * from user where uid = %d limit 1", intval($uid));
16 call_hooks('remove_user',$r[0]);
18 // save username (actually the nickname as it is guaranteed
19 // unique), so it cannot be re-registered in the future.
21 q("insert into userd ( username ) values ( '%s' )",
25 q("DELETE FROM `contact` WHERE `uid` = %d", intval($uid));
26 q("DELETE FROM `group` WHERE `uid` = %d", intval($uid));
27 q("DELETE FROM `group_member` WHERE `uid` = %d", intval($uid));
28 q("DELETE FROM `intro` WHERE `uid` = %d", intval($uid));
29 q("DELETE FROM `event` WHERE `uid` = %d", intval($uid));
30 q("DELETE FROM `item` WHERE `uid` = %d", intval($uid));
31 q("DELETE FROM `mail` WHERE `uid` = %d", intval($uid));
32 q("DELETE FROM `photo` WHERE `uid` = %d", intval($uid));
33 q("DELETE FROM `profile` WHERE `uid` = %d", intval($uid));
34 q("DELETE FROM `profile_check` WHERE `uid` = %d", intval($uid));
35 q("DELETE FROM `pconfig` WHERE `uid` = %d", intval($uid));
36 q("DELETE FROM `user` WHERE `uid` = %d", intval($uid));
37 if($uid == local_user()) {
38 unset($_SESSION['authenticated']);
39 unset($_SESSION['uid']);
40 goaway($a->get_baseurl());
45 function contact_remove($id) {
46 q("DELETE FROM `contact` WHERE `id` = %d LIMIT 1",
49 q("DELETE FROM `item` WHERE `contact-id` = %d ",
52 q("DELETE FROM `photo` WHERE `contact-id` = %d ",
55 q("DELETE FROM `mail` WHERE `contact-id` = %d ",
58 q("DELETE FROM `event` WHERE `cid` = %d ",
61 q("DELETE FROM `queue` WHERE `cid` = %d ",
68 // Contact has refused to recognise us as a friend. We will start a countdown.
69 // If they still don't recognise us in 32 days, the relationship is over,
70 // and we won't waste any more time trying to communicate with them.
71 // This provides for the possibility that their database is temporarily messed
72 // up or some other transient event and that there's a possibility we could recover from it.
74 if(! function_exists('mark_for_death')) {
75 function mark_for_death($contact) {
76 if($contact['term-date'] == '0000-00-00 00:00:00') {
77 q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d LIMIT 1",
78 dbesc(datetime_convert()),
79 intval($contact['id'])
83 $expiry = $contact['term-date'] . ' + 32 days ';
84 if(datetime_convert() > datetime_convert('UTC','UTC',$expiry)) {
86 // relationship is really truly dead.
88 contact_remove($contact['id']);
95 if(! function_exists('unmark_for_death')) {
96 function unmark_for_death($contact) {
97 // It's a miracle. Our dead contact has inexplicably come back to life.
98 q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d LIMIT 1",
99 dbesc('0000-00-00 00:00:00'),
100 intval($contact['id'])
104 if(! function_exists('contact_photo_menu')){
105 function contact_photo_menu($contact) {
116 if($contact['network'] === NETWORK_DFRN) {
118 $profile_link = $a->get_baseurl() . '/redir/' . $contact['id'];
121 $profile_link = $contact['url'];
123 if($profile_link === 'mailbox')
127 $status_link = $profile_link . "?url=status";
128 $photos_link = $profile_link . "?url=photos";
129 $profile_link = $profile_link . "?url=profile";
130 $pm_url = $a->get_baseurl() . '/message/new/' . $contact['id'];
133 $contact_url = $a->get_baseurl() . '/contacts/' . $contact['id'];
134 $posts_link = $a->get_baseurl() . '/network/?cid=' . $contact['id'];
137 t("View status") => $status_link,
138 t("View profile") => $profile_link,
139 t("View photos") => $photos_link,
140 t("View recent") => $posts_link,
141 t("Edit contact") => $contact_url,
142 t("Send PM") => $pm_url,
146 $args = array('contact' => $contact, 'menu' => $menu);
148 call_hooks('contact_photo_menu', $args);
151 foreach($menu as $k=>$v){
153 if(($k !== t("View recent")) && ($k !== t("Send PM")))
154 $o .= "<li><a target=\"redir\" href=\"$v\">$k</a></li>\n";
156 $o .= "<li><a href=\"$v\">$k</a></li>\n";